diff --git a/app-release.apk b/app-release.apk new file mode 100644 index 0000000..b668bc7 Binary files /dev/null and b/app-release.apk differ diff --git a/lib/auth_screen.dart b/lib/auth_screen.dart index 39c48b3..1e9cc7e 100644 --- a/lib/auth_screen.dart +++ b/lib/auth_screen.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; +import 'package:provider/provider.dart'; import 'package:login_vault_app/auth_service.dart'; +import 'package:login_vault_app/dashboard_screen.dart'; +import 'package:login_vault_app/theme_provider.dart'; /// First-launch screen: register with email+password, or with Google. class AuthScreen extends StatefulWidget { @@ -18,6 +21,19 @@ class _AuthScreenState extends State { bool _busy = false; String? _error; + void _goToDashboard(String email) { + if (!mounted) return; + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (_) => DashboardScreen( + auth: widget.auth, + theme: Provider.of(context, listen: false), + email: email, + ), + ), + ); + } + Future _submitEmail() async { setState(() => _busy = true); final email = _emailCtrl.text.trim(); @@ -36,12 +52,11 @@ class _AuthScreenState extends State { } else if (!ok) { setState(() => _error = 'Password aplikasi salah'); } else { - // success -> pop true - if (mounted) Navigator.pop(context, true); + _goToDashboard(email); } } else { await widget.auth.registerWithEmail(email, pass); - if (mounted) Navigator.pop(context, true); + _goToDashboard(email); } } catch (e) { setState(() => _error = e.toString()); @@ -57,7 +72,7 @@ class _AuthScreenState extends State { final account = await gs.signIn(); if (account?.email != null) { await widget.auth.registerWithGoogle(account!.email); - if (mounted) Navigator.pop(context, true); + _goToDashboard(account.email); } else { setState(() => _error = 'Google sign-in dibatalkan'); } diff --git a/lib/main.dart b/lib/main.dart index 78b4bfa..c069d04 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,6 +30,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { final theme = Provider.of(context); + final auth = Provider.of(context, listen: false); return MaterialApp( title: 'Login Vault', theme: ThemeData( @@ -43,13 +44,10 @@ class MyApp extends StatelessWidget { colorSchemeSeed: Colors.indigo, ), themeMode: theme.mode, - home: registered - ? DashboardScreen( - auth: context.read(), - theme: theme, - email: email, - ) - : AuthScreen(auth: context.read()), + // decide home: if registered AND email known -> Dashboard, else Auth. + home: (registered && email.isNotEmpty) + ? DashboardScreen(auth: auth, theme: theme, email: email) + : AuthScreen(auth: auth), debugShowCheckedModeBanner: false, ); }