feat(ui): show the tag count beside the add-tag button

This commit is contained in:
yyc12345 committed 2026-10-05 12:09:52 +08:00
1 parent da2a73d70f
commit a9e97d9b35
4 files changed
+24 -7

No files matched your search

+3
View File
@@ -184,6 +184,9 @@
<data name="Tags_AddTag" xml:space="preserve">
<value>Add Tag</value>
</data>
<data name="Tags_Count" xml:space="preserve">
<value>{0} tags</value>
</data>
<data name="Tags_Empty" xml:space="preserve">
<value>No tags yet.</value>
</data>
@@ -184,6 +184,9 @@
<data name="Tags_AddTag" xml:space="preserve">
<value>添加标签</value>
</data>
<data name="Tags_Count" xml:space="preserve">
<value>{0} 个标签</value>
</data>
<data name="Tags_Empty" xml:space="preserve">
<value>还没有标签。</value>
</data>
+8
View File
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Globalization;
using CommunityToolkit.Mvvm.Input;
@@ -47,6 +48,12 @@ public sealed partial class TagsViewModel : ViewModelBase {
/// </summary>
public bool HasNoTags => Tags.Count == 0;
/// <summary>
/// Gets the localized total number of tags shown next to the add button.
/// </summary>
public string TagCountText => string.Format(
Resources.Culture ?? CultureInfo.CurrentCulture, Resources.Tags_Count, Tags.Count);
/// <summary>
/// Gets the interaction that opens the new-tag editor.
/// </summary>
@@ -93,6 +100,7 @@ public sealed partial class TagsViewModel : ViewModelBase {
OnPropertyChanged(nameof(HasTags));
OnPropertyChanged(nameof(HasNoTags));
OnPropertyChanged(nameof(TagCountText));
}
/// <summary>
+10 -7
View File
@@ -11,13 +11,16 @@
<Grid RowDefinitions="Auto,*" Margin="8">
<Button Grid.Row="0" Command="{Binding AddNewTagCommand}"
HorizontalAlignment="Right" Margin="0,0,0,8">
<StackPanel Orientation="Horizontal" Spacing="6">
<icons:PackIconLucide Kind="Plus" Width="16" Height="16"/>
<TextBlock Text="{x:Static lang:Resources.Tags_AddTag}"/>
</StackPanel>
</Button>
<Grid Grid.Row="0" ColumnDefinitions="*,Auto" Margin="0,0,0,8">
<TextBlock Grid.Column="0" Text="{Binding TagCountText}"
VerticalAlignment="Center" Opacity="0.6" FontSize="13"/>
<Button Grid.Column="1" Command="{Binding AddNewTagCommand}">
<StackPanel Orientation="Horizontal" Spacing="6">
<icons:PackIconLucide Kind="Plus" Width="16" Height="16"/>
<TextBlock Text="{x:Static lang:Resources.Tags_AddTag}"/>
</StackPanel>
</Button>
</Grid>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Tags}">