From 0d59b6cd3e392611f5e3554115ba2313b069ded3 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Mon, 24 Apr 2023 23:40:55 +0800 Subject: [PATCH] fix: fix timeline not able to react to theme change. --- src/Ursa.Themes.Semi/Controls/Timeline.axaml | 35 +++++++++++++------ .../Themes/Dark/Timeline.axaml | 9 +++++ src/Ursa.Themes.Semi/Themes/Dark/_index.axaml | 1 + .../Themes/Light/Timeline.axaml | 1 + src/Ursa/Controls/Timeline/TimelineItem.cs | 11 ++++-- 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml diff --git a/src/Ursa.Themes.Semi/Controls/Timeline.axaml b/src/Ursa.Themes.Semi/Controls/Timeline.axaml index 63e311c..9397b3a 100644 --- a/src/Ursa.Themes.Semi/Controls/Timeline.axaml +++ b/src/Ursa.Themes.Semi/Controls/Timeline.axaml @@ -48,21 +48,16 @@ HorizontalAlignment="Center" VerticalAlignment="Top" Classes="start" - Fill="LightGray" /> + Fill="{DynamicResource TimelineLineBrush}" /> - - - - - - - + VerticalAlignment="Top" + Fill="{DynamicResource DefaultTimelineIconForeground}" /> + Fill="{DynamicResource TimelineLineBrush}" /> + Fill="{DynamicResource TimelineLineBrush}" /> + + + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml b/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml new file mode 100644 index 0000000..47b44c7 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Dark/Timeline.axaml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml index 7a530cc..004d6a1 100644 --- a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml @@ -5,5 +5,6 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml b/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml index e879046..b5549db 100644 --- a/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml +++ b/src/Ursa.Themes.Semi/Themes/Light/Timeline.axaml @@ -5,4 +5,5 @@ + diff --git a/src/Ursa/Controls/Timeline/TimelineItem.cs b/src/Ursa/Controls/Timeline/TimelineItem.cs index 9ba9f9c..0958a31 100644 --- a/src/Ursa/Controls/Timeline/TimelineItem.cs +++ b/src/Ursa/Controls/Timeline/TimelineItem.cs @@ -8,7 +8,7 @@ using Avalonia.Media; namespace Ursa.Controls; -[PseudoClasses(PC_First, PC_Last, PC_Default, PC_Ongoing, PC_Success, PC_Warning, PC_Error)] +[PseudoClasses(PC_First, PC_Last, PC_Default, PC_Ongoing, PC_Success, PC_Warning, PC_Error, PC_None)] public class TimelineItem: ContentControl { private const string PC_First = ":first"; @@ -18,6 +18,7 @@ public class TimelineItem: ContentControl private const string PC_Success = ":success"; private const string PC_Warning = ":warning"; private const string PC_Error = ":error"; + private const string PC_None = ":none"; private static readonly IReadOnlyDictionary _itemTypeMapping = new Dictionary { @@ -81,6 +82,7 @@ public class TimelineItem: ContentControl static TimelineItem() { ItemTypeProperty.Changed.AddClassHandler((o, e) => { o.OnItemTypeChanged(e); }); + IconForegroundProperty.Changed.AddClassHandler((o, e) => { o.OnIconForegroundChanged(e); }); } private void OnItemTypeChanged(AvaloniaPropertyChangedEventArgs args) @@ -90,5 +92,10 @@ public class TimelineItem: ContentControl PseudoClasses.Set(_itemTypeMapping[oldValue], false); PseudoClasses.Set(_itemTypeMapping[newValue], true); } - + + private void OnIconForegroundChanged(AvaloniaPropertyChangedEventArgs args) + { + IBrush? newValue = args.GetOldValue(); + PseudoClasses.Set(PC_None, newValue is null); + } } \ No newline at end of file