mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
committed by
GitHub
parent
11cdb67050
commit
d7f7611af4
@@ -15,6 +15,7 @@ import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/cache_manager.dart';
|
||||
import 'package:PiliPlus/utils/calc_window_position.dart';
|
||||
import 'package:PiliPlus/utils/date_utils.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/json_file_handler.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/path_utils.dart';
|
||||
@@ -267,24 +268,14 @@ class MyApp extends StatelessWidget {
|
||||
theme: ThemeUtils.getThemeData(
|
||||
colorScheme: dynamicColor
|
||||
? _light!
|
||||
: SeedColorScheme.fromSeeds(
|
||||
variant: variant,
|
||||
primaryKey: brandColor,
|
||||
brightness: Brightness.light,
|
||||
useExpressiveOnContainerColors: false,
|
||||
),
|
||||
: brandColor.asColorSchemeSeed(variant, .light),
|
||||
isDynamic: dynamicColor,
|
||||
),
|
||||
darkTheme: ThemeUtils.getThemeData(
|
||||
isDark: true,
|
||||
colorScheme: dynamicColor
|
||||
? _dark!
|
||||
: SeedColorScheme.fromSeeds(
|
||||
variant: variant,
|
||||
primaryKey: brandColor,
|
||||
brightness: Brightness.dark,
|
||||
useExpressiveOnContainerColors: false,
|
||||
),
|
||||
: brandColor.asColorSchemeSeed(variant, .dark),
|
||||
isDynamic: dynamicColor,
|
||||
),
|
||||
themeMode: Pref.themeMode,
|
||||
@@ -348,8 +339,8 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// from [DynamicColorBuilderState.initPlatformState]
|
||||
static Future<void> initPlatformState() async {
|
||||
if (_light != null || _dark != null) return;
|
||||
static Future<bool> initPlatformState() async {
|
||||
if (_light != null || _dark != null) return true;
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
try {
|
||||
final corePalette = await DynamicColorPlugin.getCorePalette();
|
||||
@@ -360,7 +351,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
_light = corePalette.toColorScheme();
|
||||
_dark = corePalette.toColorScheme(brightness: Brightness.dark);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
} on PlatformException {
|
||||
if (kDebugMode) {
|
||||
@@ -375,15 +366,10 @@ class MyApp extends StatelessWidget {
|
||||
if (kDebugMode) {
|
||||
debugPrint('dynamic_color: Accent color detected.');
|
||||
}
|
||||
_light = ColorScheme.fromSeed(
|
||||
seedColor: accentColor,
|
||||
brightness: Brightness.light,
|
||||
);
|
||||
_dark = ColorScheme.fromSeed(
|
||||
seedColor: accentColor,
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
return;
|
||||
final variant = FlexSchemeVariant.values[Pref.schemeVariant];
|
||||
_light = accentColor.asColorSchemeSeed(variant, .light);
|
||||
_dark = accentColor.asColorSchemeSeed(variant, .dark);
|
||||
return true;
|
||||
}
|
||||
} on PlatformException {
|
||||
if (kDebugMode) {
|
||||
@@ -393,6 +379,8 @@ class MyApp extends StatelessWidget {
|
||||
if (kDebugMode) {
|
||||
debugPrint('dynamic_color: Dynamic color not detected on this device.');
|
||||
}
|
||||
GStorage.setting.put(SettingBoxKey.dynamicColor, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user