theme work
This commit is contained in:
@@ -14,42 +14,30 @@ void main() async {
|
||||
await SharedPreferences.getInstance(),
|
||||
);
|
||||
getIt.registerSingleton<AppSettings>(AppSettings());
|
||||
runApp(const MainApp());
|
||||
runApp(
|
||||
BlocProvider(
|
||||
create: (context) => ThemeBloc()..add(LoadThemeEvent()),
|
||||
child: const FluxApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class MainApp extends StatelessWidget {
|
||||
const MainApp({super.key});
|
||||
class FluxApp extends StatelessWidget {
|
||||
const FluxApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppTheme appTheme = GetIt.I.get<AppSettings>().appTheme;
|
||||
ThemeData themeData;
|
||||
switch (appTheme) {
|
||||
case AppTheme.dark:
|
||||
themeData = fluxDarkTheme;
|
||||
break;
|
||||
case AppTheme.light:
|
||||
themeData = fluxLightTheme;
|
||||
break;
|
||||
default:
|
||||
themeData = ThemeMode.system == ThemeMode.dark
|
||||
? fluxDarkTheme
|
||||
: fluxLightTheme;
|
||||
break;
|
||||
}
|
||||
return MaterialApp(
|
||||
title: 'FLUX Gestionale',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: themeData, // Applica il tema FLUX
|
||||
home: MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => ThemeBloc(initialAppTheme: appTheme),
|
||||
),
|
||||
],
|
||||
|
||||
child: const HomeScreen(),
|
||||
),
|
||||
return BlocBuilder<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) {
|
||||
return MaterialApp(
|
||||
title: 'FLUX Gestionale',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: fluxLightTheme,
|
||||
darkTheme: fluxDarkTheme,
|
||||
themeMode: state.themeMode, // Applica il tema FLUX
|
||||
home: const HomeScreen(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user