Skip to content

Commit 6bf930a

Browse files
committed
feature: show tags count in tags tree (#1306)
Signed-off-by: leo <[email protected]>
1 parent 5b72b15 commit 6bf930a

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/ViewModels/BranchTreeNode.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ public string BranchesCount
5656

5757
public string Tooltip
5858
{
59-
get => Backend is Models.Branch b ?
60-
b.FriendlyName : (Backend is Models.Remote r ? r.URL : null);
59+
get
60+
{
61+
if (Backend is Models.Branch b)
62+
return b.FriendlyName;
63+
64+
if (Backend is Models.Remote r)
65+
return r.URL;
66+
67+
return null;
68+
}
6169
}
6270

6371
private Models.FilterMode _filterMode = Models.FilterMode.None;

src/ViewModels/TagCollection.cs

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class TagTreeNode : ObservableObject
2626
public Models.Tag Tag { get; private set; } = null;
2727
public TagTreeNodeToolTip ToolTip { get; private set; } = null;
2828
public List<TagTreeNode> Children { get; private set; } = [];
29+
public int Counter { get; set; } = 0;
2930

3031
public bool IsFolder
3132
{
@@ -38,6 +39,11 @@ public bool IsExpanded
3839
set => SetProperty(ref _isExpanded, value);
3940
}
4041

42+
public string TagsCount
43+
{
44+
get => Counter > 0 ? $"({Counter})" : string.Empty;
45+
}
46+
4147
public TagTreeNode(Models.Tag t, int depth)
4248
{
4349
FullPath = t.Name;
@@ -52,6 +58,7 @@ public TagTreeNode(string path, bool isExpanded, int depth)
5258
FullPath = path;
5359
Depth = depth;
5460
IsExpanded = isExpanded;
61+
Counter = 1;
5562
}
5663

5764
public static List<TagTreeNode> Build(IList<Models.Tag> tags, HashSet<string> expaneded)
@@ -77,6 +84,7 @@ public static List<TagTreeNode> Build(IList<Models.Tag> tags, HashSet<string> ex
7784
if (folders.TryGetValue(folder, out var value))
7885
{
7986
lastFolder = value;
87+
lastFolder.Counter++;
8088
}
8189
else if (lastFolder == null)
8290
{

src/Views/TagsView.axaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
3535
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
3636
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
37-
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
37+
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Classes="primary" Margin="4,0" Foreground="White"/>
3838
</Border>
3939
</StackPanel>
4040

@@ -59,8 +59,10 @@
5959

6060
<TextBlock Grid.Column="2"
6161
Classes="primary"
62-
Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"
63-
Margin="8,0,0,0"/>
62+
Margin="8,0,0,0">
63+
<Run Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"/>
64+
<Run Text="{Binding TagsCount}" Foreground="{DynamicResource Brush.FG2}"/>
65+
</TextBlock>
6466

6567
<ContentControl Grid.Column="3" Content="{Binding Tag}">
6668
<ContentControl.DataTemplates>
@@ -91,7 +93,7 @@
9193
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
9294
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
9395
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
94-
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Classes="primary" Margin="4,0" Foreground="#FFDDDDDD"/>
96+
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Classes="primary" Margin="4,0" Foreground="White"/>
9597
</Border>
9698
</StackPanel>
9799

0 commit comments

Comments
 (0)