revert auto focus next field on valid mnemonic word

This commit is contained in:
julian 2023-09-11 17:54:01 -06:00
parent dae4a38287
commit 16718b94e6

View file

@ -98,7 +98,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
final List<TextEditingController> _controllers = []; final List<TextEditingController> _controllers = [];
final List<FormInputStatus> _inputStatuses = []; final List<FormInputStatus> _inputStatuses = [];
final List<FocusNode> _focusNodes = []; // final List<FocusNode> _focusNodes = [];
late final BarcodeScannerInterface scanner; late final BarcodeScannerInterface scanner;
@ -152,7 +152,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
for (int i = 0; i < _seedWordCount; i++) { for (int i = 0; i < _seedWordCount; i++) {
_controllers.add(TextEditingController()); _controllers.add(TextEditingController());
_inputStatuses.add(FormInputStatus.empty); _inputStatuses.add(FormInputStatus.empty);
_focusNodes.add(FocusNode()); // _focusNodes.add(FocusNode());
} }
super.initState(); super.initState();
@ -821,8 +821,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
i * 4 + j - 1 == 1 i * 4 + j - 1 == 1
? textSelectionControls ? textSelectionControls
: null, : null,
focusNode: // focusNode:
_focusNodes[i * 4 + j - 1], // _focusNodes[i * 4 + j - 1],
onChanged: (value) { onChanged: (value) {
final FormInputStatus final FormInputStatus
formInputStatus; formInputStatus;
@ -841,18 +841,18 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
FormInputStatus.invalid; FormInputStatus.invalid;
} }
if (formInputStatus == // if (formInputStatus ==
FormInputStatus.valid) { // FormInputStatus.valid) {
if (i * 4 + j < // if (i * 4 + j <
_focusNodes.length) { // _focusNodes.length) {
_focusNodes[i * 4 + j] // _focusNodes[i * 4 + j]
.requestFocus(); // .requestFocus();
} else if (i * 4 + j == // } else if (i * 4 + j ==
_focusNodes.length) { // _focusNodes.length) {
_focusNodes[i * 4 + j - 1] // _focusNodes[i * 4 + j - 1]
.unfocus(); // .unfocus();
} // }
} // }
setState(() { setState(() {
_inputStatuses[i * 4 + _inputStatuses[i * 4 +
j - j -
@ -929,7 +929,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
selectionControls: i == 1 selectionControls: i == 1
? textSelectionControls ? textSelectionControls
: null, : null,
focusNode: _focusNodes[i], // focusNode: _focusNodes[i],
onChanged: (value) { onChanged: (value) {
final FormInputStatus final FormInputStatus
formInputStatus; formInputStatus;
@ -948,27 +948,27 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
FormInputStatus.invalid; FormInputStatus.invalid;
} }
if (formInputStatus == // if (formInputStatus ==
FormInputStatus // FormInputStatus
.valid && // .valid &&
(i - 1) < // (i - 1) <
_focusNodes.length) { // _focusNodes.length) {
Focus.of(context) // Focus.of(context)
.requestFocus( // .requestFocus(
_focusNodes[i]); // _focusNodes[i]);
} // }
if (formInputStatus == // if (formInputStatus ==
FormInputStatus.valid) { // FormInputStatus.valid) {
if (i + 1 < // if (i + 1 <
_focusNodes.length) { // _focusNodes.length) {
_focusNodes[i + 1] // _focusNodes[i + 1]
.requestFocus(); // .requestFocus();
} else if (i + 1 == // } else if (i + 1 ==
_focusNodes.length) { // _focusNodes.length) {
_focusNodes[i].unfocus(); // _focusNodes[i].unfocus();
} // }
} // }
}, },
controller: _controllers[i], controller: _controllers[i],
style: style:
@ -1068,7 +1068,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
AutovalidateMode.onUserInteraction, AutovalidateMode.onUserInteraction,
selectionControls: selectionControls:
i == 1 ? textSelectionControls : null, i == 1 ? textSelectionControls : null,
focusNode: _focusNodes[i - 1], // focusNode: _focusNodes[i - 1],
onChanged: (value) { onChanged: (value) {
final FormInputStatus formInputStatus; final FormInputStatus formInputStatus;
@ -1084,14 +1084,14 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
FormInputStatus.invalid; FormInputStatus.invalid;
} }
if (formInputStatus == // if (formInputStatus ==
FormInputStatus.valid) { // FormInputStatus.valid) {
if (i < _focusNodes.length) { // if (i < _focusNodes.length) {
_focusNodes[i].requestFocus(); // _focusNodes[i].requestFocus();
} else if (i == _focusNodes.length) { // } else if (i == _focusNodes.length) {
_focusNodes[i - 1].unfocus(); // _focusNodes[i - 1].unfocus();
} // }
} // }
setState(() { setState(() {
_inputStatuses[i - 1] = _inputStatuses[i - 1] =
formInputStatus; formInputStatus;