feat(library): simplify the library page and fit columns to their text
GridColumns widens text columns to the longest entry over all rows, since the lists are virtualized and the built-in auto width only sees visible rows. The page loses its license and attribution columns, gets Enter and Delete on the list, and is in German. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
b8f5a3e469
commit
d7388fbfc3
4 files changed
+121
-29
No files matched your search
@@ -2,7 +2,9 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
Title="Library"
|
||||
Title="Bibliothek"
|
||||
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
Loaded="OnLoaded">
|
||||
<Grid Margin="24">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -11,26 +13,24 @@
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:TextBlock Grid.Row="0" FontTypography="Title" Text="Library" />
|
||||
|
||||
<DockPanel Grid.Row="1" Margin="0,16,0,12" LastChildFill="True">
|
||||
<DockPanel Grid.Row="1" Margin="0,0,0,12" LastChildFill="True">
|
||||
<ui:Button x:Name="DeleteButton"
|
||||
DockPanel.Dock="Right"
|
||||
Margin="8,0,0,0"
|
||||
Content="Delete"
|
||||
Content="Löschen"
|
||||
Icon="{ui:SymbolIcon Delete24}"
|
||||
IsEnabled="False"
|
||||
Click="OnDelete" />
|
||||
<ui:Button x:Name="EditButton"
|
||||
DockPanel.Dock="Right"
|
||||
Margin="8,0,0,0"
|
||||
Content="Edit"
|
||||
Content="Bearbeiten"
|
||||
Icon="{ui:SymbolIcon Edit24}"
|
||||
IsEnabled="False"
|
||||
Click="OnEdit" />
|
||||
<ui:TextBox x:Name="SearchBox"
|
||||
AutomationProperties.Name="Search songs"
|
||||
PlaceholderText="Search title or artist"
|
||||
AutomationProperties.Name="Songs suchen"
|
||||
PlaceholderText="Titel oder Interpret suchen"
|
||||
Icon="{ui:SymbolIcon Search24}"
|
||||
TextChanged="OnSearchChanged" />
|
||||
</DockPanel>
|
||||
@@ -40,18 +40,17 @@
|
||||
SelectionMode="Single"
|
||||
AutomationProperties.Name="Songs"
|
||||
SelectionChanged="OnSelectionChanged"
|
||||
MouseDoubleClick="OnEdit">
|
||||
MouseDoubleClick="OnEdit"
|
||||
KeyDown="OnListKeyDown">
|
||||
<ui:ListView.View>
|
||||
<ui:GridView>
|
||||
<ui:GridViewColumn Width="260" Header="Title" DisplayMemberBinding="{Binding Title}" />
|
||||
<ui:GridViewColumn Width="200" Header="Artist" DisplayMemberBinding="{Binding Artist}" />
|
||||
<ui:GridViewColumn Width="80" Header="Duration">
|
||||
<ui:GridViewColumn Width="220" Header="Titel" DisplayMemberBinding="{Binding Title}" />
|
||||
<ui:GridViewColumn Width="160" Header="Interpret" DisplayMemberBinding="{Binding Artist}" />
|
||||
<ui:GridViewColumn Width="80" Header="Dauer">
|
||||
<ui:GridViewColumn.DisplayMemberBinding>
|
||||
<Binding Path="Duration" StringFormat="m\:ss" />
|
||||
</ui:GridViewColumn.DisplayMemberBinding>
|
||||
</ui:GridViewColumn>
|
||||
<ui:GridViewColumn Width="140" Header="License" DisplayMemberBinding="{Binding License}" />
|
||||
<ui:GridViewColumn Width="220" Header="Attribution" DisplayMemberBinding="{Binding Attribution}" />
|
||||
</ui:GridView>
|
||||
</ui:ListView.View>
|
||||
</ui:ListView>
|
||||
@@ -61,7 +60,7 @@
|
||||
Margin="0,48,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
Text="No songs found."
|
||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||
Visibility="Collapsed" />
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -27,9 +27,19 @@ public partial class LibraryPage : Page
|
||||
{
|
||||
var songs = _controller.Search(SearchBox.Text);
|
||||
SongList.ItemsSource = songs;
|
||||
GridColumns.Fit(SongList);
|
||||
EmptyText.Text = string.IsNullOrWhiteSpace(SearchBox.Text)
|
||||
? "Noch keine Songs. Musik auf der Seite Import hinzufĂĽgen."
|
||||
: "Kein Song passt zur Suche.";
|
||||
EmptyText.Visibility = songs.Count == 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void OnListKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == System.Windows.Input.Key.Enter) OnEdit(sender, e);
|
||||
else if (e.Key == System.Windows.Input.Key.Delete) OnDelete(sender, e);
|
||||
}
|
||||
|
||||
private void OnEdit(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Selected is not { } song)
|
||||
@@ -48,10 +58,10 @@ public partial class LibraryPage : Page
|
||||
|
||||
var result = await new MessageBox
|
||||
{
|
||||
Title = "Delete song",
|
||||
Content = $"Delete \"{song.Title}\" by {song.Artist} from the library?",
|
||||
PrimaryButtonText = "Delete",
|
||||
CloseButtonText = "Cancel",
|
||||
Title = "Song löschen",
|
||||
Content = $"\"{song.Title}\" von {song.Artist} aus der Bibliothek löschen?",
|
||||
PrimaryButtonText = "Löschen",
|
||||
CloseButtonText = "Abbrechen",
|
||||
}.ShowDialogAsync();
|
||||
|
||||
if (result != Wpf.Ui.Controls.MessageBoxResult.Primary)
|
||||
|
||||
Reference in new issue
Block a user