From 062ece7f10d163287ad98b5407f44753f24735ed Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Wed, 19 Jun 2024 09:44:01 +0200 Subject: [PATCH] Fix issues with themes --- .../lib/data_models/preferences/user_preferences.dart | 4 +++- packages/smooth_app/lib/resources/app_animations.dart | 2 +- packages/smooth_app/lib/themes/theme_provider.dart | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/smooth_app/lib/data_models/preferences/user_preferences.dart b/packages/smooth_app/lib/data_models/preferences/user_preferences.dart index a9496dfda1d..6bed2453a2d 100644 --- a/packages/smooth_app/lib/data_models/preferences/user_preferences.dart +++ b/packages/smooth_app/lib/data_models/preferences/user_preferences.dart @@ -7,6 +7,7 @@ import 'package:smooth_app/data_models/product_preferences.dart'; import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart'; import 'package:smooth_app/pages/preferences/user_preferences_dev_mode.dart'; import 'package:smooth_app/themes/color_schemes.dart'; +import 'package:smooth_app/themes/theme_provider.dart'; part 'package:smooth_app/data_models/preferences/migration/user_preferences_migration.dart'; @@ -203,7 +204,8 @@ class UserPreferences extends ChangeNotifier { _sharedPreferences.getBool(_TAG_CRASH_REPORTS) ?? false; String get currentTheme => - _sharedPreferences.getString(_TAG_CURRENT_THEME_MODE) ?? 'System Default'; + _sharedPreferences.getString(_TAG_CURRENT_THEME_MODE) ?? + THEME_SYSTEM_DEFAULT; String get currentColor => _sharedPreferences.getString(_TAG_CURRENT_COLOR_SCHEME) ?? diff --git a/packages/smooth_app/lib/resources/app_animations.dart b/packages/smooth_app/lib/resources/app_animations.dart index 2b8a602ab10..1acdaaf48f1 100644 --- a/packages/smooth_app/lib/resources/app_animations.dart +++ b/packages/smooth_app/lib/resources/app_animations.dart @@ -169,7 +169,7 @@ class _SearchEyeAnimationState extends State { @override Widget build(BuildContext context) { final double size = widget.size ?? IconTheme.of(context).size ?? 24.0; - final bool lightTheme = context.watch().isDarkMode(context); + final bool lightTheme = !context.watch().isDarkMode(context); return ExcludeSemantics( child: SizedBox( diff --git a/packages/smooth_app/lib/themes/theme_provider.dart b/packages/smooth_app/lib/themes/theme_provider.dart index 0bb268f8d89..bb8e5160909 100644 --- a/packages/smooth_app/lib/themes/theme_provider.dart +++ b/packages/smooth_app/lib/themes/theme_provider.dart @@ -60,14 +60,17 @@ class ThemeProvider with ChangeNotifier { Future setTheme(String value) async { assert( - value != THEME_LIGHT || value != THEME_DARK || value != THEME_AMOLED); + value != THEME_LIGHT || value != THEME_DARK || value != THEME_AMOLED); await _userPreferences.setTheme(value); notifyListeners(); } bool isDarkMode(BuildContext context) { - return currentThemeMode != ThemeMode.light && - MediaQuery.platformBrightnessOf(context) == Brightness.dark; + + if (currentTheme == THEME_SYSTEM_DEFAULT) { + return MediaQuery.platformBrightnessOf(context) == Brightness.dark; + } + return [THEME_DARK, THEME_AMOLED].contains(currentTheme); } @override