Skip to content

Commit

Permalink
fix: improved audio tile, correct unstarred icon, update yaru (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Aug 22, 2024
1 parent 9cba0ac commit 8a6ecaf
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 62 deletions.
73 changes: 15 additions & 58 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
),
Expand All @@ -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,
),
Expand Down
39 changes: 39 additions & 0 deletions lib/common/view/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion lib/radio/view/radio_page_star_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
}
}
12 changes: 10 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8a6ecaf

Please sign in to comment.