Add Beneficiary Animations and Localizations

This commit is contained in:
2025-08-07 23:36:28 +05:30
parent a1365b19d5
commit ae40f61c01
19 changed files with 139 additions and 275 deletions

View File

@@ -5,9 +5,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kmobile/security/secure_storage.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import './l10n/app_localizations.dart';
import 'config/themes.dart';
import 'config/theme_controller.dart';
import 'config/theme_mode_controller.dart';
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
import 'package:kmobile/features/auth/controllers/theme_state.dart';
import 'config/routes.dart';

View File

@@ -1,28 +0,0 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:kmobile/config/theme_type.dart';
class ThemeController with ChangeNotifier {
ThemeType _currentTheme = ThemeType.violet;
ThemeType get currentTheme => _currentTheme;
Future<void> loadTheme() async {
final prefs = await SharedPreferences.getInstance();
final savedTheme = prefs.getString('color_theme');
if (savedTheme != null) {
_currentTheme = ThemeType.values.firstWhere(
(e) => e.name == savedTheme,
orElse: () => ThemeType.violet,
);
notifyListeners();
}
}
Future<void> setTheme(ThemeType theme) async {
_currentTheme = theme;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setString('color_theme', theme.name);
}
}

View File

@@ -1,40 +0,0 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ThemeModeController with ChangeNotifier {
ThemeMode _currentThemeMode = ThemeMode.system;
ThemeMode get currentThemeMode => _currentThemeMode;
Future<void> loadThemeMode() async {
final prefs = await SharedPreferences.getInstance();
final savedMode = prefs.getString('theme_mode');
if (savedMode != null) {
switch (savedMode) {
case 'light':
_currentThemeMode = ThemeMode.light;
break;
case 'dark':
_currentThemeMode = ThemeMode.dark;
break;
default:
_currentThemeMode = ThemeMode.system;
}
notifyListeners();
}
}
Future<void> toggleThemeMode() async {
if (_currentThemeMode == ThemeMode.light) {
_currentThemeMode = ThemeMode.dark;
} else {
_currentThemeMode = ThemeMode.light;
}
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setString(
'theme_mode',
_currentThemeMode == ThemeMode.light ? 'light' : 'dark',
);
}
}

View File

@@ -1,66 +1,3 @@
/*class AppThemes {
static ThemeData getLightTheme(ThemeType type) {
switch (type) {
case ThemeType.green:
return ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.green,
scaffoldBackgroundColor: Colors.white,
);
case ThemeType.orange:
return ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.orange,
scaffoldBackgroundColor: Colors.white,
);
case ThemeType.blue:
return ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue,
scaffoldBackgroundColor: Colors.white,
);
case ThemeType.violet:
default:
return ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.deepPurple,
scaffoldBackgroundColor: Colors.white,
);
}
}
static ThemeData getDarkTheme(ThemeType type) {
switch (type) {
case ThemeType.green:
return ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.green,
scaffoldBackgroundColor: Colors.black,
);
case ThemeType.orange:
return ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.orange,
scaffoldBackgroundColor: Colors.black,
);
case ThemeType.blue:
return ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
scaffoldBackgroundColor: Colors.black,
);
case ThemeType.violet:
default:
return ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.deepPurple,
scaffoldBackgroundColor: Colors.black,
);
}
}
}*/
import 'package:flutter/material.dart';
import 'theme_type.dart';

View File

@@ -1,7 +1,5 @@
import 'dart:developer';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'theme_state.dart';
import 'package:kmobile/config/theme_type.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -47,14 +45,5 @@ class ThemeCubit extends Cubit<ThemeState> {
print('default macthed');
}
}
// Future<void> toggleDarkMode(bool isDark) async {
// final prefs = await SharedPreferences.getInstance();
// await prefs.setBool('is_dark_mode', isDark);
// emit(state.copyWith(
// themeMode: isDark ? ThemeMode.dark : ThemeMode.light,
// ));
// }
}

View File

@@ -1,32 +1,7 @@
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 {
// final ThemeData lightTheme;
// final ThemeMode themeMode;
// final ThemeType themeType;
// ThemeState({
// required this.lightTheme,
// required this.themeMode,
// required this.themeType,
// });
// ThemeState copyWith({
// ThemeData? lightTheme,
// ThemeMode? themeMode,
// ThemeType? themeType,
// }) {
// return ThemeState(
// lightTheme: lightTheme ?? this.lightTheme,
// themeMode: themeMode ?? this.themeMode,
// themeType: themeType ?? this.themeType,
// );
// }
// bool get isDarkMode => themeMode == ThemeMode.dark;
// }
abstract class ThemeState extends Equatable {
getThemeData();

View File

@@ -64,12 +64,12 @@ bool _isLoading = false; //for validateIFSC()
if (result == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Invalid IFSC code')),
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
);
bankNameController.clear();
branchNameController.clear();
} else {
print("Valid IFSC: ${result.bankName}, ${result.branchName}");
print("${AppLocalizations.of(context).validIfsc}: ${result.bankName}, ${result.branchName}");
bankNameController.text = result.bankName;
branchNameController.text = result.branchName;
}
@@ -118,7 +118,7 @@ void validateAndAddBeneficiary() async {
} catch (e) {
Navigator.pop(context); // Close the spinner
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Something went wrong during validation.")),
SnackBar(content: Text(AppLocalizations.of(context).somethingWentWrong)),
);
}
}
@@ -178,10 +178,10 @@ void validateAndAddBeneficiary() async {
isDense: true,
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
enabledBorder: OutlineInputBorder(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 2,
@@ -213,10 +213,10 @@ void validateAndAddBeneficiary() async {
isDense: true,
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
enabledBorder: OutlineInputBorder(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 2,
@@ -249,10 +249,10 @@ void validateAndAddBeneficiary() async {
isDense: true,
filled: true,
fillColor: Theme.of(context).dialogBackgroundColor,
enabledBorder: OutlineInputBorder(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 2,
@@ -271,14 +271,14 @@ void validateAndAddBeneficiary() async {
controller: ifscController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).ifscCode,
border: OutlineInputBorder(),
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
enabledBorder: OutlineInputBorder(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 2,
@@ -320,14 +320,14 @@ void validateAndAddBeneficiary() async {
enabled: false, // changed from readOnly to disabled
decoration: InputDecoration(
labelText: AppLocalizations.of(context).bankName,
border: OutlineInputBorder(),
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: Theme.of(context).dialogBackgroundColor, // disabled color
enabledBorder: OutlineInputBorder(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 2,
@@ -343,7 +343,7 @@ void validateAndAddBeneficiary() async {
enabled: false, // changed from readOnly to disabled
decoration: InputDecoration(
labelText: AppLocalizations.of(context).branchName,
border: OutlineInputBorder(),
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: Theme.of(context).dialogBackgroundColor,

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:confetti/confetti.dart';
import 'dart:math';
import '../../../l10n/app_localizations.dart';
class BeneficiaryResultPage extends StatefulWidget {
final bool isSuccess;
@@ -53,8 +54,8 @@ class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
const SizedBox(height: 20),
Text(
widget.isSuccess
? 'Beneficiary Added Successfully!'
: 'Beneficiary Addition Failed!',
? AppLocalizations.of(context).beneficiaryAddedSuccess
: AppLocalizations.of(context).beneficiaryAdditionFailed,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,

View File

@@ -482,7 +482,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
MaterialPageRoute(
builder: (context) =>
const FundTransferBeneficiaryScreen()));
}, disable: false),
}, disable: true),
_buildQuickLink(Symbols.server_person,
AppLocalizations.of(context).accountInfo, () {
Navigator.push(

View File

@@ -1,6 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
import '../../../l10n/app_localizations.dart';

View File

@@ -7,7 +7,6 @@ import 'package:kmobile/data/models/transfer.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
import 'package:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_success_screen.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
class TransactionPinScreen extends StatefulWidget {

View File

@@ -2,37 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kmobile/config/theme_type.dart';
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
import 'package:kmobile/features/auth/controllers/theme_state.dart';
/*void showColorThemeDialog(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Select Theme Color'),
content: BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, state) {
return Column(
mainAxisSize: MainAxisSize.min,
children: ThemeType.values.map((type) {
return RadioListTile<ThemeType>(
value: type,
groupValue: state.themeType,
title: Text(type.name.toUpperCase()),
onChanged: (val) {
if (val != null) {
context.read<ThemeCubit>().changeTheme(val);
Navigator.pop(context);
}
},
);
}).toList(),
);
},
),
),
);
}*/
import '../../../l10n/app_localizations.dart';
class ColorThemeDialog extends StatelessWidget {
const ColorThemeDialog({super.key});
@@ -40,11 +10,11 @@ class ColorThemeDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SimpleDialog(
title: const Text('Select Color Theme'),
title: Text(AppLocalizations.of(context).selectThemeColor),
children: [
ListTile(
leading: const CircleAvatar(backgroundColor: Colors.deepPurple),
title: const Text('Violet'),
title: Text(AppLocalizations.of(context).violet),
onTap: () {
context.read<ThemeCubit>().changeTheme(ThemeType.violet);
Navigator.pop(context);
@@ -68,7 +38,7 @@ class ColorThemeDialog extends StatelessWidget {
// ),
ListTile(
leading: const CircleAvatar(backgroundColor: Colors.blue),
title: const Text('Blue'),
title: Text(AppLocalizations.of(context).blue),
onTap: () {
context.read<ThemeCubit>().changeTheme(ThemeType.blue);
Navigator.pop(context);

View File

@@ -3,53 +3,6 @@ import '../../../l10n/app_localizations.dart';
import 'package:kmobile/app.dart';
import 'package:shared_preferences/shared_preferences.dart';
/*class LanguageDialog extends StatelessWidget {
const LanguageDialog({super.key});
String getLocaleName(AppLocalizations localizations, String code) {
final localeCodeMap = {
'en': localizations.english,
'hi': localizations.hindi,
};
return localeCodeMap[code] ?? 'Unknown';
}
@override
Widget build(BuildContext context) {
return Builder(
builder: (context) {
final localizations = AppLocalizations.of(context);
final supportedLocales = [const Locale('en'), const Locale('hi')];
return AlertDialog(
title: Text(localizations.language),
content: Column(
mainAxisSize: MainAxisSize.min,
children: supportedLocales.map((locale) {
return ListTile(
leading: const Icon(Icons.language),
title: Text(getLocaleName(localizations, locale.languageCode)),
onTap: () {
Navigator.pop(context);
KMobile.setLocale(context, locale);
},
);
}).toList(),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(localizations.cancel),
),
],
);
},
);
}
}
*/
class LanguageDialog extends StatelessWidget {
const LanguageDialog({Key? key}) : super(key: key);

View File

@@ -35,7 +35,7 @@ class PreferenceScreen extends StatelessWidget {
//Color_Theme_Selection
ListTile(
leading: const Icon(Icons.color_lens),
title: const Text('Theme Color'),
title: Text(AppLocalizations.of(context).themeColor),
onTap: () {
showDialog(
context: context,

View File

@@ -219,6 +219,14 @@
"setMPIN": "Set your mPIN",
"confirmMPIN": "Confirm your mPIN",
"kconnect": "Kconnect",
"kccBankFull": "Kangra Central Co-operative Bank"
"kccBankFull": "Kangra Central Co-operative Bank",
"themeColor": "Theme Color",
"selectThemeColor": "Select Theme Color",
"violet": "Violet",
"blue": "Blue",
"invalidIfsc": "Invalid IFSC code",
"validIfsc": "Valid IFSC",
"beneficiaryAddedSuccess": "Beneficiary Added Successfully",
"beneficiaryAdditionFailed": "Beneficiary Addition Failed"
}

View File

@@ -219,5 +219,13 @@
"setMPIN": "अपना mPIN सेट करें",
"confirmMPIN": "अपना mPIN की पुष्टि करें",
"kconnect": "के-कनेक्ट",
"kccBankFull": "कांगड़ा सेंट्रल को-ऑपरेटिव बैंक"
"kccBankFull": "कांगड़ा सेंट्रल को-ऑपरेटिव बैंक",
"themeColor": "थीम रंग",
"selectThemeColor": "थीम रंग चुनें",
"violet": "बैंगनी",
"blue": "नीला",
"invalidIfsc": "अमान्य IFSC कोड",
"validIfsc": "मान्य IFSC",
"beneficiaryAddedSuccess": "लाभार्थी सफलतापूर्वक जोड़ा गया",
"beneficiaryAdditionFailed": "लाभार्थी जोड़ने में विफल"
}

View File

@@ -1342,6 +1342,54 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Kangra Central Co-operative Bank'**
String get kccBankFull;
/// No description provided for @themeColor.
///
/// In en, this message translates to:
/// **'Theme Color'**
String get themeColor;
/// No description provided for @selectThemeColor.
///
/// In en, this message translates to:
/// **'Select Theme Color'**
String get selectThemeColor;
/// No description provided for @violet.
///
/// In en, this message translates to:
/// **'Violet'**
String get violet;
/// No description provided for @blue.
///
/// In en, this message translates to:
/// **'Blue'**
String get blue;
/// No description provided for @invalidIfsc.
///
/// In en, this message translates to:
/// **'Invalid IFSC code'**
String get invalidIfsc;
/// No description provided for @validIfsc.
///
/// In en, this message translates to:
/// **'Valid IFSC'**
String get validIfsc;
/// No description provided for @beneficiaryAddedSuccess.
///
/// In en, this message translates to:
/// **'Beneficiary Added Successfully'**
String get beneficiaryAddedSuccess;
/// No description provided for @beneficiaryAdditionFailed.
///
/// In en, this message translates to:
/// **'Beneficiary Addition Failed'**
String get beneficiaryAdditionFailed;
}
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {

View File

@@ -631,4 +631,28 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get kccBankFull => 'Kangra Central Co-operative Bank';
@override
String get themeColor => 'Theme Color';
@override
String get selectThemeColor => 'Select Theme Color';
@override
String get violet => 'Violet';
@override
String get blue => 'Blue';
@override
String get invalidIfsc => 'Invalid IFSC code';
@override
String get validIfsc => 'Valid IFSC';
@override
String get beneficiaryAddedSuccess => 'Beneficiary Added Successfully';
@override
String get beneficiaryAdditionFailed => 'Beneficiary Addition Failed';
}

View File

@@ -631,4 +631,28 @@ class AppLocalizationsHi extends AppLocalizations {
@override
String get kccBankFull => 'कांगड़ा सेंट्रल को-ऑपरेटिव बैंक';
@override
String get themeColor => 'थीम रंग';
@override
String get selectThemeColor => 'थीम रंग चुनें';
@override
String get violet => 'बैंगनी';
@override
String get blue => 'नीला';
@override
String get invalidIfsc => 'अमान्य IFSC कोड';
@override
String get validIfsc => 'मान्य IFSC';
@override
String get beneficiaryAddedSuccess => 'लाभार्थी सफलतापूर्वक जोड़ा गया';
@override
String get beneficiaryAdditionFailed => 'लाभार्थी जोड़ने में विफल';
}