theme work
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import 'package:flux/theme/theme_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppSettings {
|
||||
late AppTheme _appTheme;
|
||||
late String _themeModeSetting;
|
||||
late SharedPreferences _prefs;
|
||||
|
||||
// Singleton
|
||||
@@ -16,24 +15,13 @@ class AppSettings {
|
||||
|
||||
AppSettings._internal() {
|
||||
_prefs = GetIt.I.get<SharedPreferences>();
|
||||
String theme = _prefs.getString('theme') ?? 'light';
|
||||
switch (theme) {
|
||||
case 'dark':
|
||||
_appTheme = AppTheme.dark;
|
||||
break;
|
||||
case 'light':
|
||||
_appTheme = AppTheme.light;
|
||||
break;
|
||||
default:
|
||||
_appTheme = AppTheme.system;
|
||||
break;
|
||||
}
|
||||
_themeModeSetting = _prefs.getString('theme') ?? 'light';
|
||||
}
|
||||
|
||||
AppTheme get appTheme => _appTheme;
|
||||
String get themeModeSetting => _themeModeSetting;
|
||||
|
||||
void setAppTheme(AppTheme theme) {
|
||||
_appTheme = theme;
|
||||
_prefs.setString('theme', theme.name);
|
||||
void setThemeModeSetting(String value) {
|
||||
_themeModeSetting = value;
|
||||
_prefs.setString('theme', value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user