Skip to content

Commit 0162c60

Browse files
authored
feat: add player color as theme option (#1378)
1 parent 247a918 commit 0162c60

27 files changed

+220
-28
lines changed

lib/app/view/app.dart

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:yaru/yaru.dart';
55

66
import '../../common/view/theme.dart';
77
import '../../extensions/taget_platform_x.dart';
8+
import '../../player/player_model.dart';
89
import '../../settings/settings_model.dart';
910
import 'desktop_musicpod_app.dart';
1011
import 'mobile_musicpod_app.dart';
@@ -61,19 +62,22 @@ class MaterialMusicPodApp extends StatelessWidget with WatchItMixin {
6162
(SettingsModel m) => m.customThemeColor,
6263
);
6364

65+
final usePlayerColor = watchPropertyValue(
66+
(SettingsModel m) => m.usePlayerColor,
67+
);
68+
final playerColor = watchPropertyValue((PlayerModel m) => m.color);
69+
6470
return SystemThemeBuilder(
6571
builder: (context, accent) {
72+
final color = playerColor != null && usePlayerColor
73+
? playerColor
74+
: (customThemeColor != null && useCustomThemeColor
75+
? Color(customThemeColor)
76+
: accent.accent);
77+
6678
return isMobile
67-
? MobileMusicPodApp(
68-
accent: customThemeColor != null && useCustomThemeColor
69-
? Color(customThemeColor)
70-
: accent.accent,
71-
)
72-
: DesktopMusicPodApp(
73-
accent: customThemeColor != null && useCustomThemeColor
74-
? Color(customThemeColor)
75-
: accent.accent,
76-
);
79+
? MobileMusicPodApp(accent: color)
80+
: DesktopMusicPodApp(accent: color);
7781
},
7882
);
7983
}

lib/extensions/shared_preferences_x.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extension SPKeys on SharedPreferences {
4545
static const useYaruTheme = 'useYaruTheme';
4646
static const customThemeColor = 'customThemeColor';
4747
static const useCustomThemeColor = 'useCustomThemeColor';
48+
static const usePlayerColor = 'usePlayerColor';
4849
static const iconSetIndex = 'iconSetIndex';
4950
static const saveWindowSize = 'saveWindowSize';
5051
static const blurredPlayerBackground = 'blurredPlayerBackground';

lib/l10n/app_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,8 @@
722722
"customThemeColor": "Custom theme color",
723723
"useCustomThemeColorTitle": "Use custom accent color",
724724
"useCustomThemeColorDescription": "This will let you chose a custom accent color for the current theme.",
725+
"usePlayerColorTitle": "Use player color",
726+
"usePlayerColorDescription": "This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.",
725727
"selectColor": "Select color",
726728
"selectColorShade": "Select color shade",
727729
"selectColorAndItsShades": "Select color and its shades",

lib/l10n/app_localizations.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,6 +4213,18 @@ abstract class AppLocalizations {
42134213
/// **'This will let you chose a custom accent color for the current theme.'**
42144214
String get useCustomThemeColorDescription;
42154215

4216+
/// No description provided for @usePlayerColorTitle.
4217+
///
4218+
/// In en, this message translates to:
4219+
/// **'Use player color'**
4220+
String get usePlayerColorTitle;
4221+
4222+
/// No description provided for @usePlayerColorDescription.
4223+
///
4224+
/// In en, this message translates to:
4225+
/// **'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.'**
4226+
String get usePlayerColorDescription;
4227+
42164228
/// No description provided for @selectColor.
42174229
///
42184230
/// In en, this message translates to:

lib/l10n/app_localizations_cs.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,13 @@ class AppLocalizationsCs extends AppLocalizations {
21322132
String get useCustomThemeColorDescription =>
21332133
'This will let you chose a custom accent color for the current theme.';
21342134

2135+
@override
2136+
String get usePlayerColorTitle => 'Use player color';
2137+
2138+
@override
2139+
String get usePlayerColorDescription =>
2140+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2141+
21352142
@override
21362143
String get selectColor => 'Select color';
21372144

lib/l10n/app_localizations_da.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,13 @@ class AppLocalizationsDa extends AppLocalizations {
21342134
String get useCustomThemeColorDescription =>
21352135
'This will let you chose a custom accent color for the current theme.';
21362136

2137+
@override
2138+
String get usePlayerColorTitle => 'Use player color';
2139+
2140+
@override
2141+
String get usePlayerColorDescription =>
2142+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2143+
21372144
@override
21382145
String get selectColor => 'Select color';
21392146

lib/l10n/app_localizations_de.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,13 @@ class AppLocalizationsDe extends AppLocalizations {
21412141
String get useCustomThemeColorDescription =>
21422142
'Das lässt dich eine benutzerdefinierte Akzentfarbe für das aktuelle Design auswählen.';
21432143

2144+
@override
2145+
String get usePlayerColorTitle => 'Use player color';
2146+
2147+
@override
2148+
String get usePlayerColorDescription =>
2149+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2150+
21442151
@override
21452152
String get selectColor => 'Farbe auswählen';
21462153

lib/l10n/app_localizations_en.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,13 @@ class AppLocalizationsEn extends AppLocalizations {
21302130
String get useCustomThemeColorDescription =>
21312131
'This will let you chose a custom accent color for the current theme.';
21322132

2133+
@override
2134+
String get usePlayerColorTitle => 'Use player color';
2135+
2136+
@override
2137+
String get usePlayerColorDescription =>
2138+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2139+
21332140
@override
21342141
String get selectColor => 'Select color';
21352142

lib/l10n/app_localizations_es.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,13 @@ class AppLocalizationsEs extends AppLocalizations {
21422142
String get useCustomThemeColorDescription =>
21432143
'This will let you chose a custom accent color for the current theme.';
21442144

2145+
@override
2146+
String get usePlayerColorTitle => 'Use player color';
2147+
2148+
@override
2149+
String get usePlayerColorDescription =>
2150+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2151+
21452152
@override
21462153
String get selectColor => 'Select color';
21472154

lib/l10n/app_localizations_et.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,13 @@ class AppLocalizationsEt extends AppLocalizations {
21392139
String get useCustomThemeColorDescription =>
21402140
'See eelistus võimaldab sul valida aktsentvärvi vastavalt oma soovidele.';
21412141

2142+
@override
2143+
String get usePlayerColorTitle => 'Use player color';
2144+
2145+
@override
2146+
String get usePlayerColorDescription =>
2147+
'This will use the dominant color has been extracted out of the current artwork (if available) for the whole app.';
2148+
21422149
@override
21432150
String get selectColor => 'Vali värv';
21442151

0 commit comments

Comments
 (0)