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,
|
validator: requiredValidator,
|
||||||
controller: password,
|
controller: password,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
|
onFieldSubmitted: (_) => tryLogin(),
|
||||||
|
// Don't defocus on submit
|
||||||
|
onEditingComplete: () {},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,22 @@ class VerifyPage extends HookConsumerWidget {
|
||||||
final inputError = useState<String?>(null);
|
final inputError = useState<String?>(null);
|
||||||
final formKey = useRef(GlobalKey<FormState>());
|
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(
|
return Scaffold(
|
||||||
appBar: Appbar(),
|
appBar: Appbar(),
|
||||||
body: AlertDialog(
|
body: AlertDialog(
|
||||||
|
|
@ -40,29 +56,16 @@ class VerifyPage extends HookConsumerWidget {
|
||||||
label: Text("Recovery Key or Passphrase"),
|
label: Text("Recovery Key or Passphrase"),
|
||||||
errorText: inputError.value,
|
errorText: inputError.value,
|
||||||
),
|
),
|
||||||
|
onFieldSubmitted: (_) => verify(),
|
||||||
|
// Don't defocus on submit
|
||||||
|
onEditingComplete: () {},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: isLoading.value
|
onPressed: isLoading.value ? null : verify,
|
||||||
? 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;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text("Verify"),
|
child: Text("Verify"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue