This commit is contained in:
2026-04-06 10:55:56 +02:00
parent c6c61f1a31
commit 4930d25e58
15 changed files with 658 additions and 11 deletions

View File

@@ -243,12 +243,24 @@ ThemeData fluxLightTheme = ThemeData(
);
extension FluxThemeContext on BuildContext {
// Recupera il colore 'secondary' definito nel tuo ColorScheme (il Turchese Flux)
Color get accent => Theme.of(this).colorScheme.secondary;
// --- Colori del Brand ---
Color get primary => Theme.of(this).colorScheme.primary; // Blu Flux
Color get accent => Theme.of(this).colorScheme.secondary; // Turchese Flux
// Puoi aggiungere anche questi per comodità futura:
Color get primary => Theme.of(this).colorScheme.primary;
// --- Superfici ---
Color get surface => Theme.of(this).colorScheme.surface;
Color get background =>
Theme.of(this).colorScheme.surfaceContainerHighest; // O background
// --- Testi (La parte mancante) ---
// Mappiamo primaryText sul colore del titolo e secondaryText su quello del corpo
Color get primaryText =>
Theme.of(this).textTheme.titleLarge?.color ?? Colors.black;
Theme.of(this).textTheme.titleLarge?.color ?? Colors.white;
Color get secondaryText =>
Theme.of(this).textTheme.bodyMedium?.color ?? Colors.grey;
// Opzionale: un colore ancora più tenue per suggerimenti o icone disabilitate
Color get hintText =>
Theme.of(this).textTheme.bodySmall?.color ??
Colors.grey.withValues(alpha: 0.5);
}

View File

@@ -8,20 +8,19 @@ part 'theme_events.dart';
part 'theme_state.dart';
class ThemeBloc extends Bloc<ThemeEvent, ThemeState> {
static const String _savedThemeKey = "themeModeSetting";
final SharedPreferences _prefs = GetIt.I.get<SharedPreferences>();
ThemeBloc() : super(ThemeState(currentTheme: AppThemeMode.system)) {
on<LoadThemeEvent>((event, emit) {
emit(
state.copyWith(
currentTheme: AppThemeMode.fromValue(
_prefs.getString(_savedThemeKey),
_prefs.getString(PrefKeys.theme.value),
),
),
);
});
on<ChangeThemeEvent>((event, emit) async {
await _prefs.setString(_savedThemeKey, event.appThemeMode.value);
await _prefs.setString(PrefKeys.theme.value, event.appThemeMode.value);
emit(state.copyWith(currentTheme: event.appThemeMode));
});
}