Add autofillgroup

This commit is contained in:
shilangyu 2021-04-11 20:52:11 +02:00
parent 68cd03e71c
commit 3011890831
1 changed files with 85 additions and 79 deletions

View File

@ -67,91 +67,97 @@ class AddAccountPage extends HookWidget {
leading: const CloseButton(), leading: const CloseButton(),
title: const Text('Add account'), title: const Text('Add account'),
), ),
body: ListView( body: AutofillGroup(
padding: const EdgeInsets.all(15), child: ListView(
children: [ padding: const EdgeInsets.all(15),
if (icon.value == null) children: [
const SizedBox(height: 150) if (icon.value == null)
else const SizedBox(height: 150)
SizedBox( else
height: 150, SizedBox(
child: FullscreenableImage( height: 150,
url: icon.value!, child: FullscreenableImage(
child: CachedNetworkImage( url: icon.value!,
imageUrl: icon.value!, child: CachedNetworkImage(
errorWidget: (_, __, ___) => const SizedBox.shrink(), imageUrl: icon.value!,
errorWidget: (_, __, ___) => const SizedBox.shrink(),
),
), ),
), ),
), RadioPicker<String>(
RadioPicker<String>( title: 'select instance',
title: 'select instance', values: accountsStore.instances.toList(),
values: accountsStore.instances.toList(), groupValue: selectedInstance.value,
groupValue: selectedInstance.value, onChanged: (value) => selectedInstance.value = value,
onChanged: (value) => selectedInstance.value = value, buttonBuilder: (context, displayValue, onPressed) => TextButton(
buttonBuilder: (context, displayValue, onPressed) => TextButton( onPressed: onPressed,
onPressed: onPressed, child: Row(
child: Row( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(displayValue),
Text(displayValue), const Icon(Icons.arrow_drop_down),
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<String>(
context: context,
builder: (context) => const AddInstancePage(),
);
Navigator.of(context).pop(value);
},
), ),
), ),
trailing: ListTile( TextField(
leading: const Padding( autofocus: true,
padding: EdgeInsets.all(8), controller: usernameController,
child: Icon(Icons.add), autofillHints: const [
), AutofillHints.email,
title: const Text('Add instance'), AutofillHints.username
onTap: () async { ],
final value = await showCupertinoModalPopup<String>( onSubmitted: (_) => passwordFocusNode.requestFocus(),
context: context, decoration: InputDecoration(
builder: (context) => const AddInstancePage(), labelText: L10n.of(context)!.email_or_username),
);
Navigator.of(context).pop(value);
},
), ),
), const SizedBox(height: 5),
TextField( TextField(
autofocus: true, controller: passwordController,
controller: usernameController, obscureText: true,
autofillHints: const [AutofillHints.email, AutofillHints.username], focusNode: passwordFocusNode,
onSubmitted: (_) => passwordFocusNode.requestFocus(), onSubmitted: (_) => handleSubmit?.call(),
decoration: autofillHints: const [AutofillHints.password],
InputDecoration(labelText: L10n.of(context)!.email_or_username), keyboardType: TextInputType.visiblePassword,
), decoration:
const SizedBox(height: 5), InputDecoration(labelText: L10n.of(context)!.password),
TextField( ),
controller: passwordController, ElevatedButton(
obscureText: true, onPressed: handleSubmit,
focusNode: passwordFocusNode, child: !loading.loading
onSubmitted: (_) => handleSubmit?.call(), ? const Text('Sign in')
autofillHints: const [AutofillHints.password], : SizedBox(
keyboardType: TextInputType.visiblePassword, width: 20,
decoration: InputDecoration(labelText: L10n.of(context)!.password), height: 20,
), child: CircularProgressIndicator(
ElevatedButton( valueColor:
onPressed: handleSubmit, AlwaysStoppedAnimation<Color>(theme.canvasColor),
child: !loading.loading ),
? const Text('Sign in')
: SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation<Color>(theme.canvasColor),
), ),
), ),
), TextButton(
TextButton( onPressed: () {
onPressed: () { // TODO: extract to LemmyUrls or something
// TODO: extract to LemmyUrls or something ul.launch('https://${selectedInstance.value}/login');
ul.launch('https://${selectedInstance.value}/login'); },
}, child: const Text('Register'),
child: const Text('Register'), ),
), ],
], ),
), ),
); );
} }