diff --git a/lib/app.dart b/lib/app.dart index 3bf1190..885675a 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -40,7 +40,7 @@ class _KMobileState extends State { void initState() { super.initState(); loadPreferences(); - Future.delayed(const Duration(seconds: 2), () { + Future.delayed(const Duration(seconds: 3), () { setState(() { showSplash = false; }); @@ -67,7 +67,6 @@ class _KMobileState extends State { @override Widget build(BuildContext context) { -// Set status bar color and brightness SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( statusBarColor: Colors.transparent, @@ -119,7 +118,6 @@ class AuthGate extends StatefulWidget { class _AuthGateState extends State { bool _checking = true; bool _isLoggedIn = false; - bool _showWelcome = true; bool _hasMPin = false; bool _biometricEnabled = false; bool _biometricTried = false; @@ -175,18 +173,7 @@ class _AuthGateState extends State { if (_checking) { return const SplashScreen(); } - // ✅ Step 1: Show welcome screen first, only once - if (_showWelcome) { - return WelcomeScreen( - onContinue: () { - setState(() { - _showWelcome = false; - }); - }, - ); - } - // ✅ Step 2: Check login status if (_isLoggedIn) { if (_hasMPin) { if (_biometricEnabled) { @@ -201,7 +188,6 @@ class _AuthGateState extends State { return const NavigationScaffold(); // Authenticated } - // ❌ Biometric failed → Show MPIN screen return MPinScreen( mode: MPinMode.enter, onCompleted: (_) { @@ -227,7 +213,6 @@ class _AuthGateState extends State { ); } } else { - // No MPIN set → show MPIN set screen + biometric dialog return MPinScreen( mode: MPinMode.set, onCompleted: (_) async { @@ -289,8 +274,6 @@ class _AuthGateState extends State { ); } } - - // ✅ Step 3: If not logged in, show login screen return const LoginScreen(); } } @@ -382,29 +365,6 @@ class _NavigationScaffoldState extends State { } } -class SplashScreen extends StatelessWidget { - const SplashScreen({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const CircularProgressIndicator(), - const SizedBox(height: 20), - Text( - AppLocalizations.of(context).loading, - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), - ), - ); - } -} - // Add this widget at the end of the file class BiometricPromptScreen extends StatelessWidget { final VoidCallback onCompleted; @@ -466,6 +426,9 @@ class BiometricPromptScreen extends StatelessWidget { ], ), ); + if (!context.mounted) { + return; + } if (result == true) { await _handleBiometric(context); } else {