mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 13:51:53 +08:00
ux: change icon color for worktree-linked branch (#1761)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -43,19 +43,20 @@
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Branch}"/>
|
||||
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Margin="8,0,0,0" Text="{Binding FriendlyName}"/>
|
||||
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding !IsLocal}">
|
||||
<TextBlock Text="{DynamicResource Text.BranchTree.Remote}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<Border Background="Gray" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center">
|
||||
<Border.IsVisible>
|
||||
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Margin="4,0,0,0" Text="{Binding FriendlyName}"/>
|
||||
<TextBlock Classes="primary" FontSize="12" Margin="4,0" VerticalAlignment="Center">
|
||||
<TextBlock.IsVisible>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="IsCurrent" Converter="{x:Static BoolConverters.Not}"/>
|
||||
<Binding Path="WorktreePath" Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/>
|
||||
</MultiBinding>
|
||||
</Border.IsVisible>
|
||||
|
||||
<TextBlock Text="{Binding WorktreePath, Mode=OneWay}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
|
||||
</TextBlock.IsVisible>
|
||||
<Run Text="("/>
|
||||
<Run Text="{Binding WorktreePath, Mode=OneWay}" TextDecorations="Underline"/>
|
||||
<Run Text=")"/>
|
||||
</TextBlock>
|
||||
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding !IsLocal}">
|
||||
<TextBlock Text="{DynamicResource Text.BranchTree.Remote}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -50,25 +50,27 @@ namespace SourceGit.Views
|
||||
|
||||
if (node.Backend is Models.Remote)
|
||||
{
|
||||
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Remote", false);
|
||||
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Remote");
|
||||
}
|
||||
else if (node.Backend is Models.Branch branch)
|
||||
{
|
||||
if (branch.IsCurrent)
|
||||
CreateContent(new Thickness(0, 0, 0, 0), "Icons.CheckCircled", true);
|
||||
CreateContent(new Thickness(0, 0, 0, 0), "Icons.CheckCircled", Brushes.Green);
|
||||
else if (branch.IsLocal && !string.IsNullOrEmpty(branch.WorktreePath))
|
||||
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch", Brushes.Cyan);
|
||||
else
|
||||
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch", false);
|
||||
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (node.IsExpanded)
|
||||
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open", false);
|
||||
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open");
|
||||
else
|
||||
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder", false);
|
||||
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder");
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateContent(Thickness margin, string iconKey, bool highlight)
|
||||
private void CreateContent(Thickness margin, string iconKey, IBrush fill = null)
|
||||
{
|
||||
if (this.FindResource(iconKey) is not StreamGeometry geo)
|
||||
return;
|
||||
@@ -83,8 +85,8 @@ namespace SourceGit.Views
|
||||
Data = geo,
|
||||
};
|
||||
|
||||
if (highlight)
|
||||
path.Fill = Brushes.Green;
|
||||
if (fill != null)
|
||||
path.Fill = fill;
|
||||
|
||||
Content = path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user