diff --git a/src/JellyBox/Controls/CustomMediaTransportControls.IconUpdates.cs b/src/JellyBox/Controls/CustomMediaTransportControls.IconUpdates.cs index 739518a..847f647 100644 --- a/src/JellyBox/Controls/CustomMediaTransportControls.IconUpdates.cs +++ b/src/JellyBox/Controls/CustomMediaTransportControls.IconUpdates.cs @@ -1,14 +1,28 @@ +using Windows.UI; using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Media; namespace JellyBox.Controls; internal sealed partial class CustomMediaTransportControls { + private static readonly SolidColorBrush FavoriteOnBrush = new(Colors.Red); + private static readonly SolidColorBrush FavoriteOffBrush = new(Colors.White); + private bool _isUpdatingVolumeSlider; private void UpdatePlayPauseIcon() => _playPauseIcon?.Glyph = IsPlaying ? Glyphs.Pause : Glyphs.Play; - private void UpdateFavoriteIcon() => _favoriteIcon?.Glyph = IsFavorite ? Glyphs.HeartFilled : Glyphs.HeartOutline; + private void UpdateFavoriteIcon() + { + if (_favoriteIcon is null) + { + return; + } + + _favoriteIcon.Glyph = IsFavorite ? Glyphs.HeartFilled : Glyphs.HeartOutline; + _favoriteIcon.Foreground = IsFavorite ? FavoriteOnBrush : FavoriteOffBrush; + } private void UpdateEndsAtText() => _endsAtTextBlock?.Text = EndsAtText; diff --git a/src/JellyBox/Converters/BoolToBrushConverter.cs b/src/JellyBox/Converters/BoolToBrushConverter.cs new file mode 100644 index 0000000..6b6b235 --- /dev/null +++ b/src/JellyBox/Converters/BoolToBrushConverter.cs @@ -0,0 +1,23 @@ +using Windows.UI; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Media; + +namespace JellyBox.Converters; + +/// +/// Value converter that translates a bool into a brush color. +/// True returns the "on" color (e.g., red for active state), False returns the "off" color (e.g., white for inactive state). +/// +internal sealed partial class BoolToBrushConverter : IValueConverter +{ + private static readonly SolidColorBrush OnBrush = new(Colors.Red); + private static readonly SolidColorBrush OffBrush = new(Colors.White); + + public object Convert(object value, Type targetType, object parameter, string language) + => value is not bool b + ? throw new InvalidOperationException($"{nameof(BoolToBrushConverter)} can only be used with bool") + : b ? OnBrush : OffBrush; + + public object ConvertBack(object value, Type targetType, object parameter, string language) + => throw new NotSupportedException(); +} diff --git a/src/JellyBox/Glyphs.cs b/src/JellyBox/Glyphs.cs index 82d6ed3..741226c 100644 --- a/src/JellyBox/Glyphs.cs +++ b/src/JellyBox/Glyphs.cs @@ -8,6 +8,7 @@ internal static class Glyphs // Playback public const string Play = "\uE768"; public const string Pause = "\uE769"; + public const string Movies = "\uE8B2"; // Volume public const string VolumeMute = "\uE74F"; @@ -15,6 +16,10 @@ internal static class Glyphs public const string VolumeMedium = "\uE994"; public const string VolumeHigh = "\uE767"; + // Actions + public const string Accept = "\uE8FB"; + public const string More = "\uE712"; + // Favorites public const string HeartOutline = "\uEB51"; public const string HeartFilled = "\uEB52"; diff --git a/src/JellyBox/Resources/Styles.xaml b/src/JellyBox/Resources/Styles.xaml index d58c6b7..10169c0 100644 --- a/src/JellyBox/Resources/Styles.xaml +++ b/src/JellyBox/Resources/Styles.xaml @@ -4,10 +4,13 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Converters="using:JellyBox.Converters"> + + Segoe MDL2 Assets + diff --git a/src/JellyBox/ViewModels/ItemDetailsViewModel.cs b/src/JellyBox/ViewModels/ItemDetailsViewModel.cs index 9572fda..647ca6e 100644 --- a/src/JellyBox/ViewModels/ItemDetailsViewModel.cs +++ b/src/JellyBox/ViewModels/ItemDetailsViewModel.cs @@ -7,8 +7,6 @@ using JellyBox.Views; using Jellyfin.Sdk; using Jellyfin.Sdk.Generated.Models; -using Windows.UI; -using Windows.UI.Xaml.Media; namespace JellyBox.ViewModels; @@ -25,9 +23,6 @@ internal sealed record MediaSourceInfoWrapper(string DisplayText, MediaSourceInf internal sealed partial class ItemDetailsViewModel : ObservableObject #pragma warning restore CA1812 // Avoid uninstantiated internal classes { - private static readonly SolidColorBrush OnBrush = new SolidColorBrush(Colors.Red); - private static readonly SolidColorBrush OffBrush = new SolidColorBrush(Colors.White); - private readonly JellyfinApiClient _jellyfinApiClient; private readonly JellyfinImageResolver _imageResolver; private readonly NavigationManager _navigationManager; @@ -87,15 +82,9 @@ internal sealed partial class ItemDetailsViewModel : ObservableObject [ObservableProperty] public partial bool IsPlayed { get; set; } - [ObservableProperty] - public partial Brush? PlayStateBrush { get; set; } - [ObservableProperty] public partial bool IsFavorite { get; set; } - [ObservableProperty] - public partial Brush? FavoriteBrush { get; set; } - [ObservableProperty] public partial List
? Sections { get; set; } @@ -460,10 +449,7 @@ private void UpdateUserData() } IsPlayed = Item.UserData!.Played.GetValueOrDefault(); - PlayStateBrush = IsPlayed ? OnBrush : OffBrush; - IsFavorite = Item.UserData.IsFavorite.GetValueOrDefault(); - FavoriteBrush = IsFavorite ? OnBrush : OffBrush; } private async Task GetNextUpSectionAsync() diff --git a/src/JellyBox/Views/ItemDetails.xaml b/src/JellyBox/Views/ItemDetails.xaml index 031141f..496329c 100644 --- a/src/JellyBox/Views/ItemDetails.xaml +++ b/src/JellyBox/Views/ItemDetails.xaml @@ -9,6 +9,7 @@ xmlns:Behaviors="using:JellyBox.Behaviors" xmlns:uc="using:JellyBox.Controls" xmlns:m="using:JellyBox.Models" + xmlns:g="using:JellyBox" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" @@ -110,34 +111,36 @@ - +