From b051acfb649da215a17ece98a624b3dbf12f45a1 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 24 Mar 2025 19:47:14 -0500 Subject: [PATCH] enter handling --- web/repertory/lib/screens/auth_screen.dart | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/web/repertory/lib/screens/auth_screen.dart b/web/repertory/lib/screens/auth_screen.dart index cad70f6e..986ebf04 100644 --- a/web/repertory/lib/screens/auth_screen.dart +++ b/web/repertory/lib/screens/auth_screen.dart @@ -38,6 +38,19 @@ class _AuthScreenState extends State { return SizedBox.shrink(); } + createLoginHandler() { + return _enabled + ? () async { + setState(() => _enabled = false); + await auth.authenticate( + _userController.text, + _passwordController.text, + ); + setState(() => _enabled = true); + } + : null; + } + return Center( child: Card( child: Padding( @@ -59,26 +72,26 @@ class _AuthScreenState extends State { autofocus: true, decoration: InputDecoration(labelText: 'Username'), controller: _userController, + textInputAction: TextInputAction.next, ), const SizedBox(height: constants.padding), TextField( obscureText: true, decoration: InputDecoration(labelText: 'Password'), controller: _passwordController, + textInputAction: TextInputAction.go, + onSubmitted: (_) { + final handler = createLoginHandler(); + if (handler == null) { + return; + } + + handler(); + }, ), const SizedBox(height: constants.padding), ElevatedButton( - onPressed: - _enabled - ? () async { - setState(() => _enabled = false); - await auth.authenticate( - _userController.text, - _passwordController.text, - ); - setState(() => _enabled = true); - } - : null, + onPressed: createLoginHandler(), child: const Text('Login'), ), ],