refactor: show submodule as tree instead of list (#1307)

This commit is contained in:
leo 2025-05-14 17:55:28 +08:00
parent 5ec51eefb9
commit 463d161ac7
No known key found for this signature in database
6 changed files with 534 additions and 136 deletions

View file

@ -330,100 +330,14 @@
</Button>
</Grid>
</ToggleButton>
<ListBox Grid.Row="7"
x:Name="SubmoduleList"
Height="0"
Margin="12,0,4,0"
Classes="repo_left_content_list"
ItemsSource="{Binding VisibleSubmodules}"
SelectionMode="Single"
ContextRequested="OnSubmoduleContextRequested"
DoubleTapped="OnDoubleTappedSubmodule"
PropertyChanged="OnLeftSidebarListBoxPropertyChanged"
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="CornerRadius" Value="4"/>
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Submodule">
<Grid ColumnDefinitions="Auto,*,8,8" Background="Transparent">
<ToolTip.Tip>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Path Width="10" Height="10" Data="{StaticResource Icons.Submodule}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Path}"/>
</StackPanel>
<Grid RowDefinitions="24,24" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0">
<TextBlock Grid.Row="0" Grid.Column="0"
Classes="info_label"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.CommitDetail.Info.SHA}"/>
<StackPanel Grid.Row="0" Grid.Column="1"
Orientation="Horizontal"
Margin="8,0,0,0">
<TextBlock Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
VerticalAlignment="Center"/>
<Path Margin="6,0,0,0"
HorizontalAlignment="Left" VerticalAlignment="Center"
Width="12" Height="12"
Data="{StaticResource Icons.Check}"
Fill="Green"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}"/>
<Border Height="16"
Margin="6,0,0,0" Padding="4,0"
HorizontalAlignment="Left" VerticalAlignment="Center"
Background="DarkOrange"
CornerRadius="4"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}">
<Grid>
<TextBlock VerticalAlignment="Center"
Text="{DynamicResource Text.Submodule.Status.NotInited}"
Foreground="White"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.NotInited}}"/>
<TextBlock VerticalAlignment="Center"
Text="{DynamicResource Text.Submodule.Status.Modified}"
Foreground="White"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Modified}}"/>
<TextBlock VerticalAlignment="Center"
Text="{DynamicResource Text.Submodule.Status.RevisionChanged}"
Foreground="White"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.RevisionChanged}}"/>
<TextBlock VerticalAlignment="Center"
Text="{DynamicResource Text.Submodule.Status.Unmerged}"
Foreground="White"
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Unmerged}}"/>
</Grid>
</Border>
</StackPanel>
<TextBlock Grid.Row="1" Grid.Column="0"
Classes="info_label"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.Submodule.URL}"/>
<TextBlock Grid.Row="1" Grid.Column="1"
Margin="8,0,0,0"
Text="{Binding URL}"
Foreground="{DynamicResource Brush.Link}"
VerticalAlignment="Center"/>
</Grid>
</StackPanel>
</ToolTip.Tip>
<Path Grid.Column="0" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Submodule}"/>
<TextBlock Grid.Column="1" Text="{Binding Path}" ClipToBounds="True" Classes="primary" TextTrimming="CharacterEllipsis"/>
<Path Grid.Column="2"
Width="8" Height="8"
Fill="Goldenrod"
Data="{StaticResource Icons.Modified}"
IsVisible="{Binding IsDirty}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<v:SubmodulesView Grid.Row="7"
x:Name="SubmoduleList"
Height="0"
Margin="8,0,4,0"
Submodules="{Binding VisibleSubmodules}"
RowsChanged="OnSubmodulesRowsChanged"
Focusable="False"
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}"/>
<!-- Worktrees -->
<ToggleButton Grid.Row="8" Classes="group_expander" IsChecked="{Binding IsWorktreeGroupExpanded, Mode=TwoWay}">
@ -461,7 +375,7 @@
SelectionMode="Single"
ContextRequested="OnWorktreeContextRequested"
DoubleTapped="OnDoubleTappedWorktree"
PropertyChanged="OnLeftSidebarListBoxPropertyChanged"
PropertyChanged="OnWorktreeListPropertyChanged"
IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}">
<ListBox.Styles>
<Style Selector="ListBoxItem">