Theme Mode #1
This commit is contained in:
44
lib/app.dart
44
lib/app.dart
@@ -2,6 +2,8 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_state.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import './l10n/app_localizations.dart';
|
||||
@@ -78,9 +80,37 @@ class _KMobileState extends State<KMobile> {
|
||||
providers: [
|
||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
||||
BlocProvider<ThemeCubit>(create: (_) => ThemeCubit()),
|
||||
BlocProvider<ThemeModeCubit>(create: (_) => ThemeModeCubit()),
|
||||
],
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, themeState) {
|
||||
// child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
// builder: (context, themeState) {
|
||||
// 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(),
|
||||
// themeMode: ThemeMode.light,
|
||||
// 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'),
|
||||
@@ -96,14 +126,16 @@ class _KMobileState extends State<KMobile> {
|
||||
],
|
||||
title: 'kMobile',
|
||||
theme: themeState.getThemeData(),
|
||||
//darkTheme: themeState.getThemeData(),
|
||||
themeMode: ThemeMode.light,
|
||||
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(),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -336,7 +368,7 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||
currentIndex: _selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Theme.of(context)
|
||||
.scaffoldBackgroundColor, // Light blue background
|
||||
.scaffoldBackgroundColor,
|
||||
selectedItemColor: Theme.of(context).primaryColor,
|
||||
unselectedItemColor: Colors.black54,
|
||||
onTap: (index) {
|
||||
|
Reference in New Issue
Block a user