Skip to content

Commit 6768239

Browse files
committed
Add SingleSongDetailsPopupView for song metadata display
Introduced a new UserControl (SingleSongDetailsPopupView) with XAML and code-behind to show detailed metadata for a selected song. The view binds to a view model and displays fields such as cover image, title, artist, album, genre, file path, creation date, bit depth, bitrate, duration, format, size, lyrics info, play count, and release year. Includes event handling for popup dismissal and file path navigation.
1 parent 3f1c35f commit 6768239

File tree

2 files changed

+327
-0
lines changed

2 files changed

+327
-0
lines changed
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<UserControl
3+
x:Class="Dimmer.WinUI.Views.CustomViews.WinuiViews.SingleSongDetailsPopupView"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:Dimmer.WinUI.Views.CustomViews.WinuiViews"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d">
10+
11+
<Grid
12+
>
13+
<Grid.Background>
14+
<SolidColorBrush Opacity="0.8" Color="#1e1e1e"/>
15+
</Grid.Background>
16+
17+
<ScrollViewer MaxHeight="500" MaxWidth="700"
18+
Background="Black"
19+
CornerRadius="20" Padding="15">
20+
21+
<StackPanel
22+
Spacing="5"
23+
Orientation="Vertical">
24+
25+
<Border >
26+
<Grid>
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="*"/>
29+
</Grid.ColumnDefinitions>
30+
<StackPanel HorizontalAlignment="Center" Grid.Column="0">
31+
<Image Source="{x:Bind MyViewModel.SelectedSong.CoverImagePath,
32+
Converter={StaticResource StringToImageConverter}, Mode=OneWay}"
33+
MaxHeight="180"
34+
MaxWidth="180"/>
35+
</StackPanel>
36+
<Button Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top"
37+
Background="Transparent"
38+
Click="ClosePopUp_Click" x:Name="ClosePopUp">
39+
40+
<FontIcon Glyph="&#xE711;" />
41+
</Button>
42+
</Grid>
43+
</Border>
44+
<Border BorderThickness="1"
45+
BorderBrush="Gray"
46+
CornerRadius="10"
47+
Padding="5">
48+
<Grid>
49+
<Grid.ColumnDefinitions>
50+
<ColumnDefinition Width="*"/>
51+
<ColumnDefinition Width="*"/>
52+
</Grid.ColumnDefinitions>
53+
54+
<TextBlock Text="Title" Grid.Column="0"/>
55+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.Title, Mode=OneWay}" Grid.Column="1"/>
56+
</Grid>
57+
</Border>
58+
<Border BorderThickness="0.3"
59+
BorderBrush="Gray"
60+
CornerRadius="10"
61+
Padding="5">
62+
<Grid>
63+
<Grid.ColumnDefinitions>
64+
<ColumnDefinition Width="*"/>
65+
<ColumnDefinition Width="*"/>
66+
</Grid.ColumnDefinitions>
67+
68+
<TextBlock Text="Artist" Grid.Column="0"/>
69+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.OtherArtistsName, Mode=OneWay}" Grid.Column="1"/>
70+
</Grid>
71+
</Border>
72+
<Border BorderThickness="1"
73+
BorderBrush="Gray"
74+
CornerRadius="10"
75+
Padding="5">
76+
<Grid>
77+
<Grid.ColumnDefinitions>
78+
<ColumnDefinition Width="*"/>
79+
<ColumnDefinition Width="*"/>
80+
</Grid.ColumnDefinitions>
81+
82+
<TextBlock Text="Album Name" Grid.Column="0"/>
83+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.AlbumName, Mode=OneWay}" Grid.Column="1"/>
84+
</Grid>
85+
</Border>
86+
<Border BorderThickness="1"
87+
BorderBrush="Gray"
88+
CornerRadius="10"
89+
Padding="5">
90+
<Grid>
91+
<Grid.ColumnDefinitions>
92+
<ColumnDefinition Width="*"/>
93+
<ColumnDefinition Width="*"/>
94+
</Grid.ColumnDefinitions>
95+
96+
<TextBlock Text="Genre" Grid.Column="0"/>
97+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.GenreName, Mode=OneWay}" Grid.Column="1"/>
98+
</Grid>
99+
</Border>
100+
<Border BorderThickness="1"
101+
Width="500"
102+
BorderBrush="Gray"
103+
CornerRadius="10"
104+
x:Name="PathView"
105+
PointerPressed="PathView_PointerPressed"
106+
Padding="5">
107+
<Grid>
108+
<Grid.ColumnDefinitions>
109+
<ColumnDefinition Width="*"/>
110+
<ColumnDefinition Width="*"/>
111+
</Grid.ColumnDefinitions>
112+
113+
<TextBlock Text="Path" Grid.Column="0"/>
114+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.FilePath, Mode=OneWay}" Grid.Column="1"/>
115+
</Grid>
116+
</Border>
117+
118+
<Border BorderThickness="1"
119+
BorderBrush="Gray"
120+
CornerRadius="10"
121+
Padding="5">
122+
<Grid>
123+
<Grid.ColumnDefinitions>
124+
<ColumnDefinition Width="*"/>
125+
<ColumnDefinition Width="*"/>
126+
</Grid.ColumnDefinitions>
127+
128+
<TextBlock Text="Date Created" Grid.Column="0"/>
129+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.DateCreated
130+
,Converter={StaticResource EventDateToTimeAgoConverter}, Mode=OneWay}" Grid.Column="1"
131+
ToolTipService.ToolTip="{x:Bind MyViewModel.SelectedSong.DateCreated}"/>
132+
</Grid>
133+
</Border>
134+
<Border BorderThickness="1"
135+
BorderBrush="Gray"
136+
CornerRadius="10"
137+
Padding="5">
138+
<Grid>
139+
<Grid.ColumnDefinitions>
140+
<ColumnDefinition Width="*"/>
141+
<ColumnDefinition Width="*"/>
142+
</Grid.ColumnDefinitions>
143+
144+
<TextBlock Text="Bit Depth" Grid.Column="0"/>
145+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.BitDepth, Mode=OneWay}" Grid.Column="1"/>
146+
</Grid>
147+
</Border>
148+
<Border BorderThickness="1"
149+
BorderBrush="Gray"
150+
CornerRadius="10"
151+
Padding="5">
152+
<Grid>
153+
<Grid.ColumnDefinitions>
154+
<ColumnDefinition Width="*"/>
155+
<ColumnDefinition Width="*"/>
156+
</Grid.ColumnDefinitions>
157+
158+
<TextBlock Text="BitRate" Grid.Column="0"/>
159+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.BitRate, Mode=OneWay}" Grid.Column="1"/>
160+
</Grid>
161+
</Border>
162+
<Border BorderThickness="1"
163+
BorderBrush="Gray"
164+
CornerRadius="10"
165+
Padding="5">
166+
<Grid>
167+
<Grid.ColumnDefinitions>
168+
<ColumnDefinition Width="*"/>
169+
<ColumnDefinition Width="*"/>
170+
</Grid.ColumnDefinitions>
171+
172+
<TextBlock Text="Duration" Grid.Column="0"/>
173+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.DurationFormatted, Mode=OneWay}" Grid.Column="1"/>
174+
</Grid>
175+
</Border>
176+
177+
<Border BorderThickness="1"
178+
BorderBrush="Gray"
179+
CornerRadius="10"
180+
Padding="5">
181+
<Grid>
182+
<Grid.ColumnDefinitions>
183+
<ColumnDefinition Width="*"/>
184+
<ColumnDefinition Width="*"/>
185+
</Grid.ColumnDefinitions>
186+
187+
<TextBlock Text="Format" Grid.Column="0"/>
188+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.FileFormat, Mode=OneWay}" Grid.Column="1"/>
189+
</Grid>
190+
</Border>
191+
192+
<Border BorderThickness="1"
193+
BorderBrush="Gray"
194+
CornerRadius="10"
195+
Padding="5">
196+
<Grid>
197+
<Grid.ColumnDefinitions>
198+
<ColumnDefinition Width="*"/>
199+
<ColumnDefinition Width="*"/>
200+
</Grid.ColumnDefinitions>
201+
202+
<TextBlock Text="Size" Grid.Column="0"/>
203+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.FileSize, Converter={StaticResource BytesToMegabytesConverter}, Mode=OneWay}" Grid.Column="1"/>
204+
</Grid>
205+
</Border>
206+
<Border BorderThickness="1"
207+
BorderBrush="Gray"
208+
CornerRadius="10"
209+
Padding="5">
210+
<Grid>
211+
<Grid.ColumnDefinitions>
212+
<ColumnDefinition Width="*"/>
213+
<ColumnDefinition Width="*"/>
214+
</Grid.ColumnDefinitions>
215+
216+
<TextBlock Text="Has Plain Lyrics" Grid.Column="0"/>
217+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.HasLyrics, Mode=OneWay}" Grid.Column="1"/>
218+
</Grid>
219+
</Border>
220+
<Border BorderThickness="1"
221+
BorderBrush="Gray"
222+
CornerRadius="10"
223+
Padding="5">
224+
<Grid>
225+
<Grid.ColumnDefinitions>
226+
<ColumnDefinition Width="*"/>
227+
<ColumnDefinition Width="*"/>
228+
</Grid.ColumnDefinitions>
229+
230+
<TextBlock Text="Has Synced Lyrics" Grid.Column="0"/>
231+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.HasSyncedLyrics, Mode=OneWay}" Grid.Column="1"/>
232+
</Grid>
233+
</Border>
234+
<Border BorderThickness="1"
235+
BorderBrush="Gray"
236+
CornerRadius="10"
237+
Padding="5">
238+
<Grid>
239+
<Grid.ColumnDefinitions>
240+
<ColumnDefinition Width="*"/>
241+
<ColumnDefinition Width="*"/>
242+
</Grid.ColumnDefinitions>
243+
244+
<TextBlock Text="Play Completed Count" Grid.Column="0"/>
245+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.PlayCompletedCount, Mode=OneWay}" Grid.Column="1"/>
246+
</Grid>
247+
</Border>
248+
<Border BorderThickness="1"
249+
BorderBrush="Gray"
250+
CornerRadius="10"
251+
Padding="5">
252+
<Grid>
253+
<Grid.ColumnDefinitions>
254+
<ColumnDefinition Width="*"/>
255+
<ColumnDefinition Width="*"/>
256+
</Grid.ColumnDefinitions>
257+
258+
<TextBlock Text="Release Year" Grid.Column="0"/>
259+
<TextBlock Text="{x:Bind MyViewModel.SelectedSong.ReleaseYear, Mode=OneWay}" Grid.Column="1"/>
260+
</Grid>
261+
</Border>
262+
</StackPanel>
263+
</ScrollViewer>
264+
265+
</Grid>
266+
</UserControl>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Microsoft.UI.Xaml;
7+
using Microsoft.UI.Xaml.Controls;
8+
using Microsoft.UI.Xaml.Controls.Primitives;
9+
using Microsoft.UI.Xaml.Data;
10+
using Microsoft.UI.Xaml.Input;
11+
using Microsoft.UI.Xaml.Media;
12+
using Microsoft.UI.Xaml.Navigation;
13+
using Windows.Foundation;
14+
using Windows.Foundation.Collections;
15+
16+
// To learn more about WinUI, the WinUI project structure,
17+
// and more about our project templates, see: http://aka.ms/winui-project-info.
18+
19+
namespace Dimmer.WinUI.Views.CustomViews.WinuiViews;
20+
21+
public sealed partial class SingleSongDetailsPopupView : UserControl
22+
{
23+
public SingleSongDetailsPopupView()
24+
{
25+
InitializeComponent();
26+
}
27+
28+
/// <summary>
29+
/// Invoked after popup is closed
30+
/// Bool argument represents whether we navigate after dismissal
31+
/// string argument represents where to/what
32+
/// </summary>
33+
public event EventHandler<PopupDismissedEventArgs> DismissedRequested;
34+
35+
36+
BaseViewModelWin MyViewModel { get; set; }
37+
38+
public void SetBaseViewModelWin(BaseViewModelWin vm)
39+
{
40+
MyViewModel = vm;
41+
}
42+
43+
private void ClosePopUp_Click(object sender, RoutedEventArgs e)
44+
{
45+
PopupDismissedEventArgs evt = new()
46+
{
47+
HasActionAfterDismissed = false
48+
};
49+
50+
DismissedRequested?.Invoke(this,evt);
51+
}
52+
53+
private void PathView_PointerPressed(object sender, PointerRoutedEventArgs e)
54+
{
55+
//DismissedRequested?.Invoke(this, false);
56+
MyViewModel.OpenAndSelectFileInExplorer(MyViewModel.SelectedSong!);
57+
}
58+
}
59+
60+
61+

0 commit comments

Comments
 (0)