Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve media context menu #479

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Screenbox.Core/ViewModels/AllVideosPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,5 @@ private void Play(MediaViewModel media)
if (Videos.Count == 0) return;
Messenger.SendQueueAndPlay(media, Videos, true);
}

[RelayCommand]
private void PlayNext(MediaViewModel media)
{
Messenger.SendPlayNext(media);
}
}
}
7 changes: 7 additions & 0 deletions Screenbox.Core/ViewModels/CommonViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Screenbox.Core.Enums;
using Screenbox.Core.Helpers;
using Screenbox.Core.Messages;
using Screenbox.Core.Services;
using System;
Expand Down Expand Up @@ -82,6 +83,12 @@ public bool TryGetPageState(string pageTypeName, int backStackDepth, out object
return _pageStates.TryGetValue(pageTypeName + backStackDepth, out state);
}

[RelayCommand]
private void PlayNext(MediaViewModel media)
{
Messenger.SendPlayNext(media);
}

[RelayCommand]
private void OpenAlbum(AlbumViewModel? album)
{
Expand Down
6 changes: 0 additions & 6 deletions Screenbox.Core/ViewModels/HomePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ private void Play(MediaViewModel media)
}
}

[RelayCommand]
private void PlayNext(MediaViewModel media)
{
Messenger.SendPlayNext(media);
}

[RelayCommand]
private void Remove(MediaViewModel media)
{
Expand Down
6 changes: 0 additions & 6 deletions Screenbox.Core/ViewModels/SongsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,5 @@ private void Play(MediaViewModel media)
if (Songs.Count == 0) return;
Messenger.SendQueueAndPlay(media, Songs);
}

[RelayCommand]
private void PlayNext(MediaViewModel media)
{
Messenger.SendPlayNext(media);
}
}
}
10 changes: 3 additions & 7 deletions Screenbox/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@
<converters:PlayPauseGlyphConverter x:Key="PlayPauseGlyphConverter" />
<toolkitConverters:BoolNegationConverter x:Key="BoolNegationConverter" />
<toolkitConverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<toolkitConverters:BoolToObjectConverter
x:Key="InverseBoolToVisibilityConverter"
FalseValue="Visible"
TrueValue="Collapsed" />
<toolkitConverters:StringVisibilityConverter x:Key="StringVisibilityConverter" />
<toolkitConverters:EmptyObjectToObjectConverter
x:Key="InverseEmptyObjectToVisibilityConverter"
EmptyValue="Visible"
NotEmptyValue="Collapsed" />
x:Key="EmptyObjectToVisibilityConverter"
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
<toolkitConverters:CollectionVisibilityConverter x:Key="CollectionVisibilityConverter" />
<toolkitConverters:DoubleToObjectConverter
x:Key="DoubleToBoolConverter"
Expand Down
2 changes: 1 addition & 1 deletion Screenbox/Controls/CommonGridViewItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<Border
Background="{ThemeResource SolidBackgroundFillColorSecondaryBrush}"
CornerRadius="{x:Bind CornerRadius}"
Visibility="{x:Bind ThumbnailSource, Converter={StaticResource InverseEmptyObjectToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind ThumbnailSource, Converter={StaticResource EmptyObjectToVisibilityConverter}, ConverterParameter=true, Mode=OneWay}">
<IconSourceElement
x:Name="PlaceholderIcon"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Expand Down
12 changes: 12 additions & 0 deletions Screenbox/Controls/PlaylistView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@
CommandParameter="{Binding}"
Icon="{ui:FontIcon Glyph=&#xE946;}"
Text="{strings:Resources Key=Properties}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenAlbumCommand}"
CommandParameter="{Binding Album}"
Icon="{ui:FontIcon Glyph=&#xE93C;}"
Text="Open album"
Visibility="{Binding Album, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenArtistCommand}"
CommandParameter="{Binding MainArtist}"
Icon="{ui:FontIcon Glyph=&#xE77B;}"
Text="Open artist"
Visibility="{Binding MainArtist, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutSeparator Visibility="{x:Bind Common.IsAdvancedModeEnabled}" />
<MenuFlyoutItem
CommandParameter="{Binding}"
Expand Down
2 changes: 1 addition & 1 deletion Screenbox/Controls/SeekBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
Style="{StaticResource DefaultSliderStyle}"
ThumbToolTipValueConverter="{StaticResource HumanizedDurationConverter}"
ValueChanged="{x:Bind ViewModel.OnSeekBarValueChanged}"
Visibility="{x:Bind ProgressOnly, Mode=OneWay, Converter={StaticResource InverseBoolToVisibilityConverter}}"
Visibility="{x:Bind ProgressOnly, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=true}"
Value="{x:Bind ViewModel.Time, Mode=OneWay}" />
</Grid>
</UserControl>
40 changes: 39 additions & 1 deletion Screenbox/Pages/AlbumDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="Screenbox.Pages.AlbumDetailsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="using:Screenbox.Commands"
xmlns:controls="using:Screenbox.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="using:Screenbox.Controls.Extensions"
Expand All @@ -23,6 +24,42 @@
</ResourceDictionary.MergedDictionaries>

<ThemeShadow x:Name="SharedShadow" />

<MenuFlyout x:Name="ItemFlyout">
<MenuFlyoutItem
Command="{x:Bind ViewModel.PlayCommand}"
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Play}"
Text="{strings:Resources Key=Play}" />
<MenuFlyoutItem
Command="{x:Bind Common.PlayNextCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon FontFamily={StaticResource ScreenboxSymbolThemeFontFamily},
Glyph=&#xF5EB;}"
Text="{strings:Resources Key=PlayNext}" />
<MenuFlyoutSeparator />
<MenuFlyoutItem
Command="{StaticResource ShowPropertiesCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon Glyph=&#xE946;}"
Text="{strings:Resources Key=Properties}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenArtistCommand}"
CommandParameter="{Binding MainArtist}"
Icon="{ui:FontIcon Glyph=&#xE77B;}"
Text="{strings:Resources Key=ShowArtist}"
Visibility="{Binding MainArtist, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutSeparator Visibility="{x:Bind Common.IsAdvancedModeEnabled}" />
<MenuFlyoutItem
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Setting}"
Text="{strings:Resources Key=SetPlaybackOptions}"
Visibility="{x:Bind Common.IsAdvancedModeEnabled}">
<MenuFlyoutItem.Command>
<commands:SetPlaybackOptionsCommand PlayCommand="{x:Bind ViewModel.PlayCommand}" />
</MenuFlyoutItem.Command>
</MenuFlyoutItem>
</MenuFlyout>
</ResourceDictionary>
</Page.Resources>

Expand Down Expand Up @@ -81,7 +118,7 @@
<Border
Background="{ThemeResource SolidBackgroundFillColorSecondaryBrush}"
CornerRadius="{x:Bind CoverArt.CornerRadius, Mode=OneWay}"
Visibility="{x:Bind ViewModel.Source.AlbumArt, Mode=OneWay, Converter={StaticResource InverseEmptyObjectToVisibilityConverter}}">
Visibility="{x:Bind ViewModel.Source.AlbumArt, Mode=OneWay, Converter={StaticResource EmptyObjectToVisibilityConverter}, ConverterParameter=true}">
<FontIcon
x:Name="CoverArtIcon"
FontSize="64"
Expand Down Expand Up @@ -215,6 +252,7 @@
AlternateBackground="{ThemeResource CardBackgroundFillColorDefaultBrush}"
AlternateBorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
AlternateBorderThickness="1" />
<interactions:ListViewContextTriggerBehavior Flyout="{x:Bind ItemFlyout}" />
<interactions:BringIntoViewWithOffsetBehavior FromBottom="{x:Bind Common.FooterBottomPaddingHeight, Mode=OneWay}" />
<interactions:FocusOnItemClickBehavior />
</interactivity:Interaction.Behaviors>
Expand Down
4 changes: 1 addition & 3 deletions Screenbox/Pages/AllVideosPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="using:Screenbox.Commands"
xmlns:controls="using:Screenbox.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Screenbox.Controls.Interactions"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
Expand All @@ -12,7 +11,6 @@
xmlns:strings="using:Screenbox.Strings"
xmlns:triggers="using:CommunityToolkit.WinUI"
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:viewModels="using:Screenbox.Core.ViewModels"
mc:Ignorable="d">

<Page.Resources>
Expand All @@ -28,7 +26,7 @@
Icon="{ui:SymbolIcon Symbol=Play}"
Text="{strings:Resources Key=Play}" />
<MenuFlyoutItem
Command="{x:Bind ViewModel.PlayNextCommand}"
Command="{x:Bind Common.PlayNextCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon FontFamily={StaticResource ScreenboxSymbolThemeFontFamily},
Glyph=&#xF5EB;}"
Expand Down
40 changes: 39 additions & 1 deletion Screenbox/Pages/ArtistDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="Screenbox.Pages.ArtistDetailsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="using:Screenbox.Commands"
xmlns:controls="using:Screenbox.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="using:Screenbox.Controls.Extensions"
Expand Down Expand Up @@ -52,7 +53,7 @@
<Border
Background="{ThemeResource SolidBackgroundFillColorSecondaryBrush}"
CornerRadius="{StaticResource ControlCornerRadius}"
Visibility="{Binding Key.AlbumArt, Converter={StaticResource InverseEmptyObjectToVisibilityConverter}}">
Visibility="{Binding Key.AlbumArt, Converter={StaticResource EmptyObjectToVisibilityConverter}, ConverterParameter=true}">
<FontIcon
x:Name="AlbumArtIcon"
FontSize="{StaticResource GridItemPlaceholderIconFontSize}"
Expand Down Expand Up @@ -111,6 +112,42 @@
</StackPanel>
</UserControl>
</DataTemplate>

<MenuFlyout x:Name="ItemFlyout">
<MenuFlyoutItem
Command="{x:Bind ViewModel.PlayCommand}"
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Play}"
Text="{strings:Resources Key=Play}" />
<MenuFlyoutItem
Command="{x:Bind Common.PlayNextCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon FontFamily={StaticResource ScreenboxSymbolThemeFontFamily},
Glyph=&#xF5EB;}"
Text="{strings:Resources Key=PlayNext}" />
<MenuFlyoutSeparator />
<MenuFlyoutItem
Command="{StaticResource ShowPropertiesCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon Glyph=&#xE946;}"
Text="{strings:Resources Key=Properties}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenAlbumCommand}"
CommandParameter="{Binding Album}"
Icon="{ui:FontIcon Glyph=&#xE93C;}"
Text="{strings:Resources Key=ShowAlbum}"
Visibility="{Binding Album, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutSeparator Visibility="{x:Bind Common.IsAdvancedModeEnabled}" />
<MenuFlyoutItem
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Setting}"
Text="{strings:Resources Key=SetPlaybackOptions}"
Visibility="{x:Bind Common.IsAdvancedModeEnabled}">
<MenuFlyoutItem.Command>
<commands:SetPlaybackOptionsCommand PlayCommand="{x:Bind ViewModel.PlayCommand}" />
</MenuFlyoutItem.Command>
</MenuFlyoutItem>
</MenuFlyout>
</ResourceDictionary>
</Page.Resources>

Expand Down Expand Up @@ -332,6 +369,7 @@
AlternateBackground="{ThemeResource CardBackgroundFillColorDefaultBrush}"
AlternateBorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
AlternateBorderThickness="1" />
<interactions:ListViewContextTriggerBehavior Flyout="{x:Bind ItemFlyout}" />
<interactions:BringIntoViewWithOffsetBehavior FromBottom="{x:Bind Common.FooterBottomPaddingHeight, Mode=OneWay}" />
<interactions:FocusOnItemClickBehavior />
</interactivity:Interaction.Behaviors>
Expand Down
14 changes: 13 additions & 1 deletion Screenbox/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Icon="{ui:SymbolIcon Symbol=Play}"
Text="{strings:Resources Key=Play}" />
<MenuFlyoutItem
Command="{x:Bind ViewModel.PlayNextCommand}"
Command="{x:Bind Common.PlayNextCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon FontFamily={StaticResource ScreenboxSymbolThemeFontFamily},
Glyph=&#xF5EB;}"
Expand All @@ -46,6 +46,18 @@
CommandParameter="{Binding}"
Icon="{ui:FontIcon Glyph=&#xE946;}"
Text="{strings:Resources Key=Properties}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenAlbumCommand}"
CommandParameter="{Binding Album}"
Icon="{ui:FontIcon Glyph=&#xE93C;}"
Text="{strings:Resources Key=ShowAlbum}"
Visibility="{Binding Album, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenArtistCommand}"
CommandParameter="{Binding MainArtist}"
Icon="{ui:FontIcon Glyph=&#xE77B;}"
Text="{strings:Resources Key=ShowArtist}"
Visibility="{Binding MainArtist, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutSeparator Visibility="{x:Bind Common.IsAdvancedModeEnabled}" />
<MenuFlyoutItem
CommandParameter="{Binding}"
Expand Down
2 changes: 1 addition & 1 deletion Screenbox/Pages/PlayerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
<Border
Background="{ThemeResource SolidBackgroundFillColorSecondaryBrush}"
CornerRadius="{x:Bind AlbumArt.CornerRadius, Mode=OneWay}"
Visibility="{x:Bind ViewModel.Media.Thumbnail, Mode=OneWay, Converter={StaticResource InverseEmptyObjectToVisibilityConverter}}">
Visibility="{x:Bind ViewModel.Media.Thumbnail, Mode=OneWay, Converter={StaticResource EmptyObjectToVisibilityConverter}, ConverterParameter=true}">
<FontIcon
x:Name="AlbumArtGlyph"
FontSize="80"
Expand Down
44 changes: 43 additions & 1 deletion Screenbox/Pages/Search/SearchResultPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,48 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Controls/Templates/GridViewItemTemplates.xaml" />
</ResourceDictionary.MergedDictionaries>

<MenuFlyout x:Name="ItemFlyout">
<MenuFlyoutItem
Command="{x:Bind ViewModel.PlayCommand}"
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Play}"
Text="{strings:Resources Key=Play}" />
<MenuFlyoutItem
Command="{x:Bind Common.PlayNextCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon FontFamily={StaticResource ScreenboxSymbolThemeFontFamily},
Glyph=&#xF5EB;}"
Text="{strings:Resources Key=PlayNext}" />
<MenuFlyoutSeparator />
<MenuFlyoutItem
Command="{StaticResource ShowPropertiesCommand}"
CommandParameter="{Binding}"
Icon="{ui:FontIcon Glyph=&#xE946;}"
Text="{strings:Resources Key=Properties}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenAlbumCommand}"
CommandParameter="{Binding Album}"
Icon="{ui:FontIcon Glyph=&#xE93C;}"
Text="{strings:Resources Key=ShowAlbum}"
Visibility="{Binding Album, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutItem
Command="{x:Bind Common.OpenArtistCommand}"
CommandParameter="{Binding MainArtist}"
Icon="{ui:FontIcon Glyph=&#xE77B;}"
Text="{strings:Resources Key=ShowArtist}"
Visibility="{Binding MainArtist, Converter={StaticResource EmptyObjectToVisibilityConverter}}" />
<MenuFlyoutSeparator Visibility="{x:Bind Common.IsAdvancedModeEnabled}" />
<MenuFlyoutItem
CommandParameter="{Binding}"
Icon="{ui:SymbolIcon Symbol=Setting}"
Text="{strings:Resources Key=SetPlaybackOptions}"
Visibility="{x:Bind Common.IsAdvancedModeEnabled}">
<MenuFlyoutItem.Command>
<commands:SetPlaybackOptionsCommand PlayCommand="{x:Bind ViewModel.PlayCommand}" />
</MenuFlyoutItem.Command>
</MenuFlyoutItem>
</MenuFlyout>
</ResourceDictionary>
</Page.Resources>

Expand Down Expand Up @@ -156,7 +198,7 @@
AlternateBackground="{ThemeResource CardBackgroundFillColorDefaultBrush}"
AlternateBorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
AlternateBorderThickness="1" />
<!-- <interactions:ListViewContextTriggerBehavior Flyout="{x:Bind ItemFlyout}" /> -->
<interactions:ListViewContextTriggerBehavior Flyout="{x:Bind ItemFlyout}" />
</interactivity:Interaction.Behaviors>
</ListView>
</StackPanel>
Expand Down
Loading
Loading