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(),
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<String>(
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<String>(
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<String>(
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<String>(
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<Color>(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<Color>(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'),
),
],
),
),
);
}