auth
This commit is contained in:
@@ -8,20 +8,19 @@ part 'theme_events.dart';
|
||||
part 'theme_state.dart';
|
||||
|
||||
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> {
|
||||
static const String _savedThemeKey = "themeModeSetting";
|
||||
final SharedPreferences _prefs = GetIt.I.get<SharedPreferences>();
|
||||
ThemeBloc() : super(ThemeState(currentTheme: AppThemeMode.system)) {
|
||||
on<LoadThemeEvent>((event, emit) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
currentTheme: AppThemeMode.fromValue(
|
||||
_prefs.getString(_savedThemeKey),
|
||||
_prefs.getString(PrefKeys.theme.value),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
on<ChangeThemeEvent>((event, emit) async {
|
||||
await _prefs.setString(_savedThemeKey, event.appThemeMode.value);
|
||||
await _prefs.setString(PrefKeys.theme.value, event.appThemeMode.value);
|
||||
emit(state.copyWith(currentTheme: event.appThemeMode));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user