enhance: different icons for annotated and lightweight tags (#1942)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-12-01 14:16:06 +08:00
parent 9713a59268
commit 6809eaf2bd
2 changed files with 35 additions and 8 deletions

View File

@@ -87,7 +87,17 @@
<Path Grid.Column="0"
Margin="8,0,0,0"
Width="12" Height="12"
Data="{StaticResource Icons.Tag}"/>
Data="{StaticResource Icons.Tag}"
IsVisible="{Binding Tag.IsAnnotated}"/>
<Path Grid.Column="0"
Margin="8,0,0,0"
Width="12" Height="12"
Data="{StaticResource Icons.Tag}"
Fill="Transparent"
Stroke="{DynamicResource Brush.FG1}"
StrokeThickness="1"
IsVisible="{Binding !Tag.IsAnnotated}"/>
<TextBlock Grid.Column="1"
Text="{Binding Tag.Name}"
@@ -105,8 +115,16 @@
<DataTemplate DataType="vm:TagToolTip">
<StackPanel Orientation="Vertical" Spacing="6">
<StackPanel Orientation="Horizontal">
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Name}"/>
<Path Width="12" Height="12"
Data="{StaticResource Icons.Tag}"
IsVisible="{Binding IsAnnotated}"/>
<Path Width="12" Height="12"
Data="{StaticResource Icons.Tag}"
Fill="Transparent"
Stroke="{DynamicResource Brush.FG1}"
StrokeThickness="1"
IsVisible="{Binding !IsAnnotated}"/>
<TextBlock FontWeight="Bold" Margin="6,0,0,0" Text="{Binding Name}"/>
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" IsVisible="{Binding IsAnnotated}">
<TextBlock Text="{DynamicResource Text.CreateTag.Type.Annotated}" Margin="4,0" Foreground="White"/>
</Border>

View File

@@ -63,19 +63,19 @@ namespace SourceGit.Views
}
if (node.Tag != null)
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Tag");
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Tag", node.ToolTip is { IsAnnotated: false });
else if (node.IsExpanded)
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open");
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open", false);
else
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder");
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder", false);
}
private void CreateContent(Thickness margin, string iconKey)
private void CreateContent(Thickness margin, string iconKey, bool stroke)
{
if (this.FindResource(iconKey) is not StreamGeometry geo)
return;
Content = new Avalonia.Controls.Shapes.Path()
var path = new Avalonia.Controls.Shapes.Path()
{
Width = 12,
Height = 12,
@@ -84,6 +84,15 @@ namespace SourceGit.Views
Margin = margin,
Data = geo,
};
if (stroke)
{
path.Fill = Brushes.Transparent;
path.Stroke = this.FindResource("Brush.FG1") as IBrush;
path.StrokeThickness = 1;
}
Content = path;
}
}