feature: show current branch on toolbar (#283)

* re-arrange toolbar buttons
* move `Navigate to HEAD` button to toolbar
This commit is contained in:
leo 2024-07-24 16:35:35 +08:00
parent 6f317039ab
commit e29d78e2ae
No known key found for this signature in database
2 changed files with 44 additions and 12 deletions

View file

@ -76,7 +76,7 @@
</ListBox.ItemsPanel>
<ListBoxItem>
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto,Auto">
<Grid Classes="view_mode" ColumnDefinitions="32,*,Auto">
<Path Grid.Column="0" Width="12" Height="12" Data="{StaticResource Icons.Histories}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.Histories}"/>
<ToggleButton Grid.Column="2"
@ -84,9 +84,6 @@
Width="32" Height="26"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseTwoColumnsLayoutInHistories, Mode=TwoWay}"
ToolTip.Tip="{DynamicResource Text.Histories.DisplayMode}"/>
<Button Grid.Column="3" Classes="icon_button" Width="32" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Target}" Fill="{DynamicResource Brush.FG1}"/>
</Button>
</Grid>
</ListBoxItem>

View file

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.RepositoryToolbar"
@ -19,6 +20,19 @@
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
</Button>
<Rectangle Width="1" Height="16"
Margin="8,0"
VerticalAlignment="Center"
Fill="{DynamicResource Brush.Border2}"/>
<Button Classes="icon_button" Width="32" Click="OpenStatistics" ToolTip.Tip="{DynamicResource Text.Repository.Statistics}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Statistics}"/>
</Button>
<Button Classes="icon_button" Width="32" Command="{Binding OpenConfigure}" ToolTip.Tip="{DynamicResource Text.Repository.Configure}">
<Path Width="15" Height="15" Data="{StaticResource Icons.Settings}"/>
</Button>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
@ -58,19 +72,40 @@
<Button Classes="icon_button" Width="32" Margin="8,0,0,0" Click="OpenGitLFSMenu" ToolTip.Tip="{DynamicResource Text.GitLFS}">
<Path Width="14" Height="14" Data="{StaticResource Icons.LFS}"/>
</Button>
<Rectangle Width="1" Height="16"
Margin="16,0,0,0"
VerticalAlignment="Center"
Fill="{DynamicResource Brush.Border2}"/>
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding Cleanup}" ToolTip.Tip="{DynamicResource Text.Repository.Clean}">
<Path Width="14" Height="14" Margin="0,2,0,0" Data="{StaticResource Icons.Clean}"/>
</Button>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,4,0">
<Button Classes="icon_button" Width="32" Command="{Binding Cleanup}" ToolTip.Tip="{DynamicResource Text.Repository.Clean}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Clean}"/>
</Button>
<Path Width="12" Height="12" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Branch}"/>
<Button Classes="icon_button" Width="32" Click="OpenStatistics" ToolTip.Tip="{DynamicResource Text.Repository.Statistics}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Statistics}"/>
</Button>
<ContentControl Margin="4,0,0,0">
<ContentControl.Content>
<Binding Path="CurrentBranch">
<Binding.TargetNullValue>
<TextBlock Classes="monospace" Text="(No commits yet)"/>
</Binding.TargetNullValue>
</Binding>
</ContentControl.Content>
<Button Classes="icon_button" Width="32" Command="{Binding OpenConfigure}" ToolTip.Tip="{DynamicResource Text.Repository.Configure}">
<Path Width="15" Height="15" Data="{StaticResource Icons.Settings}"/>
<ContentControl.DataTemplates>
<DataTemplate DataType="m:Branch">
<Border Background="Transparent" ToolTip.Tip="{Binding FriendlyName}">
<TextBlock Classes="monospace" Text="{Binding FriendlyName}" MaxWidth="250" TextTrimming="CharacterEllipsis"/>
</Border>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
<Button Classes="icon_button" Width="32" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
<Path Width="12" Height="12" Margin="0,2,0,0" Data="{StaticResource Icons.Target}" Fill="{DynamicResource Brush.FG1}"/>
</Button>
</StackPanel>
</Grid>