Refactor Button Icon

This commit is contained in:
chinboy
2025-11-25 14:51:26 +08:00
parent 07905c0809
commit 6d8a501376
5 changed files with 19 additions and 23 deletions
@@ -3,7 +3,6 @@ using AtomUI.Animations;
using AtomUI.Controls;
using AtomUI.Desktop.Controls.Primitives;
using AtomUI.Desktop.Controls.Themes;
using AtomUI.Desktop.Controls.Utils;
using AtomUI.Theme;
using AtomUI.Utils;
using Avalonia;
@@ -71,8 +70,8 @@ public class Button : AvaloniaButton,
public static readonly StyledProperty<SizeType> SizeTypeProperty =
SizeTypeControlProperty.SizeTypeProperty.AddOwner<Button>();
public static readonly StyledProperty<Icon?> IconProperty =
AvaloniaProperty.Register<Button, Icon?>(nameof(Icon));
public static readonly StyledProperty<PathIcon?> IconProperty =
AvaloniaProperty.Register<Button, PathIcon?>(nameof(Icon));
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<Button>();
@@ -116,7 +115,7 @@ public class Button : AvaloniaButton,
set => SetValue(SizeTypeProperty, value);
}
public Icon? Icon
public PathIcon? Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
@@ -1,6 +1,5 @@
using AtomUI.Animations;
using AtomUI.Controls;
using AtomUI.Desktop.Controls.Utils;
using AtomUI.Theme;
using AtomUI.Utils;
using Avalonia;
@@ -37,8 +36,8 @@ public class HyperLinkButton : AvaloniaButton,
public static readonly StyledProperty<ButtonSizeType> SizeTypeProperty =
SizeTypeControlProperty.SizeTypeProperty.AddOwner<HyperLinkButton>();
public static readonly StyledProperty<Icon?> IconProperty =
AvaloniaProperty.Register<HyperLinkButton, Icon?>(nameof(Icon));
public static readonly StyledProperty<PathIcon?> IconProperty =
AvaloniaProperty.Register<HyperLinkButton, PathIcon?>(nameof(Icon));
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<HyperLinkButton>();
@@ -77,7 +76,7 @@ public class HyperLinkButton : AvaloniaButton,
set => SetValue(SizeTypeProperty, value);
}
public Icon? Icon
public PathIcon? Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
@@ -82,11 +82,11 @@ public class SplitButton : ContentControl,
public static readonly StyledProperty<SizeType> SizeTypeProperty =
SizeTypeControlProperty.SizeTypeProperty.AddOwner<SplitButton>();
public static readonly StyledProperty<Icon?> IconProperty =
public static readonly StyledProperty<PathIcon?> IconProperty =
Button.IconProperty.AddOwner<SplitButton>();
public static readonly StyledProperty<Icon?> FlyoutButtonIconProperty =
AvaloniaProperty.Register<SplitButton, Icon?>(nameof(FlyoutButtonIcon));
public static readonly StyledProperty<PathIcon?> FlyoutButtonIconProperty =
AvaloniaProperty.Register<SplitButton, PathIcon?>(nameof(FlyoutButtonIcon));
public static readonly StyledProperty<bool> IsDangerProperty =
Button.IsDangerProperty.AddOwner<SplitButton>();
@@ -205,13 +205,13 @@ public class SplitButton : ContentControl,
set => SetValue(SizeTypeProperty, value);
}
public Icon? Icon
public PathIcon? Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
}
public Icon? FlyoutButtonIcon
public PathIcon? FlyoutButtonIcon
{
get => GetValue(FlyoutButtonIconProperty);
set => SetValue(FlyoutButtonIconProperty, value);
@@ -16,8 +16,7 @@
IsDanger="{TemplateBinding IsDanger}"
ButtonType="{TemplateBinding EffectiveButtonType}"
IsMotionEnabled="{TemplateBinding IsMotionEnabled}"
IsWaveSpiritEnabled="{TemplateBinding IsWaveSpiritEnabled}"
/>
IsWaveSpiritEnabled="{TemplateBinding IsWaveSpiritEnabled}"/>
<atom:Button Name="{x:Static atom:SplitButtonThemeConstants.SecondaryButtonPart}"
SizeType="{TemplateBinding SizeType}"
Icon="{TemplateBinding FlyoutButtonIcon}"
@@ -1,5 +1,4 @@
using AtomUI.Controls;
using AtomUI.Theme;
using AtomUI.Theme;
using AtomUI.Utils;
using Avalonia;
using Avalonia.Controls;
@@ -13,11 +12,11 @@ public class ToggleIconButton : ToggleButton,
{
#region 公共属性定义
public static readonly StyledProperty<Icon?> CheckedIconProperty =
AvaloniaProperty.Register<ToggleIconButton, Icon?>(nameof(CheckedIcon));
public static readonly StyledProperty<PathIcon?> CheckedIconProperty =
AvaloniaProperty.Register<ToggleIconButton, PathIcon?>(nameof(CheckedIcon));
public static readonly StyledProperty<Icon?> UnCheckedIconProperty =
AvaloniaProperty.Register<ToggleIconButton, Icon?>(nameof(UnCheckedIcon));
public static readonly StyledProperty<PathIcon?> UnCheckedIconProperty =
AvaloniaProperty.Register<ToggleIconButton, PathIcon?>(nameof(UnCheckedIcon));
public static readonly StyledProperty<double> IconWidthProperty =
AvaloniaProperty.Register<ToggleIconButton, double>(nameof(IconWidth));
@@ -41,13 +40,13 @@ public class ToggleIconButton : ToggleButton,
AvaloniaProperty.Register<ToggleIconButton, IBrush?>(
nameof(DisabledIconBrush));
public Icon? CheckedIcon
public PathIcon? CheckedIcon
{
get => GetValue(CheckedIconProperty);
set => SetValue(CheckedIconProperty, value);
}
public Icon? UnCheckedIcon
public PathIcon? UnCheckedIcon
{
get => GetValue(UnCheckedIconProperty);
set => SetValue(UnCheckedIconProperty, value);