Add CommitInfo hardcoded line counter

This commit is contained in:
Bernat Borràs Civil 2025-01-12 18:47:27 +01:00
parent b26838ff68
commit 88452bd74d
4 changed files with 71 additions and 3 deletions

View file

@ -137,6 +137,7 @@
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String> <x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String>
<x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">REFS</x:String> <x:String x:Key="Text.CommitDetail.Info.Refs" xml:space="preserve">REFS</x:String>
<x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">SHA</x:String> <x:String x:Key="Text.CommitDetail.Info.SHA" xml:space="preserve">SHA</x:String>
<x:String x:Key="Text.CommitDetail.Info.Stats" xml:space="preserve">STATS</x:String>
<x:String x:Key="Text.CommitDetail.Info.WebLinks" xml:space="preserve">Open in Browser</x:String> <x:String x:Key="Text.CommitDetail.Info.WebLinks" xml:space="preserve">Open in Browser</x:String>
<x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">Enter commit subject</x:String> <x:String x:Key="Text.CommitMessageTextBox.SubjectPlaceholder" xml:space="preserve">Enter commit subject</x:String>
<x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">Description</x:String> <x:String x:Key="Text.CommitMessageTextBox.MessagePlaceholder" xml:space="preserve">Description</x:String>

View file

@ -51,7 +51,7 @@
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/> <Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
<!-- Base Information --> <!-- Base Information -->
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*"> <Grid RowDefinitions="24,Auto,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
<!-- SHA --> <!-- SHA -->
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.SHA}" /> <TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Height="24"> <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Height="24">
@ -182,9 +182,13 @@
UseGraphColor="False"/> UseGraphColor="False"/>
</Border> </Border>
<!-- 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" AddedLines="0" RemovedLines="0" />
<!-- Messages --> <!-- Messages -->
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Message}" /> <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="4" Grid.Column="1" <v:CommitMessagePresenter Grid.Row="5" Grid.Column="1"
Margin="12,4,8,0" Margin="12,4,8,0"
Classes="primary" Classes="primary"
Message="{Binding #ThisControl.Message}" Message="{Binding #ThisControl.Message}"

View file

@ -0,0 +1,22 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SourceGit.Views"
x:Class="SourceGit.Views.LinesChanged"
x:Name="ThisControl"
x:DataType="local:LinesChanged">
<StackPanel Orientation="Horizontal" Height="24">
<TextBlock Margin="12,0,4,0" VerticalAlignment="Center">
<TextBlock.Inlines>
<Run Text="++"/>
<Run Text="{Binding AddedLines}"/>
</TextBlock.Inlines>
</TextBlock>
<TextBlock Margin="12,0,4,0" VerticalAlignment="Center">
<TextBlock.Inlines>
<Run Text="--"/>
<Run Text="{Binding RemovedLines}"/>
</TextBlock.Inlines>
</TextBlock>
</StackPanel>
</UserControl>

View file

@ -0,0 +1,41 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace SourceGit.Views
{
public partial class LinesChanged : UserControl
{
public static readonly DirectProperty<LinesChanged, int> AddedLinesProperty =
AvaloniaProperty.RegisterDirect<LinesChanged, int>(nameof(AddedLines), o => o.AddedLines);
public static readonly DirectProperty<LinesChanged, int> RemovedLinesProperty =
AvaloniaProperty.RegisterDirect<LinesChanged, int>(nameof(RemovedLines), o => o.RemovedLines);
private int _addedLines;
private int _removedLines;
public int AddedLines
{
get => _addedLines;
set => SetAndRaise(AddedLinesProperty, ref _addedLines, value);
}
public int RemovedLines
{
get => _removedLines;
set => SetAndRaise(RemovedLinesProperty, ref _removedLines, value);
}
public LinesChanged()
{
InitializeComponent();
this.DataContext = this;
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}