]> git.proxmox.com Git - flutter/proxmox_login_manager.git/commitdiff
add autofill group to login form
authorTim Marx <t.marx@proxmox.com>
Tue, 22 Sep 2020 12:10:03 +0000 (14:10 +0200)
committerTim Marx <t.marx@proxmox.com>
Tue, 22 Sep 2020 12:10:03 +0000 (14:10 +0200)
Signed-off-by: Tim Marx <t.marx@proxmox.com>
lib/proxmox_login_form.dart

index 888ba8f401707bce367fbd68203923ebd99a86a9..2a4f5011279944ca508aeb69ed11f5d3d6a4ae36 100644 (file)
@@ -66,81 +66,84 @@ class _ProxmoxLoginFormState extends State<ProxmoxLoginForm> {
       );
     }
 
-    return Column(
-      mainAxisAlignment: MainAxisAlignment.center,
-      children: [
-        TextFormField(
-          decoration: InputDecoration(
-            icon: Icon(Icons.vpn_lock),
-            labelText: 'Origin',
-          ),
-          controller: widget.originController,
-          enabled: false,
-        ),
-        TextFormField(
-          decoration: InputDecoration(
-            icon: Icon(Icons.person),
-            labelText: 'Username',
+    return AutofillGroup(
+      child: Column(
+        mainAxisAlignment: MainAxisAlignment.center,
+        children: [
+          TextFormField(
+            decoration: InputDecoration(
+              icon: Icon(Icons.vpn_lock),
+              labelText: 'Origin',
+            ),
+            controller: widget.originController,
+            enabled: false,
           ),
-          controller: widget.usernameController,
-          validator: (value) {
-            if (value.isEmpty) {
-              return 'Please enter username';
-            }
-            return null;
-          },
-          autofillHints: [AutofillHints.username],
-        ),
-        DropdownButtonFormField(
-          decoration: InputDecoration(icon: Icon(Icons.domain)),
-          items: widget.accessDomains
-              .map((e) => DropdownMenuItem(
-                    child: ListTile(
-                      title: Text(e.realm),
-                      subtitle: Text(e.comment ?? ''),
-                    ),
-                    value: e,
-                  ))
-              .toList(),
-          onChanged: widget.onDomainChanged,
-          selectedItemBuilder: (context) =>
-              widget.accessDomains.map((e) => Text(e.realm)).toList(),
-          value: widget.selectedDomain,
-        ),
-        Stack(
-          children: [
-            TextFormField(
-              decoration: InputDecoration(
-                icon: Icon(Icons.lock),
-                labelText: 'Password',
-              ),
-              controller: widget.passwordController,
-              obscureText: _obscure,
-              autocorrect: false,
-              focusNode: passwordFocusNode,
-              validator: (value) {
-                if (value.isEmpty) {
-                  return 'Please enter password';
-                }
-                return null;
-              },
-              onFieldSubmitted: (value) => widget.onPasswordSubmitted(),
-              autofillHints: [AutofillHints.password],
+          TextFormField(
+            decoration: InputDecoration(
+              icon: Icon(Icons.person),
+              labelText: 'Username',
             ),
-            Align(
-              alignment: Alignment.bottomRight,
-              child: IconButton(
-                constraints: BoxConstraints.tight(Size(58, 58)),
-                iconSize: 24,
-                icon: Icon(_obscure ? Icons.visibility : Icons.visibility_off),
-                onPressed: () => setState(() {
-                  _obscure = !_obscure;
-                }),
+            controller: widget.usernameController,
+            validator: (value) {
+              if (value.isEmpty) {
+                return 'Please enter username';
+              }
+              return null;
+            },
+            autofillHints: [AutofillHints.username],
+          ),
+          DropdownButtonFormField(
+            decoration: InputDecoration(icon: Icon(Icons.domain)),
+            items: widget.accessDomains
+                .map((e) => DropdownMenuItem(
+                      child: ListTile(
+                        title: Text(e.realm),
+                        subtitle: Text(e.comment ?? ''),
+                      ),
+                      value: e,
+                    ))
+                .toList(),
+            onChanged: widget.onDomainChanged,
+            selectedItemBuilder: (context) =>
+                widget.accessDomains.map((e) => Text(e.realm)).toList(),
+            value: widget.selectedDomain,
+          ),
+          Stack(
+            children: [
+              TextFormField(
+                decoration: InputDecoration(
+                  icon: Icon(Icons.lock),
+                  labelText: 'Password',
+                ),
+                controller: widget.passwordController,
+                obscureText: _obscure,
+                autocorrect: false,
+                focusNode: passwordFocusNode,
+                validator: (value) {
+                  if (value.isEmpty) {
+                    return 'Please enter password';
+                  }
+                  return null;
+                },
+                onFieldSubmitted: (value) => widget.onPasswordSubmitted(),
+                autofillHints: [AutofillHints.password],
               ),
-            )
-          ],
-        ),
-      ],
+              Align(
+                alignment: Alignment.bottomRight,
+                child: IconButton(
+                  constraints: BoxConstraints.tight(Size(58, 58)),
+                  iconSize: 24,
+                  icon:
+                      Icon(_obscure ? Icons.visibility : Icons.visibility_off),
+                  onPressed: () => setState(() {
+                    _obscure = !_obscure;
+                  }),
+                ),
+              )
+            ],
+          ),
+        ],
+      ),
     );
   }