Theme Mode #2
This commit is contained in:
58
lib/app.dart
58
lib/app.dart
@@ -107,35 +107,36 @@ class _KMobileState extends State<KMobile> {
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, themeState) {
|
||||
return BlocBuilder<ThemeModeCubit, ThemeModeState>(
|
||||
builder: (context, modeState) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: _locale ?? const Locale('en'),
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('hi'),
|
||||
],
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
title: 'kMobile',
|
||||
theme: themeState.getThemeData(),
|
||||
darkTheme: themeState.getThemeData(), // reuse same color in dark
|
||||
themeMode: context.watch<ThemeModeCubit>().state.mode, // <<-- coming from ThemeModeCubit
|
||||
onGenerateRoute: AppRoutes.generateRoute,
|
||||
initialRoute: AppRoutes.splash,
|
||||
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, themeState) {
|
||||
return BlocBuilder<ThemeModeCubit, ThemeModeState>(
|
||||
builder: (context, modeState) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: _locale ?? const Locale('en'),
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('hi'),
|
||||
],
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
title: 'kMobile',
|
||||
theme: themeState.getLightThemeData(),
|
||||
darkTheme: themeState.getDarkThemeData(),
|
||||
themeMode: context.watch<ThemeModeCubit>().state.mode,
|
||||
onGenerateRoute: AppRoutes.generateRoute,
|
||||
initialRoute: AppRoutes.splash,
|
||||
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||
);
|
||||
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -367,8 +368,7 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Theme.of(context)
|
||||
.scaffoldBackgroundColor,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
selectedItemColor: Theme.of(context).primaryColor,
|
||||
unselectedItemColor: Colors.black54,
|
||||
onTap: (index) {
|
||||
|
Reference in New Issue
Block a user