From e06b92fde7deca32daf03a7c3d83f862a04e6bb9 Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 12 Mar 2024 21:15:11 +0100 Subject: [PATCH] new color shit --- refilc/lib/models/settings.dart | 13 ++++++++++++- refilc/lib/theme/theme.dart | 29 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/refilc/lib/models/settings.dart b/refilc/lib/models/settings.dart index 6e9ca8c..35b1e65 100644 --- a/refilc/lib/models/settings.dart +++ b/refilc/lib/models/settings.dart @@ -99,6 +99,7 @@ class SettingsProvider extends ChangeNotifier { bool _calSyncRenamed; String _calendarId; bool _navShadow; + bool _newColors; SettingsProvider({ DatabaseProvider? database, @@ -163,6 +164,7 @@ class SettingsProvider extends ChangeNotifier { required bool calSyncRenamed, required String calendarId, required bool navShadow, + required bool newColors, }) : _database = database, _language = language, _startPage = startPage, @@ -224,7 +226,8 @@ class SettingsProvider extends ChangeNotifier { _calSyncShowTeacher = calSyncShowTeacher, _calSyncRenamed = calSyncRenamed, _calendarId = calendarId, - _navShadow = navShadow; + _navShadow = navShadow, + _newColors = newColors; factory SettingsProvider.fromMap(Map map, {required DatabaseProvider database}) { @@ -306,6 +309,7 @@ class SettingsProvider extends ChangeNotifier { calSyncRenamed: map['cal_sync_renamed'] == 1, calendarId: map['calendar_id'], navShadow: map['nav_shadow'] == 1, + newColors: map['new_colors'] == 1, ); } @@ -375,6 +379,7 @@ class SettingsProvider extends ChangeNotifier { "cal_sync_renamed": _calSyncRenamed ? 1 : 0, "calendar_id": _calendarId, "nav_shadow": _navShadow ? 1 : 0, + "new_colors": _newColors ? 1 : 0, }; } @@ -448,6 +453,7 @@ class SettingsProvider extends ChangeNotifier { calSyncRenamed: false, calendarId: '', navShadow: true, + newColors: true, ); } @@ -512,6 +518,7 @@ class SettingsProvider extends ChangeNotifier { bool get calSyncRenamed => _calSyncRenamed; String get calendarId => _calendarId; bool get navShadow => _navShadow; + bool get newColors => _newColors; Future update({ bool store = true, @@ -572,6 +579,7 @@ class SettingsProvider extends ChangeNotifier { bool? calSyncRenamed, String? calendarId, bool? navShadow, + bool? newColors, }) async { if (language != null && language != _language) _language = language; if (startPage != null && startPage != _startPage) _startPage = startPage; @@ -742,6 +750,9 @@ class SettingsProvider extends ChangeNotifier { if (navShadow != null && navShadow != _navShadow) { _navShadow = navShadow; } + if (newColors != null && newColors != _newColors) { + _newColors = newColors; + } // store or not if (store) await _database?.store.storeSettings(this); notifyListeners(); diff --git a/refilc/lib/theme/theme.dart b/refilc/lib/theme/theme.dart index 4ff4a43..ff90d89 100644 --- a/refilc/lib/theme/theme.dart +++ b/refilc/lib/theme/theme.dart @@ -62,9 +62,19 @@ class AppTheme { : _paletteHighlightLight(palette)) ?? lightColors.highlight; - Color newSecondary = ColorsUtils().darken(accent, amount: 0.4); + Color newSecondary = (accentColor == AccentColor.adaptive || + accentColor == AccentColor.custom || + accentColor == AccentColor.ogfilc) || + !settings.newColors + ? accent + : ColorsUtils().darken(accent, amount: 0.4); // Color newScaffoldBg = ColorsUtils().lighten(accent, amount: 0.4); - Color newTertiary = ColorsUtils().darken(accent, amount: 0.5); + Color newTertiary = (accentColor == AccentColor.adaptive || + accentColor == AccentColor.custom || + accentColor == AccentColor.ogfilc) || + !settings.newColors + ? accent + : ColorsUtils().darken(accent, amount: 0.5); return ThemeData( brightness: Brightness.light, @@ -155,8 +165,19 @@ class AppTheme { : _paletteHighlightDark(palette)) ?? darkColors.highlight; - Color newSecondary = ColorsUtils().lighten(accent, amount: 0.4); - Color newTertiary = ColorsUtils().lighten(accent, amount: 0.5); + Color newSecondary = (accentColor == AccentColor.adaptive || + accentColor == AccentColor.custom || + accentColor == AccentColor.ogfilc) || + !settings.newColors + ? accent + : ColorsUtils().lighten(accent, amount: 0.4); + // Color newScaffoldBg = ColorsUtils().lighten(accent, amount: 0.4); + Color newTertiary = (accentColor == AccentColor.adaptive || + accentColor == AccentColor.custom || + accentColor == AccentColor.ogfilc) || + !settings.newColors + ? accent + : ColorsUtils().lighten(accent, amount: 0.5); return ThemeData( brightness: Brightness.dark,