From 897aff5d12bcdd31fdf356a02b2333489e1232ff Mon Sep 17 00:00:00 2001 From: chinboy Date: Tue, 25 Nov 2025 16:26:34 +0800 Subject: [PATCH] Refactor IconProvider default value set bug --- src/AtomUI.Core/Controls/Icon/IconProvider.cs | 17 ++++++++--------- .../SizeTypeAwareIconPresenter.axaml | 2 +- .../Spin/SpinIndicator.cs | 18 ++++++++++++------ .../AntDesignIconProvider.cs | 1 - 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/AtomUI.Core/Controls/Icon/IconProvider.cs b/src/AtomUI.Core/Controls/Icon/IconProvider.cs index 8a5b9b0f7..54824cdb8 100644 --- a/src/AtomUI.Core/Controls/Icon/IconProvider.cs +++ b/src/AtomUI.Core/Controls/Icon/IconProvider.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using Avalonia.Layout; using Avalonia.Markup.Xaml; using Avalonia.Media; @@ -45,39 +44,39 @@ public abstract class IconProvider : MarkupExtension if (NormalFilledColor != null) { - icon.SetCurrentValue(Icon.NormalFilledBrushProperty, NormalFilledColor); + icon.NormalFilledBrush = NormalFilledColor; } if (ActiveFilledColor != null) { - icon.SetCurrentValue(Icon.ActiveFilledBrushProperty, ActiveFilledColor); + icon.ActiveFilledBrush = ActiveFilledColor; } if (SelectedFilledColor != null) { - icon.SetCurrentValue(Icon.SelectedFilledBrushProperty, SelectedFilledColor); + icon.SelectedFilledBrush = SelectedFilledColor; } if (DisabledFilledColor != null) { - icon.SetCurrentValue(Icon.DisabledFilledBrushProperty, DisabledFilledColor); + icon.DisabledFilledBrush = DisabledFilledColor; } if (PrimaryFilledColor != null) { - icon.SetCurrentValue(Icon.PrimaryFilledBrushProperty, PrimaryFilledColor); + icon.PrimaryFilledBrush = PrimaryFilledColor; } if (SecondaryFilledColor != null) { - icon.SetCurrentValue(Icon.SecondaryFilledBrushProperty, SecondaryFilledColor); + icon.SecondaryFilledBrush = SecondaryFilledColor; } if (!double.IsNaN(Width)) { - icon.SetCurrentValue(Layoutable.WidthProperty, Width); + icon.Width = Width; } if (!double.IsNaN(Height)) { - icon.SetCurrentValue(Layoutable.HeightProperty, Height); + icon.Height = Height; } return icon; diff --git a/src/AtomUI.Desktop.Controls/Primitives/SizeTypeAwareIconPresenter/SizeTypeAwareIconPresenter.axaml b/src/AtomUI.Desktop.Controls/Primitives/SizeTypeAwareIconPresenter/SizeTypeAwareIconPresenter.axaml index b25b78882..ff16e9324 100644 --- a/src/AtomUI.Desktop.Controls/Primitives/SizeTypeAwareIconPresenter/SizeTypeAwareIconPresenter.axaml +++ b/src/AtomUI.Desktop.Controls/Primitives/SizeTypeAwareIconPresenter/SizeTypeAwareIconPresenter.axaml @@ -49,7 +49,7 @@ Value="{DynamicResource {x:Static atom:SharedTokenKey.IconSizeSM}}" /> - + x.PropertyEquals(SizeTypeProperty, SizeType.Middle)); - var iconStyle = new Style(x => + var iconStyle = new Style(x => Selectors.Or( x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() - .OfType()); + .OfType(), + x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() + .OfType())); iconStyle.Add(WidthProperty, SpinTokenKey.IndicatorSize); iconStyle.Add(HeightProperty, SpinTokenKey.IndicatorSize); middleStyle.Add(iconStyle); @@ -275,9 +277,11 @@ public class SpinIndicator : TemplatedControl, { var smallStyle = new Style(x => x.PropertyEquals(SizeTypeProperty, SizeType.Small)); - var iconStyle = new Style(x => + var iconStyle = new Style(x => Selectors.Or( x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() - .OfType()); + .OfType(), + x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() + .OfType())); iconStyle.Add(WidthProperty, SpinTokenKey.IndicatorSizeSM); iconStyle.Add(HeightProperty, SpinTokenKey.IndicatorSizeSM); smallStyle.Add(iconStyle); @@ -286,9 +290,11 @@ public class SpinIndicator : TemplatedControl, { var largeStyle = new Style(x => x.PropertyEquals(SizeTypeProperty, SizeType.Large)); - var iconStyle = new Style(x => + var iconStyle = new Style(x => Selectors.Or( x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() - .OfType()); + .OfType(), + x.Nesting().Descendant().OfType().Name(SpinThemeConstants.CustomIndicatorPresenterPart).Child() + .OfType())); iconStyle.Add(WidthProperty, SpinTokenKey.IndicatorSizeLG); iconStyle.Add(HeightProperty, SpinTokenKey.IndicatorSizeLG); largeStyle.Add(iconStyle); diff --git a/src/AtomUI.Icons.AntDesign/AntDesignIconProvider.cs b/src/AtomUI.Icons.AntDesign/AntDesignIconProvider.cs index fba715321..3e2821f84 100644 --- a/src/AtomUI.Icons.AntDesign/AntDesignIconProvider.cs +++ b/src/AtomUI.Icons.AntDesign/AntDesignIconProvider.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Reflection; using AtomUI.Controls; -using AtomUI.Icons.AntDesign; namespace AtomUI.Icons.AntDesign;