diff --git a/lib/app.dart b/lib/app.dart index b9316a4..aacf808 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -107,35 +107,36 @@ class _KMobileState extends State { // ); // }, // ), - child: BlocBuilder( - builder: (context, themeState) { - return BlocBuilder( - 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().state.mode, // <<-- coming from ThemeModeCubit - onGenerateRoute: AppRoutes.generateRoute, - initialRoute: AppRoutes.splash, - home: showSplash ? const SplashScreen() : const AuthGate(), + child: BlocBuilder( + builder: (context, themeState) { + return BlocBuilder( + 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().state.mode, + onGenerateRoute: AppRoutes.generateRoute, + initialRoute: AppRoutes.splash, + home: showSplash ? const SplashScreen() : const AuthGate(), + ); + + }, ); }, - ); - }, - ), + ), ); } } @@ -367,8 +368,7 @@ class _NavigationScaffoldState extends State { 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) { diff --git a/lib/config/themes.dart b/lib/config/themes.dart index 60f2432..d7e63a6 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'theme_type.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -36,4 +36,54 @@ class AppThemes { ), ); } +}*/ + + +import 'package:flutter/material.dart';import 'theme_type.dart'; +import 'package:google_fonts/google_fonts.dart'; +class AppThemes { + static ThemeData getLightTheme(ThemeType type) { + final Color seedColor = _getSeedColor(type); + final colorScheme = ColorScheme.fromSeed( + seedColor: seedColor, + brightness: Brightness.light, + ); + return ThemeData.from( + colorScheme: colorScheme, + useMaterial3: true, + textTheme: GoogleFonts.rubikTextTheme(), + ).copyWith( + scaffoldBackgroundColor: Colors.white, + bottomNavigationBarTheme: BottomNavigationBarThemeData( + backgroundColor: colorScheme.surface, + ), + ); + } + static ThemeData getDarkTheme(ThemeType type) { + final Color seedColor = _getSeedColor(type); + final colorScheme = ColorScheme.fromSeed( + seedColor: seedColor, + brightness: Brightness.dark, // Use dark brightness + ); + return ThemeData.from( + colorScheme: colorScheme, + useMaterial3: true, + textTheme: GoogleFonts.rubikTextTheme( + ThemeData(brightness: Brightness.dark).textTheme, + ), + ); + } + static Color _getSeedColor(ThemeType type) { + switch (type) { + case ThemeType.green: + return Colors.green; + case ThemeType.orange: + return Colors.orange; + case ThemeType.blue: + return Colors.blue; + case ThemeType.violet: + default: + return Colors.deepPurple; + } + } } diff --git a/lib/features/auth/controllers/theme_mode_cubit.dart b/lib/features/auth/controllers/theme_mode_cubit.dart index 97ce4ba..673576d 100644 --- a/lib/features/auth/controllers/theme_mode_cubit.dart +++ b/lib/features/auth/controllers/theme_mode_cubit.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'theme_mode_state.dart'; - class ThemeModeCubit extends Cubit { ThemeModeCubit() : super(const ThemeModeState(mode: ThemeMode.system)) { loadThemeMode(); @@ -21,4 +20,4 @@ class ThemeModeCubit extends Cubit { await prefs.setInt('theme_mode', mode.index); emit(ThemeModeState(mode: mode)); } -} \ No newline at end of file +} diff --git a/lib/features/auth/controllers/theme_mode_state.dart b/lib/features/auth/controllers/theme_mode_state.dart index cad006a..9b969fb 100644 --- a/lib/features/auth/controllers/theme_mode_state.dart +++ b/lib/features/auth/controllers/theme_mode_state.dart @@ -8,4 +8,4 @@ class ThemeModeState extends Equatable { @override List get props => [mode]; -} \ No newline at end of file +} diff --git a/lib/features/auth/controllers/theme_state.dart b/lib/features/auth/controllers/theme_state.dart index ef57938..d3b1507 100644 --- a/lib/features/auth/controllers/theme_state.dart +++ b/lib/features/auth/controllers/theme_state.dart @@ -1,4 +1,4 @@ -import 'package:equatable/equatable.dart'; +/*import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:kmobile/config/theme_type.dart'; import 'package:kmobile/config/themes.dart'; @@ -14,4 +14,28 @@ class ThemeState extends Equatable { @override List get props => [themeType]; -} +}*/ + + +import 'package:equatable/equatable.dart'; +import 'package:flutter/material.dart'; +import 'package:kmobile/config/theme_type.dart'; +import 'package:kmobile/config/themes.dart'; +class ThemeState extends Equatable { + final ThemeType themeType; + const ThemeState({required this.themeType}); + + ThemeData getLightThemeData() { + return AppThemes.getLightTheme(themeType); + } + + ThemeData getDarkThemeData() { + return AppThemes.getDarkTheme(themeType); + } + + @override + List get props => [themeType]; + } + + + diff --git a/lib/features/beneficiaries/screens/add_beneficiary_screen.dart b/lib/features/beneficiaries/screens/add_beneficiary_screen.dart index 5288806..4fde100 100644 --- a/lib/features/beneficiaries/screens/add_beneficiary_screen.dart +++ b/lib/features/beneficiaries/screens/add_beneficiary_screen.dart @@ -224,7 +224,7 @@ class _AddBeneficiaryScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: SafeArea( child: Form( key: _formKey, diff --git a/lib/features/card/screens/block_card_screen.dart b/lib/features/card/screens/block_card_screen.dart index b49ff2e..afa3883 100644 --- a/lib/features/card/screens/block_card_screen.dart +++ b/lib/features/card/screens/block_card_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../../../l10n/app_localizations.dart'; - class BlockCardScreen extends StatefulWidget { const BlockCardScreen({super.key}); @@ -61,7 +60,7 @@ class _BlockCardScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: Padding( padding: const EdgeInsets.all(10.0), child: Form( diff --git a/lib/features/card/screens/card_details_screen.dart b/lib/features/card/screens/card_details_screen.dart index 0528553..2661754 100644 --- a/lib/features/card/screens/card_details_screen.dart +++ b/lib/features/card/screens/card_details_screen.dart @@ -161,4 +161,4 @@ class CardTile extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/features/card/screens/card_management_screen.dart b/lib/features/card/screens/card_management_screen.dart index d7c223d..e3b88f0 100644 --- a/lib/features/card/screens/card_management_screen.dart +++ b/lib/features/card/screens/card_management_screen.dart @@ -59,7 +59,7 @@ class _CardManagementScreen extends State { }, ), const Divider(height: 1), - CardManagementTile( + CardManagementTile( icon: Symbols.payment_card, label: AppLocalizations.of(context).viewCardDeatils, onTap: () { @@ -78,7 +78,6 @@ class _CardManagementScreen extends State { } } - class CardManagementTile extends StatelessWidget { final IconData icon; final String label; diff --git a/lib/features/card/screens/card_pin_change_details_screen.dart b/lib/features/card/screens/card_pin_change_details_screen.dart index 3be4e84..41a4b04 100644 --- a/lib/features/card/screens/card_pin_change_details_screen.dart +++ b/lib/features/card/screens/card_pin_change_details_screen.dart @@ -50,7 +50,7 @@ class _CardPinChangeDetailsScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: Padding( padding: const EdgeInsets.all(10.0), child: Form( diff --git a/lib/features/card/screens/card_pin_set_screen.dart b/lib/features/card/screens/card_pin_set_screen.dart index f6ba521..b0a08a2 100644 --- a/lib/features/card/screens/card_pin_set_screen.dart +++ b/lib/features/card/screens/card_pin_set_screen.dart @@ -50,7 +50,7 @@ class _CardPinSetScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: Padding( padding: const EdgeInsets.all(16.0), child: Form( diff --git a/lib/features/cheque/screens/cheque_management_screen.dart b/lib/features/cheque/screens/cheque_management_screen.dart index 93f9c95..fee8eb0 100644 --- a/lib/features/cheque/screens/cheque_management_screen.dart +++ b/lib/features/cheque/screens/cheque_management_screen.dart @@ -21,7 +21,7 @@ class _ChequeManagementScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: ListView( children: [ const SizedBox(height: 15), diff --git a/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart b/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart index 5ef88cd..7a843f3 100644 --- a/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart +++ b/lib/features/fund_transfer/screens/fund_transfer_amount_screen.dart @@ -17,6 +17,7 @@ import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.da import '../../../l10n/app_localizations.dart'; import 'package:kmobile/api/services/payment_service.dart'; import 'package:kmobile/data/models/transfer.dart'; + enum TransactionMode { neft, rtgs, imps } class FundTransferAmountScreen extends StatefulWidget { @@ -38,7 +39,7 @@ class FundTransferAmountScreen extends StatefulWidget { _FundTransferAmountScreenState(); } -class _FundTransferAmountScreenState extends State { +class _FundTransferAmountScreenState extends State { final _amountController = TextEditingController(); final _formKey = GlobalKey(); TransactionMode _selectedMode = TransactionMode.neft; @@ -370,10 +371,8 @@ class _FundTransferAmountScreenState extends State { color: Theme.of(context).colorScheme.onSurface, borderColor: Colors.transparent, selectedBorderColor: Colors.transparent, - splashColor: - Theme.of(context).primaryColor, - highlightColor: - Theme.of(context).primaryColor, + splashColor: Theme.of(context).primaryColor, + highlightColor: Theme.of(context).primaryColor, children: [ Padding( padding: const EdgeInsets.symmetric( @@ -434,4 +433,4 @@ class _FundTransferAmountScreenState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/features/profile/preferences/preference_screen.dart b/lib/features/profile/preferences/preference_screen.dart index 65a0c8e..e30d020 100644 --- a/lib/features/profile/preferences/preference_screen.dart +++ b/lib/features/profile/preferences/preference_screen.dart @@ -29,8 +29,7 @@ class PreferenceScreen extends StatelessWidget { onTap: () { showDialog( context: context, - builder: (_) => - const LanguageDialog(), + builder: (_) => const LanguageDialog(), ); }, ), @@ -51,8 +50,7 @@ class PreferenceScreen extends StatelessWidget { context: context, builder: (_) => const ColorThemeDialog(), ); - } - ), + }), ], ); }, diff --git a/lib/features/profile/preferences/theme_mode_dialog.dart b/lib/features/profile/preferences/theme_mode_dialog.dart index f03c29b..5f3dca3 100644 --- a/lib/features/profile/preferences/theme_mode_dialog.dart +++ b/lib/features/profile/preferences/theme_mode_dialog.dart @@ -30,4 +30,4 @@ Future showThemeModeDialog(BuildContext context) async { ); }, ); -} \ No newline at end of file +} diff --git a/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart b/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart index 10ccb9f..072abbf 100644 --- a/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart +++ b/lib/features/quick_pay/screens/quick_pay_outside_bank_screen.dart @@ -379,7 +379,7 @@ class _QuickPayOutsideBankScreen extends State { const TextStyle(color: Colors.black, fontWeight: FontWeight.w500), ), centerTitle: false, - ), + ), body: Padding( padding: const EdgeInsets.all(12), child: Form(