ux: re-design Views.Repository

* It's better to move the `Navigate to HEAD` button to the top-right of this page.
* Icons and alignments
This commit is contained in:
leo 2024-04-18 10:50:14 +08:00
parent 8d7df75241
commit 599ba01f20
5 changed files with 39 additions and 38 deletions

View file

@ -5,10 +5,10 @@ namespace SourceGit.Converters
{
public static class BoolConverters
{
public static readonly FuncValueConverter<bool, double> ToCommitOpacity =
public static readonly FuncValueConverter<bool, double> HalfIfFalse =
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
public static readonly FuncValueConverter<bool, FontWeight> ToCommitFontWeight =
public static readonly FuncValueConverter<bool, FontWeight> BoldIfTrue =
new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular);
}
}

View file

@ -54,9 +54,9 @@
<StreamGeometry x:Key="Icons.Blame">M128 256h192a64 64 0 110 128H128a64 64 0 110-128zm576 192h192a64 64 0 010 128h-192a64 64 0 010-128zm-576 192h192a64 64 0 010 128H128a64 64 0 010-128zm576 0h192a64 64 0 010 128h-192a64 64 0 010-128zm0-384h192a64 64 0 010 128h-192a64 64 0 010-128zM128 448h192a64 64 0 110 128H128a64 64 0 110-128zm384-320a64 64 0 0164 64v640a64 64 0 01-128 0V192a64 64 0 0164-64z</StreamGeometry>
<StreamGeometry x:Key="Icons.Histories">M24 512A488 488 0 01512 24A488 488 0 011000 512A488 488 0 01512 1000A488 488 0 0124 512zm447-325v327L243 619l51 111 300-138V187H471z</StreamGeometry>
<StreamGeometry x:Key="Icons.Archive">M715 254h-405l-58 57h520zm-492 86v201h578V340zm405 143h-29v-29H425v29h-29v-57h231v57zm-405 295h578V559H223zm174-133h231v57h-29v-29H425v29h-29v-57z</StreamGeometry>
<StreamGeometry x:Key="Icons.Branch">M869 145a145 145 0 10-289 0c0 56 33 107 83 131c-5 96-77 128-201 175c-52 20-110 42-160 74V276A144 144 0 00242 0a145 145 0 00-145 145c0 58 35 108 84 131v461a144 144 0 00-84 131a145 145 0 10289 0a144 144 0 00-84-131c5-95 77-128 201-175c122-46 274-103 280-287a145 145 0 0085-132zM242 61a83 83 0 110 167a83 83 0 010-167zm0 891a84 84 0 110-167a84 84 0 010 167zM724 228a84 84 0 110-167a84 84 0 010 167z</StreamGeometry>
<StreamGeometry x:Key="Icons.Branch">M757 226a143 143 0 00-55 276 96 96 0 01-88 59h-191a187 187 0 00-96 27V312a143 143 0 10-96 0v399a143 143 0 10103 2 96 96 0 0188-59h191a191 191 0 00187-151 143 143 0 00-43-279zM280 130a48 48 0 110 96 48 48 0 010-96zm0 764a48 48 0 110-96 48 48 0 010 96zM757 417a48 48 0 110-96 48 48 0 010 96z</StreamGeometry>
<StreamGeometry x:Key="Icons.Branch.Add">M896 128h-64V64c0-35-29-64-64-64s-64 29-64 64v64h-64c-35 0-64 29-64 64s29 64 64 64h64v64c0 35 29 64 64 64s64-29 64-64V256h64c35 0 64-29 64-64s-29-64-64-64zm-204 307C673 481 628 512 576 512H448c-47 0-90 13-128 35V372C394 346 448 275 448 192c0-106-86-192-192-192S64 86 64 192c0 83 54 154 128 180v280c-74 26-128 97-128 180c0 106 86 192 192 192s192-86 192-192c0-67-34-125-84-159c22-20 52-33 84-33h128c122 0 223-85 249-199c-19 4-37 7-57 7c-26 0-51-5-76-13zM256 128c35 0 64 29 64 64s-29 64-64 64s-64-29-64-64s29-64 64-64zm0 768c-35 0-64-29-64-64s29-64 64-64s64 29 64 64s-29 64-64 64z</StreamGeometry>
<StreamGeometry x:Key="Icons.Remote">M902 479v-1c0-133-112-242-250-242c-106 0-196 64-232 154c-28-20-62-32-100-32c-76 0-140 49-160 116c-52 37-86 97-86 165c0 112 90 202 202 202h503c112 0 202-90 202-202c0-65-31-123-79-160z</StreamGeometry>
<StreamGeometry x:Key="Icons.Remote">M706 302a289 289 0 00-173 44 27 27 0 1029 46 234 234 0 01125-36c23 0 45 3 66 9 93 28 161 114 161 215C914 704 813 805 687 805H337C211 805 110 704 110 580c0-96 61-178 147-210C282 263 379 183 495 183a245 245 0 01210 119z</StreamGeometry>
<StreamGeometry x:Key="Icons.Remote.Add">M364 512h67v108h108v67h-108v108h-67v-108h-108v-67h108v-108zm298-64A107 107 0 01768 555C768 614 720 660 660 660h-108v-54h-108v-108h-94v108h-94c4-21 22-47 44-51l-1-12a75 75 0 0171-75a128 128 0 01239-7a106 106 0 0153-14z</StreamGeometry>
<StreamGeometry x:Key="Icons.Tag">M177 156c-22 5-33 17-36 37c-10 57-33 258-13 278l445 445c23 23 61 23 84 0l246-246c23-23 23-61 0-84l-445-445C437 120 231 145 177 156zM331 344c-26 26-69 26-95 0c-26-26-26-69 0-95s69-26 95 0C357 276 357 318 331 344z</StreamGeometry>
<StreamGeometry x:Key="Icons.Tag.Add">M683 537h-144v-142h-142V283H239a44 44 0 00-41 41v171a56 56 0 0014 34l321 321a41 41 0 0058 0l174-174a41 41 0 000-58zm-341-109a41 41 0 110-58a41 41 0 010 58zM649 284V142h-69v142h-142v68h142v142h69v-142h142v-68h-142z</StreamGeometry>

View file

@ -86,7 +86,7 @@
<Border Height="16" Margin="0,0,6,0" CornerRadius="2" ClipToBounds="True">
<StackPanel Orientation="Horizontal">
<Border Background="{DynamicResource Brush.Decorator}" Width="16">
<Path Width="8" Height="8" Stretch="Fill" Data="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToIcon}}" Fill="{DynamicResource Brush.DecoratorIcon}"/>
<Path Width="8" Height="8" Data="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToIcon}}" Fill="{DynamicResource Brush.DecoratorIcon}"/>
</Border>
<Border Background="{Binding Type, Converter={x:Static c:DecoratorTypeConverters.ToBackground}}">
<TextBlock Classes="monospace" Text="{Binding Name}" FontSize="10" Margin="4,0" Foreground="Black"/>

View file

@ -69,8 +69,8 @@
<TextBlock Classes="monospace"
Text="{Binding Subject}"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</StackPanel>
</Border>
</DataTemplate>
@ -85,7 +85,7 @@
VerticalAlignment="Center"
IsHitTestVisible="False"
User="{Binding Author}"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -96,8 +96,8 @@
<TextBlock Classes="monospace"
Text="{Binding Author.Name}"
Margin="0,0,8,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -108,8 +108,8 @@
<TextBlock Classes="monospace"
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
Margin="12,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -120,8 +120,8 @@
<TextBlock Classes="monospace"
Text="{Binding CommitterTimeStr}"
Margin="8,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

View file

@ -76,6 +76,10 @@
IsVisible="{Binding SelectedViewIndex, Converter={x:Static c:IntConverters.IsZero}}"
ToolTip.Tip="{DynamicResource Text.Histories.DisplayMode}"/>
<Button Classes="icon_button" Width="32" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Target}"/>
</Button>
<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>
@ -111,19 +115,16 @@
</ListBox.ItemsPanel>
<ListBoxItem Height="28" Padding="0">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="Auto,*,Auto">
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Histories}"/>
<TextBlock Grid.Column="1" Margin="8,0,0,0" Classes="monospace" Text="{DynamicResource Text.Histories}"/>
<Button Grid.Column="2" Classes="icon_button" Width="14" Margin="8,0" Command="{Binding NavigateToCurrentHead}" ToolTip.Tip="{DynamicResource Text.Repository.NavigateToCurrentHead}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Target}"/>
</Button>
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Histories}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.Histories}"/>
</Grid>
</ListBoxItem>
<ListBoxItem Height="28" Padding="0">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="Auto,*,Auto">
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Send}"/>
<TextBlock Grid.Column="1" Classes="monospace" Margin="8,0,0,0" Text="{DynamicResource Text.WorkingCopy}"/>
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*,Auto">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Send}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.WorkingCopy}"/>
<Border Grid.Column="2"
Margin="6,0"
Height="18"
@ -137,9 +138,9 @@
</ListBoxItem>
<ListBoxItem Height="28" Padding="0">
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="Auto,*,Auto">
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Stashes}"/>
<TextBlock Grid.Column="1" Classes="monospace" Margin="8,0,0,0" Text="{DynamicResource Text.Stashes}"/>
<Grid Margin="16,0,0,0" Height="28" ColumnDefinitions="20,*,Auto">
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Data="{StaticResource Icons.Stashes}"/>
<TextBlock Grid.Column="1" Classes="monospace" Text="{DynamicResource Text.Stashes}"/>
<Border Grid.Column="2"
Margin="6,0"
Height="18"
@ -170,10 +171,10 @@
</TreeView.Styles>
<TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type m:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="Auto,*,Auto,Auto" Background="Transparent" ContextRequested="OnLocalBranchContextMenuRequested" DoubleTapped="OnDoubleTappedLocalBranchNode">
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
<Path Grid.Column="0" Width="10" Height="10" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="10" Height="10" Data="{StaticResource Icons.Branch}" VerticalAlignment="Center">
<Grid Height="24" ColumnDefinitions="20,*,Auto,Auto" Background="Transparent" ContextRequested="OnLocalBranchContextMenuRequested" DoubleTapped="OnDoubleTappedLocalBranchNode">
<Path Grid.Column="0" Classes="folder_icon" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,1,0,0" IsVisible="{Binding IsFolder}"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Check}" IsVisible="{Binding IsCurrent}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" VerticalAlignment="Center">
<Path.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="!IsFolder"/>
@ -181,8 +182,8 @@
</MultiBinding>
</Path.IsVisible>
</Path>
<TextBlock Grid.Column="1" Text="{Binding Name}" Classes="monospace" FontWeight="Bold" Margin="8,0,4,0" IsVisible="{Binding IsCurrent}"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Classes="monospace" Margin="8,0,4,0" IsVisible="{Binding !IsCurrent}"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Classes="monospace" FontWeight="{Binding IsCurrent, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
<Border Grid.Column="2" Margin="8,0" Height="18" CornerRadius="9" VerticalAlignment="Center" Background="{DynamicResource Brush.Badge}" IsVisible="{Binding IsUpstreamTrackStatusVisible}">
<TextBlock Classes="monospace" FontSize="10" HorizontalAlignment="Center" Margin="9,0" Text="{Binding UpstreamTrackStatus}"/>
@ -223,12 +224,12 @@
<TreeView.ItemTemplate>
<TreeDataTemplate ItemsSource="{Binding Children}" x:DataType="{x:Type m:BranchTreeNode}">
<Grid Height="24" ColumnDefinitions="Auto,*,Auto" Background="Transparent" ContextRequested="OnRemoteBranchContextMenuRequested">
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="10" Height="10" Margin="0,4,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="10" Height="10" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}" VerticalAlignment="Center"/>
<Grid Height="24" ColumnDefinitions="20,*,Auto" Background="Transparent" ContextRequested="OnRemoteBranchContextMenuRequested">
<Path Grid.Column="0" Classes="folder_icon" Width="10" Height="10" HorizontalAlignment="Left" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="0,2,0,0" Data="{StaticResource Icons.Remote}" IsVisible="{Binding IsRemote}" VerticalAlignment="Center"/>
<Path Grid.Column="0" Width="12" Height="12" HorizontalAlignment="Left" Margin="2,0,0,0" Data="{StaticResource Icons.Branch}" IsVisible="{Binding IsBranch}" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Classes="monospace" Margin="8,0,4,0"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Classes="monospace"/>
<ToggleButton Grid.Column="2"
Classes="filter"