Skip to content

Commit d2e6889

Browse files
committed
ux: use different inline code background for different themes
Signed-off-by: leo <[email protected]>
1 parent 91acf0a commit d2e6889

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Resources/Themes.axaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<Color x:Key="Color.Diff.AddedHighlight">#A7E1A7</Color>
2626
<Color x:Key="Color.Diff.DeletedHighlight">#F19B9D</Color>
2727
<Color x:Key="Color.Link">#0000EE</Color>
28+
<Color x:Key="Color.InlineCode">#FFE5E5E5</Color>
2829
</ResourceDictionary>
2930

3031
<ResourceDictionary x:Key="Dark">
@@ -51,6 +52,7 @@
5152
<Color x:Key="Color.Diff.AddedHighlight">#A0308D3C</Color>
5253
<Color x:Key="Color.Diff.DeletedHighlight">#A09F4247</Color>
5354
<Color x:Key="Color.Link">#4DAAFC</Color>
55+
<Color x:Key="Color.InlineCode">#FF2E2E2E</Color>
5456
</ResourceDictionary>
5557
</ResourceDictionary.ThemeDictionaries>
5658

@@ -79,6 +81,7 @@
7981
<SolidColorBrush x:Key="Brush.Diff.AddedHighlight" Color="{DynamicResource Color.Diff.AddedHighlight}"/>
8082
<SolidColorBrush x:Key="Brush.Diff.DeletedHighlight" Color="{DynamicResource Color.Diff.DeletedHighlight}"/>
8183
<SolidColorBrush x:Key="Brush.Link" Color="{DynamicResource Color.Link}"/>
84+
<SolidColorBrush x:Key="Brush.InlineCode" Color="{DynamicResource Color.InlineCode}"/>
8285

8386
<FontFamily x:Key="Fonts.Default">fonts:Inter#Inter</FontFamily>
8487
<FontFamily x:Key="Fonts.Monospace">fonts:SourceGit#JetBrains Mono</FontFamily>

src/Views/CommitSubjectPresenter.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public FontWeight FontWeight
4747
get => GetValue(FontWeightProperty);
4848
set => SetValue(FontWeightProperty, value);
4949
}
50+
51+
public static readonly StyledProperty<IBrush> InlineCodeBackgroundProperty =
52+
AvaloniaProperty.Register<CommitSubjectPresenter, IBrush>(nameof(InlineCodeBackground), Brushes.Transparent);
53+
54+
public IBrush InlineCodeBackground
55+
{
56+
get => GetValue(InlineCodeBackgroundProperty);
57+
set => SetValue(InlineCodeBackgroundProperty, value);
58+
}
5059

5160
public static readonly StyledProperty<IBrush> ForegroundProperty =
5261
AvaloniaProperty.Register<CommitSubjectPresenter, IBrush>(nameof(Foreground), Brushes.White);
@@ -106,7 +115,7 @@ public override void Render(DrawingContext context)
106115
{
107116
var rect = new Rect(inline.X, (height - inline.Text.Height - 2) * 0.5, inline.Text.WidthIncludingTrailingWhitespace + 8, inline.Text.Height + 2);
108117
var roundedRect = new RoundedRect(rect, new CornerRadius(4));
109-
context.DrawRectangle(new SolidColorBrush(new Color(52, 101, 108, 118)), null, roundedRect);
118+
context.DrawRectangle(InlineCodeBackground, null, roundedRect);
110119
context.DrawText(inline.Text, new Point(inline.X + 4, (height - inline.Text.Height) * 0.5));
111120
}
112121
else
@@ -182,6 +191,10 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
182191
_needRebuildInlines = true;
183192
InvalidateVisual();
184193
}
194+
else if (change.Property == InlineCodeBackgroundProperty)
195+
{
196+
InvalidateVisual();
197+
}
185198
}
186199

187200
protected override void OnPointerMoved(PointerEventArgs e)

src/Views/Histories.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
<v:CommitSubjectPresenter Grid.Column="3"
159159
FontFamily="{DynamicResource Fonts.Primary}"
160160
CodeFontFamily="{DynamicResource Fonts.Monospace}"
161+
InlineCodeBackground="{DynamicResource Brush.InlineCode}"
161162
Foreground="{DynamicResource Brush.FG1}"
162163
LinkForeground="{DynamicResource Brush.Link}"
163164
Subject="{Binding Subject}"

0 commit comments

Comments
 (0)