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: force disable material you on Android 11 and below #1293

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions lib/ui/views/navigation/navigation_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ignore_for_file: use_build_context_synchronously
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dynamic_themes/dynamic_themes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -32,7 +33,20 @@ class NavigationViewModel extends IndexTrackingViewModel {

if (prefs.getInt('themeMode') == null) {
await prefs.setInt('themeMode', 0);
await DynamicTheme.of(context)!.setTheme(0);
BenjaminHalko marked this conversation as resolved.
Show resolved Hide resolved
}

// Force disable Material You on Android 11 and below
if (DynamicTheme.of(context)!.themeId.isOdd) {
const int ANDROID_12_SDK_VERSION = 31;
final AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
if (info.version.sdkInt < ANDROID_12_SDK_VERSION) {
BenjaminHalko marked this conversation as resolved.
Show resolved Hide resolved
await prefs.setInt('themeMode', 0);
await prefs.setBool('useDynamicTheme', false);
await DynamicTheme.of(context)!.setTheme(0);
}
}

SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
Expand Down