From 8a6ecaff8c4a99f8e73b6842c10fa2f37d5b7283 Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Thu, 22 Aug 2024 21:05:23 +0200 Subject: [PATCH] fix: improved audio tile, correct unstarred icon, update yaru (#887) --- lib/app/view/app.dart | 73 +++++----------------- lib/common/view/audio_tile.dart | 2 + lib/common/view/theme.dart | 39 ++++++++++++ lib/radio/view/radio_page_star_button.dart | 7 ++- pubspec.lock | 12 +++- pubspec.yaml | 2 +- 6 files changed, 73 insertions(+), 62 deletions(-) diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 607ca8912..30f080ff1 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -9,7 +9,6 @@ import 'package:watch_it/watch_it.dart'; import 'package:window_manager/window_manager.dart'; import 'package:yaru/yaru.dart'; -import '../../common/view/icons.dart'; import '../../common/view/theme.dart'; import '../../external_path/external_path_service.dart'; import '../../l10n/l10n.dart'; @@ -20,78 +19,36 @@ import 'splash_screen.dart'; import 'system_tray.dart'; class YaruMusicPodApp extends StatelessWidget { - const YaruMusicPodApp({ - super.key, - }); + const YaruMusicPodApp({super.key}); @override Widget build(BuildContext context) { return YaruTheme( - builder: (context, yaru, child) { - return _MusicPodApp( - highContrastTheme: yaruHighContrastLight, - highContrastDarkTheme: yaruHighContrastDark, - lightTheme: yaru.theme?.copyWith( - actionIconTheme: ActionIconThemeData( - backButtonIconBuilder: (context) => Icon(Iconz().goBack), - ), - snackBarTheme: SnackBarThemeData( - behavior: SnackBarBehavior.floating, - actionTextColor: yaru.theme?.colorScheme.primary, - ), - cardColor: yaru.theme?.dividerColor.scale( - lightness: -0.01, - ), - ), - darkTheme: yaru.darkTheme?.copyWith( - actionIconTheme: ActionIconThemeData( - backButtonIconBuilder: (context) => Icon(Iconz().goBack), - ), - scaffoldBackgroundColor: - yaru.darkTheme?.scaffoldBackgroundColor.scale( - lightness: -0.35, - ), - dividerColor: yaruFixDarkDividerColor, - dividerTheme: const DividerThemeData( - color: yaruFixDarkDividerColor, - space: 1.0, - thickness: 0.0, - ), - snackBarTheme: SnackBarThemeData( - behavior: SnackBarBehavior.floating, - actionTextColor: yaru.theme?.colorScheme.primary, - ), - cardColor: yaru.darkTheme?.cardColor.scale( - lightness: -0.2, - ), - ), - ); - }, + builder: (context, yaru, child) => _MusicPodApp( + highContrastTheme: yaruHighContrastLight, + highContrastDarkTheme: yaruHighContrastDark, + lightTheme: yaruLightWithTweaks(yaru), + darkTheme: yaruDarkWithTweaks(yaru), + ), ); } } class MaterialMusicPodApp extends StatelessWidget { - const MaterialMusicPodApp({ - super.key, - }); + const MaterialMusicPodApp({super.key}); @override - Widget build(BuildContext context) { - return SystemThemeBuilder( - builder: (context, accent) { - return _MusicPodApp( - accent: accent.accent, - ); - }, - ); - } + Widget build(BuildContext context) => SystemThemeBuilder( + builder: (context, accent) { + return _MusicPodApp( + accent: accent.accent, + ); + }, + ); } class _MusicPodApp extends StatefulWidget with WatchItStatefulWidgetMixin { const _MusicPodApp({ - // ignore: unused_element - super.key, this.lightTheme, this.darkTheme, this.accent, diff --git a/lib/common/view/audio_tile.dart b/lib/common/view/audio_tile.dart index 736ec778d..b090e0a7f 100644 --- a/lib/common/view/audio_tile.dart +++ b/lib/common/view/audio_tile.dart @@ -190,6 +190,7 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin { alignment: Alignment.centerRight, child: Text( Duration(milliseconds: audio.durationMs!.toInt()).formattedTime, + style: context.t.textTheme.labelMedium, ), ), ), @@ -214,6 +215,7 @@ class AlbumTileLead extends StatelessWidget { widthFactor: 1, child: Text( trackNumber?.toString() ?? '0', + style: context.t.textTheme.labelMedium, maxLines: 1, overflow: TextOverflow.ellipsis, ), diff --git a/lib/common/view/theme.dart b/lib/common/view/theme.dart index 440883110..ed2346568 100644 --- a/lib/common/view/theme.dart +++ b/lib/common/view/theme.dart @@ -5,7 +5,46 @@ import 'package:yaru/yaru.dart'; import '../../constants.dart'; import '../../extensions/theme_data_x.dart'; +import 'icons.dart'; +ThemeData? yaruDarkWithTweaks(YaruThemeData yaru) { + return yaru.darkTheme?.copyWith( + actionIconTheme: ActionIconThemeData( + backButtonIconBuilder: (context) => Icon(Iconz().goBack), + ), + scaffoldBackgroundColor: yaru.darkTheme?.scaffoldBackgroundColor.scale( + lightness: -0.35, + ), + dividerColor: yaruFixDarkDividerColor, + dividerTheme: const DividerThemeData( + color: yaruFixDarkDividerColor, + space: 1.0, + thickness: 0.0, + ), + snackBarTheme: SnackBarThemeData( + behavior: SnackBarBehavior.floating, + actionTextColor: yaru.theme?.colorScheme.primary, + ), + cardColor: yaru.darkTheme?.cardColor.scale( + lightness: -0.2, + ), + ); +} + +ThemeData? yaruLightWithTweaks(YaruThemeData yaru) { + return yaru.theme?.copyWith( + actionIconTheme: ActionIconThemeData( + backButtonIconBuilder: (context) => Icon(Iconz().goBack), + ), + snackBarTheme: SnackBarThemeData( + behavior: SnackBarBehavior.floating, + actionTextColor: yaru.theme?.colorScheme.primary, + ), + cardColor: yaru.theme?.dividerColor.scale( + lightness: -0.01, + ), + ); +} // TODO: MOVE TO THEME EXTENSIONS where possible! const yaruFixDarkDividerColor = Color.fromARGB(19, 255, 255, 255); diff --git a/lib/radio/view/radio_page_star_button.dart b/lib/radio/view/radio_page_star_button.dart index a9ef84fe5..f703cee50 100644 --- a/lib/radio/view/radio_page_star_button.dart +++ b/lib/radio/view/radio_page_star_button.dart @@ -28,7 +28,12 @@ class RadioPageStarButton extends StatelessWidget with WatchItMixin { : isStarred ? () => libraryModel.unStarStation(station.url!) : () => libraryModel.addStarredStation(station.url!, [station]), - icon: Iconz().getAnimatedStar(isStarred, context.t.colorScheme.primary), + icon: Iconz().getAnimatedStar( + isStarred, + isStarred + ? context.t.colorScheme.primary + : context.t.colorScheme.onSurface, + ), ); } } diff --git a/pubspec.lock b/pubspec.lock index 643bdecd8..904b401ce 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1086,6 +1086,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.5" + platform_linux: + dependency: transitive + description: + name: platform_linux + sha256: "856cfc9871e3ff3df6926991729d24bba9b70d0229ae377fa08b562344baaaa8" + url: "https://pub.dev" + source: hosted + version: "0.1.2" pls: dependency: "direct main" description: @@ -1759,10 +1767,10 @@ packages: dependency: "direct main" description: name: yaru - sha256: "696407f5d92c8eb8a39d943a9de231c8b22de4b75a5426ca53250f20e6903d10" + sha256: b582f1d552a5c40796cd1a00dbfe2b5e075d14655103eb60d284d7b183dfbc0a url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.1.0" yaru_window: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 715ef3c7f..35bbce93a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -77,7 +77,7 @@ dependencies: win32: ^5.5.4 window_manager: ^0.3.9 xdg_directories: ^1.0.4 - yaru: ^5.0.0 + yaru: ^5.1.0 yaru_window: ^0.2.1 yaru_window_linux: ^0.2.0