feat: implement dynamic theme palette selection
- Introduced a new feature allowing users to select from multiple accent color palettes for buttons, cards, and chat bubbles. - Added `AppThemePalette` provider to manage the current theme palette and persist user selections. - Updated the `AppTheme` class to utilize the selected palette for light and dark themes, enhancing visual customization. - Enhanced the `AppCustomizationPage` to include a palette selector, improving user experience and personalization options. - Updated localization files to support new palette selection UI elements in multiple languages.
This commit is contained in:
@@ -23,6 +23,8 @@ import '../services/optimized_storage_service.dart';
|
||||
import '../services/socket_service.dart';
|
||||
import '../utils/debug_logger.dart';
|
||||
import '../models/socket_event.dart';
|
||||
import '../../shared/theme/color_palettes.dart';
|
||||
import '../../shared/theme/app_theme.dart';
|
||||
|
||||
part 'app_providers.g.dart';
|
||||
|
||||
@@ -78,6 +80,42 @@ class AppThemeMode extends _$AppThemeMode {
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class AppThemePalette extends _$AppThemePalette {
|
||||
late final OptimizedStorageService _storage;
|
||||
|
||||
@override
|
||||
AppColorPalette build() {
|
||||
_storage = ref.watch(optimizedStorageServiceProvider);
|
||||
final storedId = _storage.getThemePaletteId();
|
||||
return AppColorPalettes.byId(storedId);
|
||||
}
|
||||
|
||||
Future<void> setPalette(String paletteId) async {
|
||||
final palette = AppColorPalettes.byId(paletteId);
|
||||
state = palette;
|
||||
await _storage.setThemePaletteId(palette.id);
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class AppLightTheme extends _$AppLightTheme {
|
||||
@override
|
||||
ThemeData build() {
|
||||
final palette = ref.watch(appThemePaletteProvider);
|
||||
return AppTheme.light(palette);
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class AppDarkTheme extends _$AppDarkTheme {
|
||||
@override
|
||||
ThemeData build() {
|
||||
final palette = ref.watch(appThemePaletteProvider);
|
||||
return AppTheme.dark(palette);
|
||||
}
|
||||
}
|
||||
|
||||
// Locale provider
|
||||
@Riverpod(keepAlive: true)
|
||||
class AppLocale extends _$AppLocale {
|
||||
|
||||
Reference in New Issue
Block a user