Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix issues with themes #5410

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading