fix keyboard navigation of forms
Including submit with keyboard, and not defocusing on submit of a form
This commit is contained in:
parent
c10c74a1f3
commit
22aa26fd05
2 changed files with 23 additions and 17 deletions
|
|
@ -80,6 +80,9 @@ class LoginPage extends HookConsumerWidget {
|
|||
validator: requiredValidator,
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
onFieldSubmitted: (_) => tryLogin(),
|
||||
// Don't defocus on submit
|
||||
onEditingComplete: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,22 @@ class VerifyPage extends HookConsumerWidget {
|
|||
final inputError = useState<String?>(null);
|
||||
final formKey = useRef(GlobalKey<FormState>());
|
||||
|
||||
Future<void> verify() async {
|
||||
isLoading.value = true;
|
||||
|
||||
try {
|
||||
if (formKey.value.currentState?.validate() != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
inputError.value = await ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.verify(passphraseController.text);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: Appbar(),
|
||||
body: AlertDialog(
|
||||
|
|
@ -40,29 +56,16 @@ class VerifyPage extends HookConsumerWidget {
|
|||
label: Text("Recovery Key or Passphrase"),
|
||||
errorText: inputError.value,
|
||||
),
|
||||
onFieldSubmitted: (_) => verify(),
|
||||
// Don't defocus on submit
|
||||
onEditingComplete: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: isLoading.value
|
||||
? null
|
||||
: () async {
|
||||
isLoading.value = true;
|
||||
|
||||
try {
|
||||
if (formKey.value.currentState?.validate() != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
inputError.value = await ref
|
||||
.watch(ClientController.provider.notifier)
|
||||
.verify(passphraseController.text);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
},
|
||||
onPressed: isLoading.value ? null : verify,
|
||||
child: Text("Verify"),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue