From f4fb846855bee483f304d485c84808d0baec6c0c Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 2 Sep 2025 14:25:19 +0200 Subject: [PATCH] fix login --- covas_mobile_new/lib/main.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/covas_mobile_new/lib/main.dart b/covas_mobile_new/lib/main.dart index af9c6ed..682e45c 100644 --- a/covas_mobile_new/lib/main.dart +++ b/covas_mobile_new/lib/main.dart @@ -6,21 +6,28 @@ import 'pages/LoginDemo.dart'; import 'locale_provider.dart'; // <-- à adapter selon ton arborescence import 'package:covas_mobile/gen_l10n/app_localizations.dart'; import 'classes/notification_service.dart'; +import 'classes/auth_service.dart'; +import 'pages/ListItemMenu.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await MobileAds.instance.initialize(); await NotificationService.initialize(); + final AuthService _authService = AuthService(); + + final loggedIn = await _authService.isLoggedIn(); runApp( ChangeNotifierProvider( create: (_) => LocaleProvider(), - child: MyApp(), + child: MyApp(isLoggedIn: loggedIn), ), ); } class MyApp extends StatelessWidget { + final bool isLoggedIn; + const MyApp({Key? key, required this.isLoggedIn}) : super(key: key); @override Widget build(BuildContext context) { final localeProvider = Provider.of( @@ -30,7 +37,7 @@ class MyApp extends StatelessWidget { locale: localeProvider.locale, // <-- utilise la locale courante supportedLocales: L10n.all, localizationsDelegates: AppLocalizations.localizationsDelegates, - home: LoginDemo(), + home: isLoggedIn ? ListItemMenu() : LoginDemo(), ); } }