133 lines
4.3 KiB
Dart
133 lines
4.3 KiB
Dart
/// UnionFlow - Application Mobile Révolutionnaire
|
|
///
|
|
/// Point d'entrée principal avec système d'authentification adaptatif
|
|
/// Architecture ultra-sophistiquée avec dashboard morphique basé sur les rôles
|
|
library main;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
import 'core/design_system/theme/app_theme_sophisticated.dart';
|
|
import 'core/auth/bloc/auth_bloc.dart';
|
|
import 'core/cache/dashboard_cache_manager.dart';
|
|
import 'core/l10n/locale_provider.dart';
|
|
import 'features/auth/presentation/pages/login_page.dart';
|
|
import 'core/navigation/main_navigation_layout.dart';
|
|
import 'core/di/app_di.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Configuration du système
|
|
await _configureApp();
|
|
|
|
// Initialisation de l'injection de dépendances
|
|
await AppDI.initialize();
|
|
|
|
// Initialisation du cache
|
|
await DashboardCacheManager.initialize();
|
|
|
|
// Initialisation du LocaleProvider
|
|
final localeProvider = LocaleProvider();
|
|
await localeProvider.initialize();
|
|
|
|
runApp(UnionFlowApp(localeProvider: localeProvider));
|
|
}
|
|
|
|
/// Configure les paramètres globaux de l'application
|
|
Future<void> _configureApp() async {
|
|
// Configuration de l'orientation
|
|
await SystemChrome.setPreferredOrientations([
|
|
DeviceOrientation.portraitUp,
|
|
]);
|
|
|
|
// Configuration de la barre de statut
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
const SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
statusBarIconBrightness: Brightness.dark,
|
|
statusBarBrightness: Brightness.light,
|
|
systemNavigationBarColor: Colors.white,
|
|
systemNavigationBarIconBrightness: Brightness.dark,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Application principale avec système d'authentification Keycloak
|
|
class UnionFlowApp extends StatelessWidget {
|
|
final LocaleProvider localeProvider;
|
|
|
|
const UnionFlowApp({super.key, required this.localeProvider});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiProvider(
|
|
providers: [
|
|
ChangeNotifierProvider.value(value: localeProvider),
|
|
BlocProvider(
|
|
create: (context) => AuthBloc()..add(const AuthStatusChecked()),
|
|
),
|
|
],
|
|
child: Consumer<LocaleProvider>(
|
|
builder: (context, localeProvider, child) {
|
|
return MaterialApp(
|
|
title: 'UnionFlow',
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
// Configuration du thème
|
|
theme: AppThemeSophisticated.lightTheme,
|
|
// darkTheme: AppThemeSophisticated.darkTheme,
|
|
// themeMode: ThemeMode.system,
|
|
|
|
// Configuration de la localisation
|
|
locale: localeProvider.locale,
|
|
supportedLocales: LocaleProvider.supportedLocales,
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
|
|
// Configuration des routes
|
|
routes: {
|
|
'/': (context) => BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) {
|
|
if (state is AuthLoading) {
|
|
return const Scaffold(
|
|
body: Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
);
|
|
} else if (state is AuthAuthenticated) {
|
|
return const MainNavigationLayout();
|
|
} else {
|
|
return const LoginPage();
|
|
}
|
|
},
|
|
),
|
|
'/dashboard': (context) => const MainNavigationLayout(),
|
|
'/login': (context) => const LoginPage(),
|
|
},
|
|
|
|
// Page d'accueil par défaut
|
|
initialRoute: '/',
|
|
|
|
// Builder global pour gérer les erreurs
|
|
builder: (context, child) {
|
|
return MediaQuery(
|
|
data: MediaQuery.of(context).copyWith(
|
|
textScaler: const TextScaler.linear(1.0),
|
|
),
|
|
child: child ?? const SizedBox(),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
} |