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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,28 @@ class SettingsView extends StatelessWidget {
|
||||
Icons.person,
|
||||
'Profilo Utente',
|
||||
'Configura i tuoi dati',
|
||||
context,
|
||||
),
|
||||
_settingsTile(
|
||||
Icons.store,
|
||||
'Mio Negozio',
|
||||
'Piacenza Centro',
|
||||
context,
|
||||
),
|
||||
_settingsTile(Icons.store, 'Mio Negozio', 'Piacenza Centro'),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_settingsSection('Applicazione', [
|
||||
_settingsTile(Icons.sync, 'Sincronizzazione', 'Ultima: 5 min fa'),
|
||||
_settingsTile(
|
||||
Icons.sync,
|
||||
'Sincronizzazione',
|
||||
'Ultima: 5 min fa',
|
||||
context,
|
||||
),
|
||||
_settingsTile(
|
||||
Icons.dark_mode,
|
||||
'Tema (FLUX Dark Active)',
|
||||
'Configurazione visiva',
|
||||
context,
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 24),
|
||||
@@ -58,14 +70,19 @@ class SettingsView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _settingsTile(IconData icon, String title, String subtitle) {
|
||||
Widget _settingsTile(
|
||||
IconData icon,
|
||||
String title,
|
||||
String subtitle,
|
||||
BuildContext context,
|
||||
) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: FluxColors.primaryBlue),
|
||||
title: Text(title, style: const TextStyle(color: FluxColors.textPrimary)),
|
||||
title: Text(title, style: Theme.of(context).textTheme.titleLarge),
|
||||
subtitle: Text(subtitle),
|
||||
trailing: const Icon(
|
||||
trailing: Icon(
|
||||
Icons.chevron_right,
|
||||
color: FluxColors.textSecondary,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user