Skip to content

Commit

Permalink
fix: Fix issues with themes (#5410)
Browse files Browse the repository at this point in the history
* Fix issues with themes

* Reformat code
  • Loading branch information
g123k committed Jun 19, 2024
1 parent b9f83c4 commit 6026fbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) ??
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/lib/resources/app_animations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class _SearchEyeAnimationState extends State<SearchEyeAnimation> {
@override
Widget build(BuildContext context) {
final double size = widget.size ?? IconTheme.of(context).size ?? 24.0;
final bool lightTheme = context.watch<ThemeProvider>().isDarkMode(context);
final bool lightTheme = !context.watch<ThemeProvider>().isDarkMode(context);

return ExcludeSemantics(
child: SizedBox(
Expand Down
6 changes: 4 additions & 2 deletions packages/smooth_app/lib/themes/theme_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ class ThemeProvider with ChangeNotifier {
}

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 <String>[THEME_DARK, THEME_AMOLED].contains(currentTheme);
}

@override
Expand Down

0 comments on commit 6026fbc

Please sign in to comment.