Skip to content

Commit 5d9740a

Browse files
committed
ux: change icon color for worktree-linked branch (#1761)
Signed-off-by: leo <[email protected]>
1 parent c30202e commit 5d9740a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/Views/BranchTree.axaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@
4343
<StackPanel Orientation="Vertical">
4444
<StackPanel Orientation="Horizontal">
4545
<Path Width="12" Height="12" Data="{StaticResource Icons.Branch}"/>
46-
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Margin="8,0,0,0" Text="{Binding FriendlyName}"/>
47-
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding !IsLocal}">
48-
<TextBlock Text="{DynamicResource Text.BranchTree.Remote}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
49-
</Border>
50-
<Border Background="Gray" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center">
51-
<Border.IsVisible>
46+
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Margin="4,0,0,0" Text="{Binding FriendlyName}"/>
47+
<TextBlock Classes="primary" FontSize="12" Margin="4,0" VerticalAlignment="Center">
48+
<TextBlock.IsVisible>
5249
<MultiBinding Converter="{x:Static BoolConverters.And}">
5350
<Binding Path="IsCurrent" Converter="{x:Static BoolConverters.Not}"/>
5451
<Binding Path="WorktreePath" Converter="{x:Static StringConverters.IsNotNullOrEmpty}"/>
5552
</MultiBinding>
56-
</Border.IsVisible>
57-
58-
<TextBlock Text="{Binding WorktreePath, Mode=OneWay}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
53+
</TextBlock.IsVisible>
54+
<Run Text="("/>
55+
<Run Text="{Binding WorktreePath, Mode=OneWay}" TextDecorations="Underline"/>
56+
<Run Text=")"/>
57+
</TextBlock>
58+
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding !IsLocal}">
59+
<TextBlock Text="{DynamicResource Text.BranchTree.Remote}" FontSize="12" Classes="primary" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
5960
</Border>
6061
</StackPanel>
6162

src/Views/BranchTree.axaml.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,27 @@ private void UpdateContent()
5050

5151
if (node.Backend is Models.Remote)
5252
{
53-
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Remote", false);
53+
CreateContent(new Thickness(0, 0, 0, 0), "Icons.Remote");
5454
}
5555
else if (node.Backend is Models.Branch branch)
5656
{
5757
if (branch.IsCurrent)
58-
CreateContent(new Thickness(0, 0, 0, 0), "Icons.CheckCircled", true);
58+
CreateContent(new Thickness(0, 0, 0, 0), "Icons.CheckCircled", Brushes.Green);
59+
else if (branch.IsLocal && !string.IsNullOrEmpty(branch.WorktreePath))
60+
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch", Brushes.Cyan);
5961
else
60-
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch", false);
62+
CreateContent(new Thickness(2, 0, 0, 0), "Icons.Branch");
6163
}
6264
else
6365
{
6466
if (node.IsExpanded)
65-
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open", false);
67+
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder.Open");
6668
else
67-
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder", false);
69+
CreateContent(new Thickness(0, 2, 0, 0), "Icons.Folder");
6870
}
6971
}
7072

71-
private void CreateContent(Thickness margin, string iconKey, bool highlight)
73+
private void CreateContent(Thickness margin, string iconKey, IBrush fill = null)
7274
{
7375
if (this.FindResource(iconKey) is not StreamGeometry geo)
7476
return;
@@ -83,8 +85,8 @@ private void CreateContent(Thickness margin, string iconKey, bool highlight)
8385
Data = geo,
8486
};
8587

86-
if (highlight)
87-
path.Fill = Brushes.Green;
88+
if (fill != null)
89+
path.Fill = fill;
8890

8991
Content = path;
9092
}

0 commit comments

Comments
 (0)