IFSC Code Validation and Add Beneficiary Validation API integration
This commit is contained in:
@@ -1,50 +1,60 @@
|
||||
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';
|
||||
import 'package:kmobile/config/themes.dart';
|
||||
// import 'package:kmobile/config/themes.dart';
|
||||
|
||||
class ThemeCubit extends Cubit<ThemeState> {
|
||||
ThemeCubit()
|
||||
: super(ThemeState(
|
||||
lightTheme: AppThemes.getLightTheme(ThemeType.violet),
|
||||
themeMode: ThemeMode.light,
|
||||
themeType: ThemeType.violet,
|
||||
)) {
|
||||
ThemeCubit(): super(ThemeViolet()) {
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
Future<void> loadTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
||||
final isDark = prefs.getBool('is_dark_mode') ?? false;
|
||||
// final isDark = prefs.getBool('is_dark_mode') ?? false;
|
||||
|
||||
final type = ThemeType.values[themeIndex];
|
||||
emit(state.copyWith(
|
||||
lightTheme: AppThemes.getLightTheme(type),
|
||||
themeMode: isDark ? ThemeMode.dark : ThemeMode.light,
|
||||
themeType: type,
|
||||
));
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
default:
|
||||
emit(ThemeViolet());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeTheme(ThemeType type) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('theme_type', type.index);
|
||||
|
||||
emit(state.copyWith(
|
||||
lightTheme: AppThemes.getLightTheme(type),
|
||||
themeType: type,
|
||||
));
|
||||
log("Mode Change");
|
||||
print("mode changed");
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
print('blue matched');
|
||||
break;
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
print('violet matched');
|
||||
break;
|
||||
default:
|
||||
emit(ThemeBlue());
|
||||
print('default macthed');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> toggleDarkMode(bool isDark) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('is_dark_mode', isDark);
|
||||
// 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,
|
||||
));
|
||||
}
|
||||
// emit(state.copyWith(
|
||||
// themeMode: isDark ? ThemeMode.dark : ThemeMode.light,
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user