theme work

This commit is contained in:
2026-04-05 10:06:26 +02:00
parent 0347a354ef
commit 28b2abdff3
16 changed files with 223 additions and 137 deletions

View File

@@ -16,7 +16,7 @@ class AnagraficheMainView extends StatelessWidget {
isScrollable: true,
indicatorColor: FluxColors.accentTurquoise,
labelColor: FluxColors.accentTurquoise,
unselectedLabelColor: FluxColors.textSecondary,
unselectedLabelColor: Theme.of(context).textTheme.bodyMedium?.color,
tabs: [
Tab(icon: Icon(Icons.storefront), text: 'Negozi'),
Tab(icon: Icon(Icons.support_agent), text: 'Gestori'),

View File

@@ -92,26 +92,28 @@ class _RecentActivityPreview extends StatelessWidget {
'Attività Recenti',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const Divider(color: FluxColors.textSecondary),
Divider(color: Theme.of(context).textTheme.bodyMedium?.color),
// Sostituire con BlocBuilder
_activityTile('Nuova Linea', 'Mario Rossi', '10 min fa'),
_activityTile('Assistenza Tech', 'iPhone 13', '45 min fa'),
_activityTile('Nuova Linea', 'Mario Rossi', '10 min fa', context),
_activityTile('Assistenza Tech', 'iPhone 13', '45 min fa', context),
],
),
),
);
}
Widget _activityTile(String title, String subtitle, String time) {
Widget _activityTile(
String title,
String subtitle,
String time,
BuildContext context,
) {
return ListTile(
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.history, color: FluxColors.accentTurquoise),
title: Text(title, style: const TextStyle(color: FluxColors.textPrimary)),
title: Text(title, style: Theme.of(context).textTheme.titleLarge),
subtitle: Text(subtitle),
trailing: Text(
time,
style: const TextStyle(color: FluxColors.textSecondary, fontSize: 12),
),
trailing: Text(time, style: Theme.of(context).textTheme.bodyMedium),
);
}
}

View File

@@ -1,7 +1,5 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flux/theme/theme.dart';
import 'package:flux/theme/theme_bloc.dart';
import 'package:flux/ui/anagrafiche/anagrafiche_main_view.dart';
import 'package:flux/ui/dashboard/dashboard_view.dart';
import 'package:flux/ui/settings/settings_view.dart';
@@ -31,46 +29,39 @@ class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return BlocBuilder<ThemeBloc, ThemeState>(
builder: (context, state) {
return Scaffold(
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.dashboard_outlined),
activeIcon: Icon(Icons.dashboard),
label: 'Dashboard',
),
BottomNavigationBarItem(
icon: Icon(Icons.history_edu_outlined),
activeIcon: Icon(Icons.history_edu),
label: 'Operazioni',
),
BottomNavigationBarItem(
icon: Icon(Icons.people_alt_outlined),
activeIcon: Icon(Icons.people_alt),
label: 'Anagrafiche',
),
BottomNavigationBarItem(
icon: Icon(Icons.settings_outlined),
activeIcon: Icon(Icons.settings),
label: 'Impostazioni',
),
],
currentIndex: _selectedIndex,
selectedItemColor: FluxColors.accentTurquoise,
unselectedItemColor: state.themeMode == ThemeMode.dark
? FluxColors.darkTextSecondary
: FluxColors.lightTextSecondary,
backgroundColor: state.themeMode == ThemeMode.dark
? FluxColors.darkSurface
: FluxColors.lightSurface,
type: BottomNavigationBarType.fixed,
onTap: _onItemTapped,
final surfaceColor = Theme.of(context).colorScheme.surface;
return Scaffold(
body: Center(child: _widgetOptions.elementAt(_selectedIndex)),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.dashboard_outlined),
activeIcon: Icon(Icons.dashboard),
label: 'Dashboard',
),
);
},
BottomNavigationBarItem(
icon: Icon(Icons.history_edu_outlined),
activeIcon: Icon(Icons.history_edu),
label: 'Operazioni',
),
BottomNavigationBarItem(
icon: Icon(Icons.people_alt_outlined),
activeIcon: Icon(Icons.people_alt),
label: 'Anagrafiche',
),
BottomNavigationBarItem(
icon: Icon(Icons.settings_outlined),
activeIcon: Icon(Icons.settings),
label: 'Impostazioni',
),
],
currentIndex: _selectedIndex,
selectedItemColor: FluxColors.accentTurquoise,
unselectedItemColor: Theme.of(context).textTheme.bodyMedium?.color,
backgroundColor: surfaceColor,
type: BottomNavigationBarType.fixed,
onTap: _onItemTapped,
),
);
}
}

View File

@@ -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);
}
}

View File

@@ -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,
),
);
}