From 30118908318796ccaf60389811d775c24354cfc8 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Sun, 11 Apr 2021 20:52:11 +0200 Subject: [PATCH] Add autofillgroup --- lib/pages/add_account.dart | 164 +++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 79 deletions(-) diff --git a/lib/pages/add_account.dart b/lib/pages/add_account.dart index 83039a7..e0af64c 100644 --- a/lib/pages/add_account.dart +++ b/lib/pages/add_account.dart @@ -67,91 +67,97 @@ class AddAccountPage extends HookWidget { leading: const CloseButton(), title: const Text('Add account'), ), - body: ListView( - padding: const EdgeInsets.all(15), - children: [ - if (icon.value == null) - const SizedBox(height: 150) - else - SizedBox( - height: 150, - child: FullscreenableImage( - url: icon.value!, - child: CachedNetworkImage( - imageUrl: icon.value!, - errorWidget: (_, __, ___) => const SizedBox.shrink(), + body: AutofillGroup( + child: ListView( + padding: const EdgeInsets.all(15), + children: [ + if (icon.value == null) + const SizedBox(height: 150) + else + SizedBox( + height: 150, + child: FullscreenableImage( + url: icon.value!, + child: CachedNetworkImage( + imageUrl: icon.value!, + errorWidget: (_, __, ___) => const SizedBox.shrink(), + ), ), ), - ), - RadioPicker( - title: 'select instance', - values: accountsStore.instances.toList(), - groupValue: selectedInstance.value, - onChanged: (value) => selectedInstance.value = value, - buttonBuilder: (context, displayValue, onPressed) => TextButton( - onPressed: onPressed, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(displayValue), - const Icon(Icons.arrow_drop_down), - ], + RadioPicker( + title: 'select instance', + values: accountsStore.instances.toList(), + groupValue: selectedInstance.value, + onChanged: (value) => selectedInstance.value = value, + buttonBuilder: (context, displayValue, onPressed) => TextButton( + onPressed: onPressed, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(displayValue), + const Icon(Icons.arrow_drop_down), + ], + ), + ), + trailing: ListTile( + leading: const Padding( + padding: EdgeInsets.all(8), + child: Icon(Icons.add), + ), + title: const Text('Add instance'), + onTap: () async { + final value = await showCupertinoModalPopup( + context: context, + builder: (context) => const AddInstancePage(), + ); + Navigator.of(context).pop(value); + }, ), ), - trailing: ListTile( - leading: const Padding( - padding: EdgeInsets.all(8), - child: Icon(Icons.add), - ), - title: const Text('Add instance'), - onTap: () async { - final value = await showCupertinoModalPopup( - context: context, - builder: (context) => const AddInstancePage(), - ); - Navigator.of(context).pop(value); - }, + TextField( + autofocus: true, + controller: usernameController, + autofillHints: const [ + AutofillHints.email, + AutofillHints.username + ], + onSubmitted: (_) => passwordFocusNode.requestFocus(), + decoration: InputDecoration( + labelText: L10n.of(context)!.email_or_username), ), - ), - TextField( - autofocus: true, - controller: usernameController, - autofillHints: const [AutofillHints.email, AutofillHints.username], - onSubmitted: (_) => passwordFocusNode.requestFocus(), - decoration: - InputDecoration(labelText: L10n.of(context)!.email_or_username), - ), - const SizedBox(height: 5), - TextField( - controller: passwordController, - obscureText: true, - focusNode: passwordFocusNode, - onSubmitted: (_) => handleSubmit?.call(), - autofillHints: const [AutofillHints.password], - keyboardType: TextInputType.visiblePassword, - decoration: InputDecoration(labelText: L10n.of(context)!.password), - ), - ElevatedButton( - onPressed: handleSubmit, - child: !loading.loading - ? const Text('Sign in') - : SizedBox( - width: 20, - height: 20, - child: CircularProgressIndicator( - valueColor: - AlwaysStoppedAnimation(theme.canvasColor), + const SizedBox(height: 5), + TextField( + controller: passwordController, + obscureText: true, + focusNode: passwordFocusNode, + onSubmitted: (_) => handleSubmit?.call(), + autofillHints: const [AutofillHints.password], + keyboardType: TextInputType.visiblePassword, + decoration: + InputDecoration(labelText: L10n.of(context)!.password), + ), + ElevatedButton( + onPressed: handleSubmit, + child: !loading.loading + ? const Text('Sign in') + : SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + valueColor: + AlwaysStoppedAnimation(theme.canvasColor), + ), ), - ), - ), - TextButton( - onPressed: () { - // TODO: extract to LemmyUrls or something - ul.launch('https://${selectedInstance.value}/login'); - }, - child: const Text('Register'), - ), - ], + ), + TextButton( + onPressed: () { + // TODO: extract to LemmyUrls or something + ul.launch('https://${selectedInstance.value}/login'); + }, + child: const Text('Register'), + ), + ], + ), ), ); }