Fix password auto-fill suggestion

This commit is contained in:
Neeraj Gupta 2022-07-14 18:58:37 +05:30
parent 3b9d4d3643
commit e33cc392b7
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 249 additions and 227 deletions

View file

@ -70,6 +70,7 @@ class _LoginPageState extends State<LoginPage> {
return Column(
children: [
Expanded(
child: AutofillGroup(
child: ListView(
children: [
Padding(
@ -202,6 +203,7 @@ class _LoginPageState extends State<LoginPage> {
],
),
),
),
const Padding(padding: EdgeInsets.all(8)),
],
);

View file

@ -18,12 +18,14 @@ class PasswordReentryPage extends StatefulWidget {
class _PasswordReentryPageState extends State<PasswordReentryPage> {
final _passwordController = TextEditingController();
final FocusNode _passwordFocusNode = FocusNode();
String email;
bool _passwordInFocus = false;
bool _passwordVisible = false;
@override
void initState() {
super.initState();
email = Configuration.instance.getEmail();
_passwordFocusNode.addListener(() {
setState(() {
_passwordInFocus = _passwordFocusNode.hasFocus;
@ -96,6 +98,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
return Column(
children: [
Expanded(
child: AutofillGroup(
child: ListView(
children: [
Padding(
@ -106,6 +109,20 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
style: Theme.of(context).textTheme.headline4,
),
),
Visibility(
// hidden textForm for suggesting auto-fill service for saving
// password
visible: false,
child: TextFormField(
autofillHints: const [
AutofillHints.email,
],
autocorrect: false,
keyboardType: TextInputType.emailAddress,
initialValue: email,
textInputAction: TextInputAction.next,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
child: TextFormField(
@ -174,7 +191,8 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
child: Center(
child: Text(
"Forgot password",
style: Theme.of(context).textTheme.subtitle1.copyWith(
style:
Theme.of(context).textTheme.subtitle1.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
@ -195,7 +213,8 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
child: Center(
child: Text(
"Change email",
style: Theme.of(context).textTheme.subtitle1.copyWith(
style:
Theme.of(context).textTheme.subtitle1.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
@ -208,6 +227,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
],
),
),
),
],
);
}