Split line counters in a new view

This commit is contained in:
Bernat Borràs Civil 2025-04-13 16:10:20 +02:00
parent f1fcdb89f3
commit 2cac661676
3 changed files with 61 additions and 21 deletions

View file

@ -183,27 +183,8 @@
<!-- Stats -->
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Stats}" />
<!--v:LinesChanged Grid.Row="4" Grid.Column="1" AddedCount="{Binding AddedLines}" RemovedCount="{Binding RemovedLines}" /-->
<StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal" Height="24">
<Border Margin="12,0,4,0" VerticalAlignment="Center" BorderBrush="Green" BorderThickness="1" CornerRadius="6">
<TextBlock VerticalAlignment="Center" Foreground="Green" Padding="3,0">
<TextBlock.Inlines>
<Run Text="+"/>
<Run Text="{Binding AddedLines}"/>
</TextBlock.Inlines>
</TextBlock>
</Border>
<Border Margin="12,0,4,0" VerticalAlignment="Center" BorderBrush="Red" BorderThickness="1" CornerRadius="6">
<TextBlock VerticalAlignment="Center" Foreground="Red" Padding="3,0">
<TextBlock.Inlines>
<Run Text="-"/>
<Run Text="{Binding RemovedLines}"/>
</TextBlock.Inlines>
</TextBlock>
</Border>
</StackPanel>
<v:LinesChanged Grid.Row="4" Grid.Column="1" AddedCount="{Binding AddedLines}" RemovedCount="{Binding RemovedLines}" />
<!-- Messages -->
<TextBlock Grid.Row="5" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Message}" />
<v:CommitMessagePresenter Grid.Row="5" Grid.Column="1"

View file

@ -0,0 +1,28 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.LinesChanged"
x:Name="ThisControl"
Height="24">
<StackPanel Orientation="Horizontal">
<Border Margin="12,0,4,0" VerticalAlignment="Center" BorderBrush="Green" BorderThickness="1" CornerRadius="6">
<TextBlock VerticalAlignment="Center" Foreground="Green" Padding="3,0">
<TextBlock.Inlines>
<Run Text="+"/>
<Run Text="{Binding #ThisControl.AddedCount}"/>
</TextBlock.Inlines>
</TextBlock>
</Border>
<Border Margin="12,0,4,0" VerticalAlignment="Center" BorderBrush="Red" BorderThickness="1" CornerRadius="6">
<TextBlock VerticalAlignment="Center" Foreground="Red" Padding="3,0">
<TextBlock.Inlines>
<Run Text="-"/>
<Run Text="{Binding #ThisControl.RemovedCount}"/>
</TextBlock.Inlines>
</TextBlock>
</Border>
</StackPanel>
</UserControl>

View file

@ -0,0 +1,31 @@
using Avalonia;
using Avalonia.Controls;
namespace SourceGit.Views
{
public partial class LinesChanged : UserControl
{
public static readonly StyledProperty<int> AddedCountProperty =
AvaloniaProperty.Register<LinesChanged, int>(nameof(AddedCount));
public static readonly StyledProperty<int> RemovedCountProperty =
AvaloniaProperty.Register<LinesChanged, int>(nameof(RemovedCount));
public int AddedCount
{
get => GetValue(AddedCountProperty);
set => SetValue(AddedCountProperty, value);
}
public int RemovedCount
{
get => GetValue(RemovedCountProperty);
set => SetValue(RemovedCountProperty, value);
}
public LinesChanged()
{
InitializeComponent();
}
}
}