fix: fix timeline not able to react to theme change.
This commit is contained in:
@@ -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<TimelineItemType, string> _itemTypeMapping = new Dictionary<TimelineItemType, string>
|
||||
{
|
||||
@@ -81,6 +82,7 @@ public class TimelineItem: ContentControl
|
||||
static TimelineItem()
|
||||
{
|
||||
ItemTypeProperty.Changed.AddClassHandler<TimelineItem>((o, e) => { o.OnItemTypeChanged(e); });
|
||||
IconForegroundProperty.Changed.AddClassHandler<TimelineItem>((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<IBrush?>();
|
||||
PseudoClasses.Set(PC_None, newValue is null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user