From 8c8c8620952af22b6ac4c464bba187169eefc528 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 18 Nov 2024 19:32:15 +0800 Subject: [PATCH 1/2] feat: pure dark mode --- lib/main.dart | 25 +++++++++++++++++++++++-- lib/pages/setting/style_setting.dart | 9 +++++++++ lib/utils/storage.dart | 3 ++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 1ec86c8e..30464b0c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -214,6 +214,27 @@ class BuildMainApp extends StatelessWidget { @override Widget build(BuildContext context) { + Box setting = GStorage.setting; + + /// 纯黑模式主题配置 + ColorScheme? pureDarkColorScheme; + final bool enablePureBlack = + setting.get(SettingBoxKey.enablePureBlack, defaultValue: false); + if (enablePureBlack) { + pureDarkColorScheme = darkColorScheme.copyWith( + background: Colors.black, + surface: Colors.black, + primary: Colors.white, + secondary: Colors.white, + error: Colors.red, + onPrimary: Colors.black, + onSecondary: Colors.black, + onSurface: Colors.white, + onBackground: Colors.white, + onError: Colors.white, + ); + } + final SnackBarThemeData snackBarTheme = SnackBarThemeData( actionTextColor: lightColorScheme.primary, backgroundColor: lightColorScheme.secondaryContainer, @@ -253,13 +274,13 @@ class BuildMainApp extends StatelessWidget { title: 'PiliPala', theme: buildThemeData( currentThemeValue == ThemeType.dark - ? darkColorScheme + ? pureDarkColorScheme ?? darkColorScheme : lightColorScheme, ), darkTheme: buildThemeData( currentThemeValue == ThemeType.light ? lightColorScheme - : darkColorScheme, + : pureDarkColorScheme ?? darkColorScheme, ), localizationsDelegates: const [ GlobalCupertinoLocalizations.delegate, diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index 5b59397e..12f52414 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -249,6 +249,15 @@ class _StyleSettingState extends State { '当前模式:${settingController.themeType.value.description}', style: subTitleStyle)), ), + SetSwitchItem( + title: '纯黑模式', + subTitle: '深色模式时使用纯黑色背景,适用于OLED屏幕', + setKey: SettingBoxKey.enablePureBlack, + defaultVal: false, + callFn: (bool val) => { + if (val && Get.isDarkMode) {Get.appUpdate()} + }, + ), ListTile( dense: false, onTap: () => settingController.setDynamicBadgeMode(context), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index a5b36768..ac02592e 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -133,7 +133,8 @@ class SettingBoxKey { enableGradientBg = 'enableGradientBg', enableDynamicSwitch = 'enableDynamicSwitch', navBarSort = 'navBarSort', - actionTypeSort = 'actionTypeSort'; + actionTypeSort = 'actionTypeSort', + enablePureBlack = 'enablePureBlack'; } class LocalCacheKey { From 417c225b27a6df680c044ab7027b6ff80821dd9b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 4 Dec 2024 23:35:59 +0800 Subject: [PATCH 2/2] mod: pureBlack theme config --- lib/main.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8dc243ab..6c43a139 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -226,14 +226,8 @@ class BuildMainApp extends StatelessWidget { pureDarkColorScheme = darkColorScheme.copyWith( background: Colors.black, surface: Colors.black, - primary: Colors.white, - secondary: Colors.white, - error: Colors.red, onPrimary: Colors.black, onSecondary: Colors.black, - onSurface: Colors.white, - onBackground: Colors.white, - onError: Colors.white, ); }