fix: Wrap login form into `AutofillGroup`

onboarding
Sorunome 4 years ago
parent c4d32b28a1
commit 72f00f33bc

@ -26,78 +26,80 @@ class LoginView extends StatelessWidget {
), ),
), ),
body: Builder(builder: (context) { body: Builder(builder: (context) {
return ListView( return AutofillGroup(
children: <Widget>[ child: ListView(
Padding( children: <Widget>[
padding: const EdgeInsets.all(12.0), Padding(
child: TextField( padding: const EdgeInsets.all(12.0),
readOnly: controller.loading, child: TextField(
autocorrect: false, readOnly: controller.loading,
autofocus: true, autocorrect: false,
onChanged: controller.checkWellKnownWithCoolDown, autofocus: true,
controller: controller.usernameController, onChanged: controller.checkWellKnownWithCoolDown,
autofillHints: controller: controller.usernameController,
controller.loading ? null : [AutofillHints.username], autofillHints:
decoration: InputDecoration( controller.loading ? null : [AutofillHints.username],
prefixIcon: Icon(Icons.account_box_outlined), decoration: InputDecoration(
hintText: L10n.of(context).username, prefixIcon: Icon(Icons.account_box_outlined),
errorText: controller.usernameError, hintText: L10n.of(context).username,
labelText: L10n.of(context).username), errorText: controller.usernameError,
labelText: L10n.of(context).username),
),
), ),
), Padding(
Padding( padding: const EdgeInsets.all(12.0),
padding: const EdgeInsets.all(12.0), child: TextField(
child: TextField( readOnly: controller.loading,
readOnly: controller.loading, autocorrect: false,
autocorrect: false, autofillHints:
autofillHints: controller.loading ? null : [AutofillHints.password],
controller.loading ? null : [AutofillHints.password], controller: controller.passwordController,
controller: controller.passwordController, obscureText: !controller.showPassword,
obscureText: !controller.showPassword, onSubmitted: controller.login,
onSubmitted: controller.login, decoration: InputDecoration(
decoration: InputDecoration( prefixIcon: Icon(Icons.lock_outlined),
prefixIcon: Icon(Icons.lock_outlined), hintText: '****',
hintText: '****', errorText: controller.passwordError,
errorText: controller.passwordError, suffixIcon: IconButton(
suffixIcon: IconButton( tooltip: L10n.of(context).showPassword,
tooltip: L10n.of(context).showPassword, icon: Icon(controller.showPassword
icon: Icon(controller.showPassword ? Icons.visibility_off_outlined
? Icons.visibility_off_outlined : Icons.visibility_outlined),
: Icons.visibility_outlined), onPressed: controller.toggleShowPassword,
onPressed: controller.toggleShowPassword, ),
labelText: L10n.of(context).password,
), ),
labelText: L10n.of(context).password,
), ),
), ),
), SizedBox(height: 12),
SizedBox(height: 12), Hero(
Hero( tag: 'loginButton',
tag: 'loginButton', child: Padding(
child: Padding( padding: EdgeInsets.symmetric(horizontal: 12),
padding: EdgeInsets.symmetric(horizontal: 12), child: ElevatedButton(
child: ElevatedButton( onPressed: controller.loading
onPressed: controller.loading ? null
? null : () => controller.login(context),
: () => controller.login(context), child: controller.loading
child: controller.loading ? LinearProgressIndicator()
? LinearProgressIndicator() : Text(L10n.of(context).login),
: Text(L10n.of(context).login), ),
), ),
), ),
), Center(
Center( child: TextButton(
child: TextButton( onPressed: controller.passwordForgotten,
onPressed: controller.passwordForgotten, child: Text(
child: Text( L10n.of(context).passwordForgotten,
L10n.of(context).passwordForgotten, style: TextStyle(
style: TextStyle( color: Colors.blue,
color: Colors.blue, decoration: TextDecoration.underline,
decoration: TextDecoration.underline, ),
), ),
), ),
), ),
), ],
], ),
); );
}), }),
), ),

Loading…
Cancel
Save