From a236a73844b94a8521e33ac0d62b03187c9cb1f9 Mon Sep 17 00:00:00 2001 From: ChandruBtechCSE Date: Wed, 15 Jul 2026 23:00:33 +0530 Subject: [PATCH] fixed and optimized the login screen issues --- mobile/lib/main.dart | 14 +- mobile/lib/pages/login_page.dart | 238 ++++++++++++------------------- 2 files changed, 101 insertions(+), 151 deletions(-) diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index ab0fb74..0258584 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -12,14 +12,13 @@ import 'pages/home_page.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - await Env.init(); - await AuthService().initTokens(); + await Future.wait([Env.init(), AuthService().initTokens()]); final themeProvider = ThemeProvider(); - while (!themeProvider.isInitialized) { - await Future.delayed(const Duration(milliseconds: 10)); - } + // while (!themeProvider.isInitialized) { + // await Future.delayed(const Duration(milliseconds: 10)); + // } runApp( MultiProvider( @@ -70,7 +69,9 @@ class _SessionGatewayState extends State { final auth = context.read(); final token = await auth.checkAutoLogin(); - if (token != null && mounted) { + if (!mounted) return; + + if (token != null) { _lastInitializedToken = token; context.read().initSession(); } @@ -90,6 +91,7 @@ class _SessionGatewayState extends State { body: Center( child: CircularProgressIndicator( color: Theme.of(context).colorScheme.primary, + strokeWidth: 3, ), ), ); diff --git a/mobile/lib/pages/login_page.dart b/mobile/lib/pages/login_page.dart index f9620bb..60f7cb8 100644 --- a/mobile/lib/pages/login_page.dart +++ b/mobile/lib/pages/login_page.dart @@ -363,7 +363,6 @@ class _LoginPageState extends State end: const Offset(1.6, 1.6), ), ), - ], ), ), @@ -379,7 +378,7 @@ class _LoginPageState extends State child: ClipRRect( borderRadius: BorderRadiusGeometry.circular(24), child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 25, sigmaY: 25), + filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15), child: Container( decoration: BoxDecoration( gradient: LinearGradient( @@ -417,89 +416,59 @@ class _LoginPageState extends State crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - Icons.chat_bubble_rounded, - color: Color(0xFF0052CC), - size: 28, - ), - const SizedBox(width: 8), - Text( - 'Elephant', - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, - color: Theme.of( - context, - ).colorScheme.primary, - letterSpacing: 0.5, - ), - ), - ], - ) - .animate( - onPlay: (controller) => - controller.repeat(period: 4.seconds), - ) - .shimmer( - duration: 1.5.seconds, - color: theme.colorScheme.onSurface - .withValues(alpha: 0.5), + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.chat_bubble_rounded, + color: Color(0xFF0052CC), + size: 28, + ), + const SizedBox(width: 8), + Text( + 'Elephant', + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Theme.of( + context, + ).colorScheme.primary, + letterSpacing: 0.5, + ), ), + ], + ), const SizedBox(height: 24), - AnimatedSwitcher( - duration: const Duration(milliseconds: 400), - switchInCurve: Curves.easeOutCirc, - switchOutCurve: Curves.easeInCirc, - transitionBuilder: - ( - Widget child, - Animation animation, - ) { - return FadeTransition( - opacity: animation, - child: SlideTransition( - position: Tween( - begin: const Offset(0.0, 0.2), - end: Offset.zero, - ).animate(animation), - child: child, - ), - ); - }, - child: Column( - key: ValueKey(_tabController.index), - children: [ - Text( - _tabController.index == 0 - ? 'Welcome Back' - : 'Create Account', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - color: Theme.of( - context, - ).colorScheme.onSurface, - ), + Column( + key: ValueKey(_tabController.index), + children: [ + Text( + _tabController.index == 0 + ? 'Welcome Back' + : 'Create Account', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + color: Theme.of( + context, + ).colorScheme.onSurface, ), - const SizedBox(height: 6), - Text( - _tabController.index == 0 - ? 'Access your secure workspace' - : 'Join the peer mesh platform', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - color: Theme.of( - context, - ).colorScheme.onSurfaceVariant, - ), + ), + const SizedBox(height: 6), + Text( + _tabController.index == 0 + ? 'Access your secure workspace' + : 'Join the peer mesh platform', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + color: Theme.of( + context, + ).colorScheme.onSurfaceVariant, ), - ], - ), + ), + ], ), const SizedBox(height: 28), @@ -648,6 +617,7 @@ class _LoginPageState extends State ), const SizedBox(height: 6), TextFormField( + textInputAction: TextInputAction.next, controller: _usernameController, style: TextStyle( color: Theme.of( @@ -706,6 +676,8 @@ class _LoginPageState extends State ), const SizedBox(height: 6), TextFormField( + textInputAction: + TextInputAction.next, controller: _displayNameController, style: TextStyle( @@ -800,6 +772,8 @@ class _LoginPageState extends State const SizedBox(height: 6), TextFormField( controller: _passwordController, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) => _submit(), obscureText: true, style: TextStyle( color: Theme.of( @@ -838,72 +812,46 @@ class _LoginPageState extends State const SizedBox(height: 24), ElevatedButton( - onPressed: authState.isLoading - ? null - : _submit, - style: ElevatedButton.styleFrom( - backgroundColor: Theme.of( - context, - ).colorScheme.primary, - foregroundColor: Theme.of( - context, - ).colorScheme.onPrimary, - padding: const EdgeInsets.symmetric( - vertical: 14, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - elevation: 0, - ), - child: authState.isLoading - ? SizedBox( - height: 20, - width: 20, - child: CircularProgressIndicator( - color: Theme.of( - context, - ).colorScheme.onPrimary, - strokeWidth: 2.5, - ), - ) - : AnimatedSwitcher( - duration: const Duration( - milliseconds: 300, - ), - transitionBuilder: - (child, animation) => - FadeTransition( - opacity: animation, - child: ScaleTransition( - scale: animation, - child: child, - ), - ), - child: Text( - _tabController.index == 0 - ? 'Sign In' - : 'Sign Up', - key: ValueKey( - _tabController.index, - ), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - ), - ) - .animate( - onPlay: (controller) => - controller.repeat(reverse: true), - ) - .scale( - begin: const Offset(1, 1), - end: const Offset(1.02, 1.02), - duration: 2.seconds, - curve: Curves.easeInOutSine, + onPressed: authState.isLoading ? null : _submit, + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of( + context, + ).colorScheme.primary, + foregroundColor: Theme.of( + context, + ).colorScheme.onPrimary, + padding: const EdgeInsets.symmetric( + vertical: 14, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), ), + elevation: 0, + ), + child: authState.isLoading + ? SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + color: Theme.of( + context, + ).colorScheme.onPrimary, + strokeWidth: 2.5, + ), + ) + : Text( + _tabController.index == 0 + ? 'Sign In' + : 'Sign Up', + key: ValueKey( + _tabController.index, + ), + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + ), + ), + ), const SizedBox(height: 24), Row(