diff --git a/lib/settings/settings_view.dart b/lib/settings/settings_view.dart index 4f40adbb..08d4b91c 100644 --- a/lib/settings/settings_view.dart +++ b/lib/settings/settings_view.dart @@ -55,12 +55,13 @@ class SettingsPage extends StatelessWidget { settingKey: 'overrideColor', onChange: logic.updateTheme, childrenIfEnabled: [ - ColorPickerSettingsTile( - settingKey: 'color', - title: '主题色', - defaultValue: ecnuColor, - onChange: logic.updateTheme, - ), + for (final c in ['primary', 'secondary', 'surface']) + ColorPickerSettingsTile( + settingKey: 'color.$c', + title: c, + defaultValue: ecnuColor, + onChange: logic.updateTheme, + ), ], ); diff --git a/lib/settings/theme.dart b/lib/settings/theme.dart index 78b063e4..19f5f2fe 100644 --- a/lib/settings/theme.dart +++ b/lib/settings/theme.dart @@ -4,11 +4,8 @@ import 'package:get/get.dart'; import '../utils/messages.dart'; -const ecnuColor = Color(0xffa41f35); - -Color get _color => Settings.getValue('overrideColor', false) - ? ConversionUtils.colorFromString(Settings.getValue('color', '#ffa41f35')) - : ecnuColor; +const _ecnuColorStr = '#ffa41f35'; +final ecnuColor = ConversionUtils.colorFromString(_ecnuColorStr); ThemeMode get _themeMode => ThemeMode.values[Settings.getValue('themeMode', ThemeMode.system.index)]; @@ -17,9 +14,16 @@ bool get _dark => _themeMode == ThemeMode.dark || _themeMode == ThemeMode.system && Get.isPlatformDarkMode; +Color _c(String key) => Settings.getValue('overrideColor', false) + ? ConversionUtils.colorFromString( + Settings.getValue('color.$key', _ecnuColorStr)) + : ecnuColor; + ThemeData get theme => ThemeData.from( colorScheme: (_dark ? ColorScheme.dark : ColorScheme.light)( - primary: _color, + primary: _c('primary'), + secondary: _c('secondary'), + surface: _c('surface'), ), textTheme: (_dark ? ThemeData.dark : ThemeData.light)() .textTheme