From 6081fd134feeddd45ddbe7f0d3181bbbe7b409a0 Mon Sep 17 00:00:00 2001 From: moon <56061215+MgKyawLay@users.noreply.github.com> Date: Wed, 22 Apr 2026 14:29:06 +0630 Subject: [PATCH] login loading --- .../auth/presentation/pages/login_page.dart | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/features/auth/presentation/pages/login_page.dart b/lib/features/auth/presentation/pages/login_page.dart index 7f73b8f..fcf815a 100644 --- a/lib/features/auth/presentation/pages/login_page.dart +++ b/lib/features/auth/presentation/pages/login_page.dart @@ -20,6 +20,7 @@ class _LoginPageState extends State { List? _availableBiometrics; String _authorized = "Not Authorized"; bool _isAuthenticating = false; + bool _isSigningIn = false; _SupportState _supportState = _SupportState.unknown; var _obscurePassword = true; @@ -43,10 +44,18 @@ class _LoginPageState extends State { super.dispose(); } - void _submit() { + Future _submit() async { final form = _formKey.currentState; if (form == null || !form.validate()) return; + setState(() { + _isSigningIn = true; + }); + + await Future.delayed(const Duration(seconds: 2)); + + if (!mounted) return; + Navigator.of(context).pushReplacement( MaterialPageRoute(builder: (_) => const MainShell()), ); @@ -245,7 +254,7 @@ class _LoginPageState extends State { SizedBox( width: double.infinity, child: FilledButton( - onPressed: _submit, + onPressed: _isSigningIn ? null : _submit, style: FilledButton.styleFrom( backgroundColor: colorScheme.primary, foregroundColor: Colors.white, @@ -254,13 +263,24 @@ class _LoginPageState extends State { borderRadius: BorderRadius.circular(18), ), ), - child: const Text( - 'Sign In', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), + child: _isSigningIn + ? const SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + strokeWidth: 2.4, + valueColor: AlwaysStoppedAnimation( + Colors.white, + ), + ), + ) + : const Text( + 'Sign In', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), ), ), ],