From b2d226a966a9743d727596ecd4ce363dfd4994fe Mon Sep 17 00:00:00 2001 From: CHINBOY Date: Wed, 18 Jun 2025 16:25:05 +0800 Subject: [PATCH] Refactor Segmented themes --- .../AtomUIOSSControlThemesProvider.axaml | 1 + .../Themes/Button/BaseButtonTheme.axaml | 2 +- .../Themes/BaseCalendarDayButtonTheme.axaml | 2 +- .../Themes/ComboBoxSpinnerInnerBoxTheme.axaml | 2 +- .../CalendarView/CalendarButtonTheme.axaml | 2 +- .../CalendarView/CalendarDayButtonTheme.axaml | 2 +- .../ControlThemePool.g.cs | 2 - src/AtomUI.Controls/Segmented/Segmented.cs | 39 ++- .../Segmented/SegmentedItem.cs | 44 +--- .../Segmented/SegmentedItemTheme.cs | 246 ------------------ .../Segmented/SegmentedPseudoClass.cs | 6 + .../Segmented/SegmentedTheme.cs | 90 ------- .../Segmented/Themes/SegmentedItemTheme.axaml | 158 +++++++++++ .../Segmented/Themes/SegmentedTheme.axaml | 48 ++++ .../Themes/SegmentedThemeConstants.cs | 14 + .../Segmented/Themes/SegmentedThemes.axaml | 7 + src/AtomUI.IconPkg/IconPresenter.cs | 13 +- 17 files changed, 276 insertions(+), 402 deletions(-) delete mode 100644 src/AtomUI.Controls/Segmented/SegmentedItemTheme.cs create mode 100644 src/AtomUI.Controls/Segmented/SegmentedPseudoClass.cs delete mode 100644 src/AtomUI.Controls/Segmented/SegmentedTheme.cs create mode 100644 src/AtomUI.Controls/Segmented/Themes/SegmentedItemTheme.axaml create mode 100644 src/AtomUI.Controls/Segmented/Themes/SegmentedTheme.axaml create mode 100644 src/AtomUI.Controls/Segmented/Themes/SegmentedThemeConstants.cs create mode 100644 src/AtomUI.Controls/Segmented/Themes/SegmentedThemes.axaml diff --git a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml index e56592030..4021c1926 100644 --- a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml +++ b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml @@ -31,6 +31,7 @@ + diff --git a/src/AtomUI.Controls/Buttons/Themes/Button/BaseButtonTheme.axaml b/src/AtomUI.Controls/Buttons/Themes/Button/BaseButtonTheme.axaml index b4888468f..eacd0d9ac 100644 --- a/src/AtomUI.Controls/Buttons/Themes/Button/BaseButtonTheme.axaml +++ b/src/AtomUI.Controls/Buttons/Themes/Button/BaseButtonTheme.axaml @@ -192,7 +192,7 @@ - diff --git a/src/AtomUI.Controls/Calendar/Themes/BaseCalendarDayButtonTheme.axaml b/src/AtomUI.Controls/Calendar/Themes/BaseCalendarDayButtonTheme.axaml index 207deb004..5d59253db 100644 --- a/src/AtomUI.Controls/Calendar/Themes/BaseCalendarDayButtonTheme.axaml +++ b/src/AtomUI.Controls/Calendar/Themes/BaseCalendarDayButtonTheme.axaml @@ -56,7 +56,7 @@ - diff --git a/src/AtomUI.Controls/DatePicker/Themes/CalendarView/CalendarButtonTheme.axaml b/src/AtomUI.Controls/DatePicker/Themes/CalendarView/CalendarButtonTheme.axaml index 5ddfa097e..052ae8bb5 100644 --- a/src/AtomUI.Controls/DatePicker/Themes/CalendarView/CalendarButtonTheme.axaml +++ b/src/AtomUI.Controls/DatePicker/Themes/CalendarView/CalendarButtonTheme.axaml @@ -56,7 +56,7 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Segmented/Themes/SegmentedTheme.axaml b/src/AtomUI.Controls/Segmented/Themes/SegmentedTheme.axaml new file mode 100644 index 000000000..f11af79f2 --- /dev/null +++ b/src/AtomUI.Controls/Segmented/Themes/SegmentedTheme.axaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/Segmented/Themes/SegmentedThemeConstants.cs b/src/AtomUI.Controls/Segmented/Themes/SegmentedThemeConstants.cs new file mode 100644 index 000000000..f39bba1b8 --- /dev/null +++ b/src/AtomUI.Controls/Segmented/Themes/SegmentedThemeConstants.cs @@ -0,0 +1,14 @@ +namespace AtomUI.Controls.Themes; + +internal static class SegmentedItemThemeConstants +{ + public const string MainFramePart = "PART_MainFrame"; + public const string IconPresenterPart = "PART_IconPresenter"; + public const string ContentPart = "PART_Content"; +} + +internal static class SegmentedThemeConstants +{ + public const string FramePart = "PART_Frame"; + public const string ItemsPresenterPart = "PART_ItemsPresenter"; +} \ No newline at end of file diff --git a/src/AtomUI.Controls/Segmented/Themes/SegmentedThemes.axaml b/src/AtomUI.Controls/Segmented/Themes/SegmentedThemes.axaml new file mode 100644 index 000000000..efd17bd01 --- /dev/null +++ b/src/AtomUI.Controls/Segmented/Themes/SegmentedThemes.axaml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/src/AtomUI.IconPkg/IconPresenter.cs b/src/AtomUI.IconPkg/IconPresenter.cs index 702d8e2a2..b8e8a3b2d 100644 --- a/src/AtomUI.IconPkg/IconPresenter.cs +++ b/src/AtomUI.IconPkg/IconPresenter.cs @@ -2,7 +2,6 @@ using AtomUI.Data; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; -using Avalonia.Data; using Avalonia.Layout; using Avalonia.Media; using Avalonia.Metadata; @@ -185,25 +184,25 @@ public class IconPresenter : Control private void ConfigureIcon(Icon icon) { - SetValue(LoadingAnimationProperty, icon.LoadingAnimation, BindingPriority.Template); - SetValue(LoadingAnimationDurationProperty, icon.LoadingAnimationDuration, BindingPriority.Template); + SetCurrentValue(LoadingAnimationProperty, icon.LoadingAnimation); + SetCurrentValue(LoadingAnimationDurationProperty, icon.LoadingAnimationDuration); if (icon.ThemeType != IconThemeType.TwoTone) { if (icon.NormalFilledBrush != null) { - SetValue(NormalFilledBrushProperty, icon.NormalFilledBrush, BindingPriority.Template); + SetCurrentValue(NormalFilledBrushProperty, icon.NormalFilledBrush); } if (icon.ActiveFilledBrush != null) { - SetValue(ActiveFilledBrushProperty, icon.ActiveFilledBrush, BindingPriority.Template); + SetCurrentValue(ActiveFilledBrushProperty, icon.ActiveFilledBrush); } if (icon.SecondaryFilledBrush != null) { - SetValue(SelectedFilledBrushProperty, icon.SecondaryFilledBrush, BindingPriority.Template); + SetCurrentValue(SelectedFilledBrushProperty, icon.SecondaryFilledBrush); } if (icon.SecondaryFilledBrush != null) { - SetValue(DisabledFilledBrushProperty, icon.DisabledFilledBrush, BindingPriority.Template); + SetCurrentValue(DisabledFilledBrushProperty, icon.DisabledFilledBrush); } }