From 9139a65003d758b4ee52758149b178d8dc990e0e Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Mon, 22 May 2023 09:45:40 -0600 Subject: Arreglos al flujo de autenticación MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 25 ++++++++++++------------- lib/screens/dashboard_screen.dart | 7 ++++++- lib/screens/login_screen.dart | 6 +++--- lib/screens/register_screen.dart | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8baaa61..97a8fb4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -52,19 +52,18 @@ class LinkChat extends StatelessWidget { final ThemeProvider provider = context.watch(); final ThemeData? theme = provider.theme; provider.syncFromPrefs(); - return MaterialApp( - theme: theme ?? ThemeSettings.lightTheme, - darkTheme: theme ?? ThemeSettings.darkTheme, - themeMode: ThemeMode.system, - routes: getApplicationRoutes(), - // initialRoute: '/login', - home: StreamBuilder( - stream: _auth.userChanges, - builder: (context, snapshot) { - return (snapshot.hasData && !snapshot.data!.isAnonymous) + return StreamBuilder( + stream: _auth.userChanges, + builder: (context, snapshot) { + return MaterialApp( + theme: theme ?? ThemeSettings.lightTheme, + darkTheme: theme ?? ThemeSettings.darkTheme, + themeMode: ThemeMode.system, + routes: getApplicationRoutes(), + home: (snapshot.hasData && !snapshot.data!.isAnonymous) ? const DashboardScreen() - : const LoginScreen(); - }, - )); + : const LoginScreen(), + ); + }); } } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 778c2bb..88bd8e7 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -93,10 +93,15 @@ class _DashboardScreenState extends State { } void signOut(BuildContext context) { - _auth.signOut().then((success) { + /*_auth.signOut().then((success) { if (success) { Navigator.of(context).popUntil(ModalRoute.withName('/login')); } + });*/ + _auth.signOut().then((success) { + if (success) { + Navigator.of(context).pushReplacementNamed('/login'); + } }); } } diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index 44cef6f..f00328b 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -117,7 +117,7 @@ class _LoginScreenState extends State isLoading = false; }); // TODO: checar si el resultado es true - Navigator.of(context).pushNamed('/dash'); + Navigator.of(context).pushReplacementNamed('/dash'); }); } @@ -127,7 +127,7 @@ class _LoginScreenState extends State isLoading = false; }); if (success) { - Navigator.of(context).pushNamed('/dash'); + Navigator.of(context).pushReplacementNamed('/dash'); } }); } @@ -138,7 +138,7 @@ class _LoginScreenState extends State isLoading = false; }); if (success) { - Navigator.of(context).pushNamed('/dash'); + Navigator.of(context).pushReplacementNamed('/dash'); } }); } diff --git a/lib/screens/register_screen.dart b/lib/screens/register_screen.dart index 349cac0..9a11923 100644 --- a/lib/screens/register_screen.dart +++ b/lib/screens/register_screen.dart @@ -169,7 +169,7 @@ class _RegisterScreenState extends State { ) .then((success) { if (success) { - Navigator.of(context).pushNamed('/onboard'); + Navigator.of(context).pushReplacementNamed('/onboard'); } }); } -- cgit v1.2.3