Files
flux/lib/ui/settings/settings.dart

40 lines
878 B
Dart
Raw Normal View History

2026-04-04 19:25:55 +02:00
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 SharedPreferences _prefs;
// Singleton
static final AppSettings _instance = AppSettings._internal();
factory AppSettings() {
return _instance;
}
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;
}
}
AppTheme get appTheme => _appTheme;
void setAppTheme(AppTheme theme) {
_appTheme = theme;
_prefs.setString('theme', theme.name);
}
}