style: use FontWeight.Bold for current head (#44)

This commit is contained in:
leo 2024-04-01 18:11:22 +08:00
parent 54b9c420c1
commit ef02a57ab2
3 changed files with 19 additions and 4 deletions

View file

@ -1,4 +1,5 @@
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace SourceGit.Converters
{
@ -6,5 +7,8 @@ namespace SourceGit.Converters
{
public static readonly FuncValueConverter<bool, double> ToCommitOpacity =
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
public static readonly FuncValueConverter<bool, FontWeight> ToCommitFontWeight =
new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular);
}
}

View file

@ -30,6 +30,11 @@ namespace SourceGit.Models
get => Author != Committer || AuthorTime != CommitterTime;
}
public bool IsCurrentHead
{
get => Decorators.Find(x => x.Type == DecoratorType.CurrentBranchHead) != null;
}
public string FullMessage
{
get => string.IsNullOrWhiteSpace(Message) ? Subject : $"{Subject}\n\n{Message}";

View file

@ -62,7 +62,10 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Classes="monospace" Text="{Binding Subject}" Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"/>
<TextBlock Classes="monospace"
Text="{Binding Subject}"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
</StackPanel>
</Border>
</DataTemplate>
@ -88,7 +91,8 @@
<TextBlock Classes="monospace"
Text="{Binding Author.Name}"
Margin="0,0,8,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -99,7 +103,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}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
@ -110,7 +115,8 @@
<TextBlock Classes="monospace"
Text="{Binding CommitterTimeStr}"
Margin="8,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"/>
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.ToCommitOpacity}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.ToCommitFontWeight}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>