Files
flux/lib/theme/theme_bloc.dart
Mark M2 Macbook c6c61f1a31 Enhance theme management and UI settings
- Updated AppThemeMode enum to include icons and added fromValue method for easier theme retrieval.
- Modified ThemeBloc to manage currentTheme instead of themeMode.
- Enhanced ThemeState to reflect currentTheme and updated copyWith method.
- Added ThemeSettingsView for user-friendly theme selection in settings.
- Improved fluxLightTheme and fluxDarkTheme with new listTileTheme and color settings.
- Updated settings view to navigate to ThemeSettingsView.
- Added entitlements for network client permissions in Debug and Release profiles.
- Introduced Podfile.lock for dependency management.
- Added devtools_options.yaml for Dart & Flutter DevTools configuration.
2026-04-06 08:48:10 +02:00

29 lines
941 B
Dart

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flux/data/enums.dart';
import 'package:get_it/get_it.dart';
import 'package:shared_preferences/shared_preferences.dart';
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),
),
),
);
});
on<ChangeThemeEvent>((event, emit) async {
await _prefs.setString(_savedThemeKey, event.appThemeMode.value);
emit(state.copyWith(currentTheme: event.appThemeMode));
});
}
}