enter handling
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...

This commit is contained in:
Scott E. Graves 2025-03-24 19:47:14 -05:00
parent a079192e87
commit b051acfb64

View File

@ -38,6 +38,19 @@ class _AuthScreenState extends State<AuthScreen> {
return SizedBox.shrink(); return SizedBox.shrink();
} }
createLoginHandler() {
return _enabled
? () async {
setState(() => _enabled = false);
await auth.authenticate(
_userController.text,
_passwordController.text,
);
setState(() => _enabled = true);
}
: null;
}
return Center( return Center(
child: Card( child: Card(
child: Padding( child: Padding(
@ -59,26 +72,26 @@ class _AuthScreenState extends State<AuthScreen> {
autofocus: true, autofocus: true,
decoration: InputDecoration(labelText: 'Username'), decoration: InputDecoration(labelText: 'Username'),
controller: _userController, controller: _userController,
textInputAction: TextInputAction.next,
), ),
const SizedBox(height: constants.padding), const SizedBox(height: constants.padding),
TextField( TextField(
obscureText: true, obscureText: true,
decoration: InputDecoration(labelText: 'Password'), decoration: InputDecoration(labelText: 'Password'),
controller: _passwordController, controller: _passwordController,
textInputAction: TextInputAction.go,
onSubmitted: (_) {
final handler = createLoginHandler();
if (handler == null) {
return;
}
handler();
},
), ),
const SizedBox(height: constants.padding), const SizedBox(height: constants.padding),
ElevatedButton( ElevatedButton(
onPressed: onPressed: createLoginHandler(),
_enabled
? () async {
setState(() => _enabled = false);
await auth.authenticate(
_userController.text,
_passwordController.text,
);
setState(() => _enabled = true);
}
: null,
child: const Text('Login'), child: const Text('Login'),
), ),
], ],