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.Data.Converters;
using Avalonia.Media;
namespace SourceGit.Converters namespace SourceGit.Converters
{ {
@ -6,5 +7,8 @@ namespace SourceGit.Converters
{ {
public static readonly FuncValueConverter<bool, double> ToCommitOpacity = public static readonly FuncValueConverter<bool, double> ToCommitOpacity =
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5); 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; get => Author != Committer || AuthorTime != CommitterTime;
} }
public bool IsCurrentHead
{
get => Decorators.Find(x => x.Type == DecoratorType.CurrentBranchHead) != null;
}
public string FullMessage public string FullMessage
{ {
get => string.IsNullOrWhiteSpace(Message) ? Subject : $"{Subject}\n\n{Message}"; get => string.IsNullOrWhiteSpace(Message) ? Subject : $"{Subject}\n\n{Message}";

View file

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