hgkj
This commit is contained in:
39
lib/ui/settings/settings.dart
Normal file
39
lib/ui/settings/settings.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// lib/ui/impostazioni/impostazioni_view.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/theme.dart';
|
||||
import 'package:flux/theme/theme.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
const SettingsView({super.key});
|
||||
|
||||
Reference in New Issue
Block a user