add autofill hints for source page

This commit is contained in:
Daniel Playfair Cal 2023-05-07 14:04:20 +10:00 committed by austinried
parent 8fbc5e6ce4
commit 56dbcde3b4

View File

@ -41,6 +41,7 @@ class SourcePage extends HookConsumerWidget {
label: l.settingsServersFieldsAddress, label: l.settingsServersFieldsAddress,
initialValue: source?.address.toString(), initialValue: source?.address.toString(),
keyboardType: TextInputType.url, keyboardType: TextInputType.url,
autofillHints: const [AutofillHints.url],
required: true, required: true,
validator: (value, label) { validator: (value, label) {
if (Uri.tryParse(value!) == null) { if (Uri.tryParse(value!) == null) {
@ -52,12 +53,14 @@ class SourcePage extends HookConsumerWidget {
final username = LabeledTextField( final username = LabeledTextField(
label: l.settingsServersFieldsUsername, label: l.settingsServersFieldsUsername,
initialValue: source?.username, initialValue: source?.username,
autofillHints: const [AutofillHints.username],
required: true, required: true,
); );
final password = LabeledTextField( final password = LabeledTextField(
label: l.settingsServersFieldsPassword, label: l.settingsServersFieldsPassword,
initialValue: source?.password, initialValue: source?.password,
obscureText: true, obscureText: true,
autofillHints: const [AutofillHints.password],
required: true, required: true,
); );
@ -175,6 +178,7 @@ class SourcePage extends HookConsumerWidget {
), ),
body: Form( body: Form(
key: form, key: form,
child: AutofillGroup(
child: ListView( child: ListView(
children: [ children: [
const SizedBox(height: 96 - kToolbarHeight), const SizedBox(height: 96 - kToolbarHeight),
@ -198,6 +202,7 @@ class SourcePage extends HookConsumerWidget {
), ),
), ),
), ),
),
); );
} }
} }
@ -208,6 +213,7 @@ class LabeledTextField extends HookConsumerWidget {
final bool obscureText; final bool obscureText;
final bool required; final bool required;
final TextInputType? keyboardType; final TextInputType? keyboardType;
final Iterable<String>? autofillHints;
final String? Function(String? value, String label)? validator; final String? Function(String? value, String label)? validator;
// ignore: prefer_const_constructors_in_immutables // ignore: prefer_const_constructors_in_immutables
@ -218,6 +224,7 @@ class LabeledTextField extends HookConsumerWidget {
this.obscureText = false, this.obscureText = false,
this.keyboardType, this.keyboardType,
this.validator, this.validator,
this.autofillHints,
this.required = false, this.required = false,
}); });
@ -249,6 +256,7 @@ class LabeledTextField extends HookConsumerWidget {
controller: _controller, controller: _controller,
obscureText: obscureText, obscureText: obscureText,
keyboardType: keyboardType, keyboardType: keyboardType,
autofillHints: autofillHints,
validator: (value) { validator: (value) {
String? error; String? error;