feat: shows the number of files in the current list on unstaged and staged lists

This commit is contained in:
Gadfly 2024-04-12 01:27:19 +08:00
parent f3f39ac593
commit 0e2da217f1
No known key found for this signature in database
GPG key ID: 9128145F93CFC69C
2 changed files with 42 additions and 4 deletions

View file

@ -46,13 +46,25 @@ namespace SourceGit.ViewModels
public List<Models.Change> Unstaged public List<Models.Change> Unstaged
{ {
get => _unstaged; get => _unstaged;
private set => SetProperty(ref _unstaged, value); private set
{
if (SetProperty(ref _unstaged, value))
{
OnPropertyChanged(nameof(UnstagedCount));
}
}
} }
public List<Models.Change> Staged public List<Models.Change> Staged
{ {
get => _staged; get => _staged;
private set => SetProperty(ref _staged, value); private set
{
if (SetProperty(ref _staged, value))
{
OnPropertyChanged(nameof(StagedCount));
}
}
} }
public int Count public int Count
@ -60,6 +72,16 @@ namespace SourceGit.ViewModels
get => _count; get => _count;
} }
public int UnstagedCount
{
get => _unstaged.Count;
}
public int StagedCount
{
get => _staged.Count;
}
public Models.Change SelectedUnstagedChange public Models.Change SelectedUnstagedChange
{ {
get => _selectedUnstagedChange; get => _selectedUnstagedChange;

View file

@ -22,7 +22,15 @@
<Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"> <Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}">
<Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto,Auto,Auto"> <Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto,Auto,Auto">
<v:ChangeViewModeSwitcher Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=UnstagedChangeViewMode, Mode=TwoWay}"/> <v:ChangeViewModeSwitcher Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=UnstagedChangeViewMode, Mode=TwoWay}"/>
<TextBlock Grid.Column="1" Text="{DynamicResource Text.WorkingCopy.Unstaged}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold" Margin="8,0,0,0"/> <TextBlock Grid.Column="1"
Foreground="{DynamicResource Brush.FG2}"
FontWeight="Bold"
Margin="8,0,0,0">
<Run Text="{DynamicResource Text.WorkingCopy.Unstaged}" />
<Run Text="(" />
<Run Text="{Binding UnstagedCount}" />
<Run Text=")" />
</TextBlock>
<Path Grid.Column="2" Classes="rotating" Width="14" Height="14" Data="{StaticResource Icons.Loading}" Margin="8,0,0,0" IsVisible="{Binding IsStaging}"/> <Path Grid.Column="2" Classes="rotating" Width="14" Height="14" Data="{StaticResource Icons.Loading}" Margin="8,0,0,0" IsVisible="{Binding IsStaging}"/>
<Button Grid.Column="4" <Button Grid.Column="4"
@ -169,7 +177,15 @@
<Border Grid.Row="2" BorderThickness="0,1" BorderBrush="{DynamicResource Brush.Border0}"> <Border Grid.Row="2" BorderThickness="0,1" BorderBrush="{DynamicResource Brush.Border0}">
<Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto"> <Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto">
<v:ChangeViewModeSwitcher Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=StagedChangeViewMode, Mode=TwoWay}"/> <v:ChangeViewModeSwitcher Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=StagedChangeViewMode, Mode=TwoWay}"/>
<TextBlock Grid.Column="1" Text="{DynamicResource Text.WorkingCopy.Staged}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold" Margin="8,0,0,0"/> <TextBlock Grid.Column="1"
Foreground="{DynamicResource Brush.FG2}"
FontWeight="Bold"
Margin="8,0,0,0">
<Run Text="{DynamicResource Text.WorkingCopy.Staged}" />
<Run Text="(" />
<Run Text="{Binding StagedCount}" />
<Run Text=")" />
</TextBlock>
<Path Grid.Column="2" Classes="rotating" Width="14" Height="14" Data="{StaticResource Icons.Loading}" Margin="8,0,0,0" IsVisible="{Binding IsUnstaging}"/> <Path Grid.Column="2" Classes="rotating" Width="14" Height="14" Data="{StaticResource Icons.Loading}" Margin="8,0,0,0" IsVisible="{Binding IsUnstaging}"/>
<Button Grid.Column="4" Classes="icon_button" Width="26" Height="14" Padding="0" ToolTip.Tip="{DynamicResource Text.WorkingCopy.Staged.Unstage}" Click="UnstageSelected"> <Button Grid.Column="4" Classes="icon_button" Width="26" Height="14" Padding="0" ToolTip.Tip="{DynamicResource Text.WorkingCopy.Staged.Unstage}" Click="UnstageSelected">
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/> <Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>