Skip to content

Commit

Permalink
feat(flutterfire_ui): add autofillhints (#7668)
Browse files Browse the repository at this point in the history
* feat(flutterfire_ui): add autofillhints

* feat: change prop of PasswordInput to autofill with default value
  • Loading branch information
Lyokone committed Jan 31, 2022
1 parent 0c43bfc commit dd94e93
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/flutterfire_ui/lib/src/auth/widgets/email_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class _SignInFormContentState extends State<_SignInFormContent> {
widget.action == AuthAction.link) ...[
const SizedBox(height: 8),
PasswordInput(
autofillHints: const [AutofillHints.newPassword],
focusNode: confirmPasswordFocusNode,
controller: confirmPasswordCtrl,
onSubmit: _submit,
Expand Down Expand Up @@ -204,12 +205,14 @@ class _SignInFormContentState extends State<_SignInFormContent> {
),
];

return Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: children,
return AutofillGroup(
child: Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: children,
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class EmailInput extends StatelessWidget {
final l = FlutterFireUILocalizations.labelsOf(context);

return UniversalTextFormField(
autofillHints: const [AutofillHints.email],
autofocus: autofocus ?? false,
focusNode: focusNode,
controller: controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class UniversalTextFormField extends PlatformWidget {
final bool? enableSuggestions;
final bool? autocorrect;
final Widget? prefix;
final Iterable<String>? autofillHints;

const UniversalTextFormField({
Key? key,
Expand All @@ -31,6 +32,7 @@ class UniversalTextFormField extends PlatformWidget {
this.focusNode,
this.enableSuggestions,
this.autocorrect,
this.autofillHints,
}) : super(key: key);

@override
Expand All @@ -45,6 +47,7 @@ class UniversalTextFormField extends PlatformWidget {
),
),
child: CupertinoTextFormFieldRow(
autofillHints: autofillHints,
focusNode: focusNode,
padding: EdgeInsets.zero,
controller: controller,
Expand All @@ -63,6 +66,7 @@ class UniversalTextFormField extends PlatformWidget {
@override
Widget buildMaterial(BuildContext context) {
return TextFormField(
autofillHints: autofillHints,
autofocus: autofocus ?? false,
focusNode: focusNode,
controller: controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class PasswordInput extends StatelessWidget {
final void Function(String value) onSubmit;
final String label;
final String? Function(String? value)? validator;
final Iterable<String> autofillHints;

const PasswordInput({
Key? key,
required this.focusNode,
required this.controller,
required this.onSubmit,
required this.label,
this.autofillHints = const [AutofillHints.password],
this.validator,
}) : super(key: key);

Expand All @@ -25,6 +27,7 @@ class PasswordInput extends StatelessWidget {
final l = FlutterFireUILocalizations.labelsOf(context);

return UniversalTextFormField(
autofillHints: autofillHints,
focusNode: focusNode,
controller: controller,
obscureText: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/flutterfire_ui/lib/src/auth/widgets/phone_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ class PhoneInputState extends State<PhoneInput> {
SizedBox(
width: 90,
child: UniversalTextFormField(
autofillHints: const [
AutofillHints.telephoneNumberCountryCode
],
autofocus: false,
controller: countryController,
prefix: const Text('+'),
Expand All @@ -282,6 +285,7 @@ class PhoneInputState extends State<PhoneInput> {
const SizedBox(width: 8),
Expanded(
child: UniversalTextFormField(
autofillHints: const [AutofillHints.telephoneNumberNational],
autofocus: true,
focusNode: numberFocusNode,
controller: numberController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class SMSCodeInputState extends State<SMSCodeInput> {
child: Padding(
padding: const EdgeInsets.only(top: 30),
child: UniversalTextFormField(
autofillHints: const [AutofillHints.oneTimeCode],
autofocus: true,
focusNode: focusNode,
controller: controller,
Expand Down

0 comments on commit dd94e93

Please sign in to comment.