Merge branch 'soru/autofill-hints' into 'main'

fix: Wrap login form into `AutofillGroup`

Closes #503

See merge request famedly/fluffychat!481
This commit is contained in:
Krille Fear 2021-08-09 08:46:50 +00:00
commit 5bb070b318

View File

@ -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: const EdgeInsets.all(12.0),
child: TextField(
readOnly: controller.loading,
autocorrect: false,
autofillHints:
controller.loading ? null : [AutofillHints.password],
controller: controller.passwordController,
obscureText: !controller.showPassword,
onSubmitted: controller.login,
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock_outlined),
hintText: '****',
errorText: controller.passwordError,
suffixIcon: IconButton(
tooltip: L10n.of(context).showPassword,
icon: Icon(controller.showPassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined),
onPressed: controller.toggleShowPassword,
),
labelText: L10n.of(context).password,
), ),
), ),
), Padding(
SizedBox(height: 12), padding: const EdgeInsets.all(12.0),
Hero( child: TextField(
tag: 'loginButton', readOnly: controller.loading,
child: Padding( autocorrect: false,
padding: EdgeInsets.symmetric(horizontal: 12), autofillHints:
child: ElevatedButton( controller.loading ? null : [AutofillHints.password],
onPressed: controller.loading controller: controller.passwordController,
? null obscureText: !controller.showPassword,
: () => controller.login(context), onSubmitted: controller.login,
child: controller.loading decoration: InputDecoration(
? LinearProgressIndicator() prefixIcon: Icon(Icons.lock_outlined),
: Text(L10n.of(context).login), hintText: '****',
), errorText: controller.passwordError,
), suffixIcon: IconButton(
), tooltip: L10n.of(context).showPassword,
Center( icon: Icon(controller.showPassword
child: TextButton( ? Icons.visibility_off_outlined
onPressed: controller.passwordForgotten, : Icons.visibility_outlined),
child: Text( onPressed: controller.toggleShowPassword,
L10n.of(context).passwordForgotten, ),
style: TextStyle( labelText: L10n.of(context).password,
color: Colors.blue,
decoration: TextDecoration.underline,
), ),
), ),
), ),
), SizedBox(height: 12),
], Hero(
tag: 'loginButton',
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: ElevatedButton(
onPressed: controller.loading
? null
: () => controller.login(context),
child: controller.loading
? LinearProgressIndicator()
: Text(L10n.of(context).login),
),
),
),
Center(
child: TextButton(
onPressed: controller.passwordForgotten,
child: Text(
L10n.of(context).passwordForgotten,
style: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
),
),
),
],
),
); );
}), }),
), ),