make login form autofillable (#2048)
Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
This commit is contained in:
parent
b8e7eca69c
commit
8f50bfd4bc
2 changed files with 39 additions and 26 deletions
|
|
@ -19,32 +19,39 @@ class PangeaLoginView extends StatelessWidget {
|
|||
key: controller.formKey,
|
||||
child: PangeaLoginScaffold(
|
||||
children: [
|
||||
FullWidthTextField(
|
||||
hintText: L10n.of(context).username,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return L10n.of(context).pleaseEnterYourUsername;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: controller.usernameController,
|
||||
),
|
||||
FullWidthTextField(
|
||||
hintText: L10n.of(context).password,
|
||||
obscureText: true,
|
||||
textInputAction: TextInputAction.go,
|
||||
onSubmitted: (_) {
|
||||
controller.enabledSignIn ? controller.login() : null;
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return L10n.of(context).pleaseEnterYourPassword;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: controller.passwordController,
|
||||
),
|
||||
AutofillGroup(
|
||||
child: Column(children: [
|
||||
FullWidthTextField(
|
||||
hintText: L10n.of(context).username,
|
||||
autofillHints: const [AutofillHints.username],
|
||||
autoFocus: true,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return L10n.of(context).pleaseEnterYourUsername;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: controller.usernameController,
|
||||
),
|
||||
FullWidthTextField(
|
||||
hintText: L10n.of(context).password,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
autoFocus: true,
|
||||
obscureText: true,
|
||||
textInputAction: TextInputAction.go,
|
||||
onSubmitted: (_) {
|
||||
controller.enabledSignIn ? controller.login() : null;
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return L10n.of(context).pleaseEnterYourPassword;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: controller.passwordController,
|
||||
),
|
||||
])),
|
||||
FullWidthButton(
|
||||
title: L10n.of(context).signIn,
|
||||
icon: PangeaLogoSvg(
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ class FullWidthTextField extends StatelessWidget {
|
|||
final String? errorText;
|
||||
final Function(String)? onSubmitted;
|
||||
final String? labelText;
|
||||
final List<String>? autofillHints;
|
||||
final bool autoFocus;
|
||||
|
||||
const FullWidthTextField({
|
||||
required this.hintText,
|
||||
|
|
@ -135,6 +137,8 @@ class FullWidthTextField extends StatelessWidget {
|
|||
this.showErrorText,
|
||||
this.onSubmitted,
|
||||
this.labelText,
|
||||
this.autofillHints,
|
||||
this.autoFocus = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -149,6 +153,8 @@ class FullWidthTextField extends StatelessWidget {
|
|||
autocorrect: autocorrect,
|
||||
textInputAction: textInputAction,
|
||||
keyboardType: keyboardType,
|
||||
autofillHints: autofillHints,
|
||||
autofocus: autoFocus,
|
||||
decoration: InputDecoration(
|
||||
labelText: labelText,
|
||||
hintText: hintText,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue