From 95905bc890e1c0c05b636b3c3126f169dc9206d2 Mon Sep 17 00:00:00 2001 From: polarboy Date: Tue, 8 Oct 2024 22:21:49 +0800 Subject: [PATCH] Refactor AnimationUtils --- src/AtomUI.Base/Utils/AnimationUtils.cs | 26 + .../AddOnDecoratedBoxTheme.cs | 2 +- .../AddOnDecoratedInnerBox.cs | 2 +- .../AddOnDecoratedInnerBoxTheme.cs | 2 +- src/AtomUI.Controls/Alert/AlertTheme.cs | 2 +- src/AtomUI.Controls/Badge/CountBadge.cs | 2 +- .../Badge/CountBadgeAdorner.cs | 2 +- src/AtomUI.Controls/Badge/DotBadgeAdorner.cs | 2 +- .../Badge/DotBadgeIndicator.cs | 4 +- src/AtomUI.Controls/Buttons/Button.cs | 2 - src/AtomUI.Controls/Buttons/DropdownButton.cs | 2 +- .../Buttons/IconButtonTheme.cs | 4 +- .../Calendar/BaseCalendarButton.cs | 4 +- .../Calendar/BaseCalendarDayButton.cs | 3 +- .../Calendar/CalendarItemTheme.cs | 2 +- .../Calendar/HeadTextButton.cs | 4 +- .../CheckBox/CheckBoxIndicator.cs | 2 - src/AtomUI.Controls/Collapse/CollapseItem.cs | 2 +- .../Collapse/CollapseItemTheme.cs | 5 +- .../ComboBox/ComboBoxItemTheme.cs | 4 +- src/AtomUI.Controls/ComboBox/ComboBoxTheme.cs | 2 +- .../DatePicker/CalendarView/CalendarButton.cs | 4 +- .../CalendarView/CalendarDayButton.cs | 3 +- .../CalendarView/CalendarItemTheme.cs | 2 +- .../DualMonthCalendarItemTheme.cs | 2 +- .../EmptyIndicator/EmptyIndicator.cs | 2 +- src/AtomUI.Controls/Expander/ExpanderTheme.cs | 5 +- src/AtomUI.Controls/Flyouts/Flyout.cs | 2 +- src/AtomUI.Controls/Flyouts/FlyoutHost.cs | 2 +- .../Flyouts/MenuFlyoutPresenterTheme.cs | 2 +- .../InfoPickerInput/InfoPickerInput.cs | 2 +- .../PickerClearUpButtonTheme.cs | 4 +- .../InfoPickerInput/RangeInfoPickerInput.cs | 2 +- .../RangeInfoPickerInputTheme.cs | 4 +- src/AtomUI.Controls/ListBox/ListBoxItem.cs | 4 +- .../MarqueeLabel/MarqueeLabel.cs | 1 + src/AtomUI.Controls/Menu/Menu.cs | 2 +- src/AtomUI.Controls/Menu/MenuItem.cs | 2 +- src/AtomUI.Controls/Menu/MenuItemTheme.cs | 2 +- .../Menu/TopLevelMenuItemTheme.cs | 2 +- src/AtomUI.Controls/Message/MessageCard.cs | 2 +- .../Message/MessageCardTheme.cs | 7 +- .../NavMenu/BaseNavMenuItemTheme.cs | 2 +- .../NavMenu/HorizontalNavMenuTheme.cs | 10 +- .../NavMenu/InlineNavMenuItemTheme.cs | 43 +- src/AtomUI.Controls/NavMenu/NavMenuItem.cs | 4 +- .../NavMenu/NavMenuItemTheme.cs | 24 +- src/AtomUI.Controls/NavMenu/NavMenuTheme.cs | 2 +- .../TopLevelHorizontalNavMenuItemTheme.cs | 2 +- .../Notifications/NotificationCard.cs | 2 +- .../Notifications/NotificationCardTheme.cs | 8 +- .../Notifications/NotificationProgressBar.cs | 3 +- src/AtomUI.Controls/PathIcon/PathIcon.cs | 4 +- src/AtomUI.Controls/Popup/Popup.cs | 2 +- .../PopupConfirmContainerTheme.cs | 2 +- .../AbstractCircleProgressTheme.cs | 4 +- .../ProgressBar/AbstractLineProgressTheme.cs | 4 +- .../ProgressBar/AbstractProgressBar.cs | 3 +- .../RadioButton/RadioIndicator.cs | 2 - src/AtomUI.Controls/Segmented/Segmented.cs | 4 +- .../Segmented/SegmentedItem.cs | 3 +- src/AtomUI.Controls/Separator/Separator.cs | 1 + src/AtomUI.Controls/Slider/SliderThumb.cs | 4 +- src/AtomUI.Controls/Slider/SliderTrack.cs | 2 +- src/AtomUI.Controls/Switch/SwitchKnob.cs | 2 +- .../TabControl/BaseOverflowMenuItemTheme.cs | 2 +- .../TabControl/BaseTabItemTheme.cs | 2 +- .../TabControl/BaseTabScrollViewer.cs | 2 +- .../TabControl/CardTabItemTheme.cs | 4 +- src/AtomUI.Controls/TabControl/TabControl.cs | 6 +- src/AtomUI.Controls/TabControl/TabItem.cs | 3 +- .../TabStrip/BaseTabStripItemTheme.cs | 2 +- .../TabStrip/CardTabStripItemTheme.cs | 4 +- .../TabControl/TabStrip/TabStrip.cs | 6 +- .../TabControl/TabStrip/TabStripItem.cs | 3 +- src/AtomUI.Controls/Tag/TagTheme.cs | 2 +- .../TimePicker/TimeView/TimeViewTheme.cs | 2 +- src/AtomUI.Controls/Tooltip/ToolTip.cs | 2 +- .../TreeView/DragPreviewAdorner.cs | 4 +- .../TreeView/NodeSwitcherButton.cs | 3 +- src/AtomUI.Controls/TreeView/TreeView.cs | 1 + src/AtomUI.Controls/TreeView/TreeViewItem.cs | 1 - src/AtomUI.Controls/Utils/AnimationUtils.cs | 32 + src/AtomUI.Icon/AtomUI.Icon.csproj | 4 + src/AtomUI.Icon/IconImage.cs | 2 +- src/AtomUI.Icon/PathIcon.cs | 667 ++++++++++++++++++ src/AtomUI.Theme/Data/TokenResourceBinder.cs | 2 +- src/AtomUI.Theme/Utils/AnimationUtils.cs | 64 -- 88 files changed, 873 insertions(+), 222 deletions(-) create mode 100644 src/AtomUI.Base/Utils/AnimationUtils.cs create mode 100644 src/AtomUI.Controls/Utils/AnimationUtils.cs create mode 100644 src/AtomUI.Icon/PathIcon.cs delete mode 100644 src/AtomUI.Theme/Utils/AnimationUtils.cs diff --git a/src/AtomUI.Base/Utils/AnimationUtils.cs b/src/AtomUI.Base/Utils/AnimationUtils.cs new file mode 100644 index 0000000..b15a50c --- /dev/null +++ b/src/AtomUI.Base/Utils/AnimationUtils.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Animation; +using Avalonia.Animation.Easings; + +namespace AtomUI.Utils; + +public class AnimationUtils +{ + protected AnimationUtils() {} + + public static ITransition CreateTransition(AvaloniaProperty targetProperty, + TimeSpan? duration = null, + Easing? easing = null) + where T : TransitionBase, new() + { + easing ??= new LinearEasing(); + duration ??= TimeSpan.FromMilliseconds(300); + var transition = new T + { + Property = targetProperty, + Easing = easing, + Duration = duration.Value + }; + return transition; + } +} \ No newline at end of file diff --git a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedBoxTheme.cs b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedBoxTheme.cs index ceab0f0..e1b96c2 100644 --- a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedBoxTheme.cs +++ b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedBoxTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBox.cs b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBox.cs index 236023c..c081dbf 100644 --- a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBox.cs +++ b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBox.cs @@ -1,7 +1,7 @@ using AtomUI.Controls.Utils; using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Metadata; diff --git a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBoxTheme.cs b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBoxTheme.cs index 04a6c7a..997b306 100644 --- a/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBoxTheme.cs +++ b/src/AtomUI.Controls/AddOnDecoratedBox/AddOnDecoratedInnerBoxTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Media; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/Alert/AlertTheme.cs b/src/AtomUI.Controls/Alert/AlertTheme.cs index de329eb..c869351 100644 --- a/src/AtomUI.Controls/Alert/AlertTheme.cs +++ b/src/AtomUI.Controls/Alert/AlertTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Data; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/Badge/CountBadge.cs b/src/AtomUI.Controls/Badge/CountBadge.cs index 695190b..7ebc93f 100644 --- a/src/AtomUI.Controls/Badge/CountBadge.cs +++ b/src/AtomUI.Controls/Badge/CountBadge.cs @@ -1,7 +1,7 @@ using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Palette; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs b/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs index 42c2b7b..c5183a0 100644 --- a/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs +++ b/src/AtomUI.Controls/Badge/CountBadgeAdorner.cs @@ -1,7 +1,7 @@ using AtomUI.Controls.Badge; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs b/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs index ba3b5c9..d9f682e 100644 --- a/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs +++ b/src/AtomUI.Controls/Badge/DotBadgeAdorner.cs @@ -1,7 +1,7 @@ using AtomUI.Controls.Badge; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Badge/DotBadgeIndicator.cs b/src/AtomUI.Controls/Badge/DotBadgeIndicator.cs index 1eda028..b3e91b6 100644 --- a/src/AtomUI.Controls/Badge/DotBadgeIndicator.cs +++ b/src/AtomUI.Controls/Badge/DotBadgeIndicator.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Controls; using Avalonia.Media; diff --git a/src/AtomUI.Controls/Buttons/Button.cs b/src/AtomUI.Controls/Buttons/Button.cs index 2db1ee7..301a715 100644 --- a/src/AtomUI.Controls/Buttons/Button.cs +++ b/src/AtomUI.Controls/Buttons/Button.cs @@ -5,8 +5,6 @@ using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Theme.TokenSystem; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Buttons/DropdownButton.cs b/src/AtomUI.Controls/Buttons/DropdownButton.cs index 9beee13..89fe802 100644 --- a/src/AtomUI.Controls/Buttons/DropdownButton.cs +++ b/src/AtomUI.Controls/Buttons/DropdownButton.cs @@ -1,8 +1,8 @@ using AtomUI.Data; using AtomUI.Icon; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Theme.TokenSystem; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Diagnostics; diff --git a/src/AtomUI.Controls/Buttons/IconButtonTheme.cs b/src/AtomUI.Controls/Buttons/IconButtonTheme.cs index 80ed45a..910a074 100644 --- a/src/AtomUI.Controls/Buttons/IconButtonTheme.cs +++ b/src/AtomUI.Controls/Buttons/IconButtonTheme.cs @@ -1,7 +1,7 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/Calendar/BaseCalendarButton.cs b/src/AtomUI.Controls/Calendar/BaseCalendarButton.cs index e95d5be..41d7139 100644 --- a/src/AtomUI.Controls/Calendar/BaseCalendarButton.cs +++ b/src/AtomUI.Controls/Calendar/BaseCalendarButton.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Metadata; diff --git a/src/AtomUI.Controls/Calendar/BaseCalendarDayButton.cs b/src/AtomUI.Controls/Calendar/BaseCalendarDayButton.cs index 7514ee6..818234d 100644 --- a/src/AtomUI.Controls/Calendar/BaseCalendarDayButton.cs +++ b/src/AtomUI.Controls/Calendar/BaseCalendarDayButton.cs @@ -1,9 +1,8 @@ using System.Globalization; +using AtomUI.Controls.Utils; using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Calendar/CalendarItemTheme.cs b/src/AtomUI.Controls/Calendar/CalendarItemTheme.cs index 155849a..d8fbbfa 100644 --- a/src/AtomUI.Controls/Calendar/CalendarItemTheme.cs +++ b/src/AtomUI.Controls/Calendar/CalendarItemTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia.Controls; using Avalonia.Controls.Templates; using Avalonia.Data; diff --git a/src/AtomUI.Controls/Calendar/HeadTextButton.cs b/src/AtomUI.Controls/Calendar/HeadTextButton.cs index 06e33b8..bdb34aa 100644 --- a/src/AtomUI.Controls/Calendar/HeadTextButton.cs +++ b/src/AtomUI.Controls/Calendar/HeadTextButton.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/CheckBox/CheckBoxIndicator.cs b/src/AtomUI.Controls/CheckBox/CheckBoxIndicator.cs index f8d8313..608f51c 100644 --- a/src/AtomUI.Controls/CheckBox/CheckBoxIndicator.cs +++ b/src/AtomUI.Controls/CheckBox/CheckBoxIndicator.cs @@ -2,8 +2,6 @@ using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; diff --git a/src/AtomUI.Controls/Collapse/CollapseItem.cs b/src/AtomUI.Controls/Collapse/CollapseItem.cs index 2401d44..c57218e 100644 --- a/src/AtomUI.Controls/Collapse/CollapseItem.cs +++ b/src/AtomUI.Controls/Collapse/CollapseItem.cs @@ -1,7 +1,7 @@ using AtomUI.Controls.Utils; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation.Easings; using Avalonia.Automation.Peers; diff --git a/src/AtomUI.Controls/Collapse/CollapseItemTheme.cs b/src/AtomUI.Controls/Collapse/CollapseItemTheme.cs index 5cffa41..f2659e2 100644 --- a/src/AtomUI.Controls/Collapse/CollapseItemTheme.cs +++ b/src/AtomUI.Controls/Collapse/CollapseItemTheme.cs @@ -1,8 +1,7 @@ -using AtomUI.Controls.Primitives; -using AtomUI.MotionScene; +using AtomUI.MotionScene; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/ComboBox/ComboBoxItemTheme.cs b/src/AtomUI.Controls/ComboBox/ComboBoxItemTheme.cs index 4404b40..cb59880 100644 --- a/src/AtomUI.Controls/ComboBox/ComboBoxItemTheme.cs +++ b/src/AtomUI.Controls/ComboBox/ComboBoxItemTheme.cs @@ -1,7 +1,7 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/ComboBox/ComboBoxTheme.cs b/src/AtomUI.Controls/ComboBox/ComboBoxTheme.cs index d5246c0..65a70e7 100644 --- a/src/AtomUI.Controls/ComboBox/ComboBoxTheme.cs +++ b/src/AtomUI.Controls/ComboBox/ComboBoxTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Documents; diff --git a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarButton.cs b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarButton.cs index 2ab9b69..80baef1 100644 --- a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarButton.cs +++ b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarButton.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Metadata; diff --git a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarDayButton.cs b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarDayButton.cs index c8437d5..031b557 100644 --- a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarDayButton.cs +++ b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarDayButton.cs @@ -1,9 +1,8 @@ using System.Globalization; +using AtomUI.Controls.Utils; using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarItemTheme.cs b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarItemTheme.cs index cac18cd..0cea5b4 100644 --- a/src/AtomUI.Controls/DatePicker/CalendarView/CalendarItemTheme.cs +++ b/src/AtomUI.Controls/DatePicker/CalendarView/CalendarItemTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Data; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/DatePicker/CalendarView/DualMonthCalendarItemTheme.cs b/src/AtomUI.Controls/DatePicker/CalendarView/DualMonthCalendarItemTheme.cs index 1f4d43c..6e226a7 100644 --- a/src/AtomUI.Controls/DatePicker/CalendarView/DualMonthCalendarItemTheme.cs +++ b/src/AtomUI.Controls/DatePicker/CalendarView/DualMonthCalendarItemTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs index bdb60fc..375e824 100644 --- a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs +++ b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs @@ -1,6 +1,6 @@ using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Expander/ExpanderTheme.cs b/src/AtomUI.Controls/Expander/ExpanderTheme.cs index 932453e..e337fc8 100644 --- a/src/AtomUI.Controls/Expander/ExpanderTheme.cs +++ b/src/AtomUI.Controls/Expander/ExpanderTheme.cs @@ -1,8 +1,7 @@ -using AtomUI.Controls.Primitives; -using AtomUI.MotionScene; +using AtomUI.MotionScene; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/Flyouts/Flyout.cs b/src/AtomUI.Controls/Flyouts/Flyout.cs index 9a3b8eb..7a8641e 100644 --- a/src/AtomUI.Controls/Flyouts/Flyout.cs +++ b/src/AtomUI.Controls/Flyouts/Flyout.cs @@ -1,8 +1,8 @@ using System.ComponentModel; using System.Reactive.Disposables; using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives.PopupPositioning; diff --git a/src/AtomUI.Controls/Flyouts/FlyoutHost.cs b/src/AtomUI.Controls/Flyouts/FlyoutHost.cs index 0c65d82..2feaa6c 100644 --- a/src/AtomUI.Controls/Flyouts/FlyoutHost.cs +++ b/src/AtomUI.Controls/Flyouts/FlyoutHost.cs @@ -1,6 +1,6 @@ using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives.PopupPositioning; diff --git a/src/AtomUI.Controls/Flyouts/MenuFlyoutPresenterTheme.cs b/src/AtomUI.Controls/Flyouts/MenuFlyoutPresenterTheme.cs index 6b21dda..e36a078 100644 --- a/src/AtomUI.Controls/Flyouts/MenuFlyoutPresenterTheme.cs +++ b/src/AtomUI.Controls/Flyouts/MenuFlyoutPresenterTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInput.cs b/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInput.cs index c8ef3ff..177ab22 100644 --- a/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInput.cs +++ b/src/AtomUI.Controls/Internal/InfoPickerInput/InfoPickerInput.cs @@ -1,6 +1,6 @@ using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Diagnostics; diff --git a/src/AtomUI.Controls/Internal/InfoPickerInput/PickerClearUpButtonTheme.cs b/src/AtomUI.Controls/Internal/InfoPickerInput/PickerClearUpButtonTheme.cs index de034b4..c241dc1 100644 --- a/src/AtomUI.Controls/Internal/InfoPickerInput/PickerClearUpButtonTheme.cs +++ b/src/AtomUI.Controls/Internal/InfoPickerInput/PickerClearUpButtonTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; @@ -74,7 +74,7 @@ internal class PickerClearUpButtonTheme : BaseControlTheme PickerClearUpButton.IsInClearModeProperty); layout.Children.Add(clearButton); } - + protected override void BuildInstanceStyles(Control control) { var iconStyle = new Style(selector => selector.Name(InfoIconContentPart).Child().OfType()); diff --git a/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInput.cs b/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInput.cs index 11d1eef..8d812db 100644 --- a/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInput.cs +++ b/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInput.cs @@ -1,4 +1,4 @@ -using AtomUI.Theme.Utils; +using AtomUI.Controls.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInputTheme.cs b/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInputTheme.cs index dce5721..338f3da 100644 --- a/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInputTheme.cs +++ b/src/AtomUI.Controls/Internal/InfoPickerInput/RangeInfoPickerInputTheme.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia.Controls; using Avalonia.Controls.Shapes; using Avalonia.Controls.Templates; diff --git a/src/AtomUI.Controls/ListBox/ListBoxItem.cs b/src/AtomUI.Controls/ListBox/ListBoxItem.cs index 4083bea..02f8a1c 100644 --- a/src/AtomUI.Controls/ListBox/ListBoxItem.cs +++ b/src/AtomUI.Controls/ListBox/ListBoxItem.cs @@ -1,5 +1,5 @@ -using AtomUI.Media; -using AtomUI.Theme.Utils; +using AtomUI.Controls.Utils; +using AtomUI.Media; using Avalonia; using Avalonia.Animation; using Avalonia.LogicalTree; diff --git a/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs b/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs index e136d7a..751ef5d 100644 --- a/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs +++ b/src/AtomUI.Controls/MarqueeLabel/MarqueeLabel.cs @@ -1,3 +1,4 @@ +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Utils; using Avalonia; diff --git a/src/AtomUI.Controls/Menu/Menu.cs b/src/AtomUI.Controls/Menu/Menu.cs index 50fdc59..68afb64 100644 --- a/src/AtomUI.Controls/Menu/Menu.cs +++ b/src/AtomUI.Controls/Menu/Menu.cs @@ -1,5 +1,5 @@ using AtomUI.Data; -using AtomUI.Utils; +using AtomUI.Theme.Data; using Avalonia; using Avalonia.Controls; using Avalonia.LogicalTree; diff --git a/src/AtomUI.Controls/Menu/MenuItem.cs b/src/AtomUI.Controls/Menu/MenuItem.cs index fefd822..c31deb4 100644 --- a/src/AtomUI.Controls/Menu/MenuItem.cs +++ b/src/AtomUI.Controls/Menu/MenuItem.cs @@ -1,7 +1,7 @@ using AtomUI.Data; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/Menu/MenuItemTheme.cs b/src/AtomUI.Controls/Menu/MenuItemTheme.cs index 41eeacc..6270b9c 100644 --- a/src/AtomUI.Controls/Menu/MenuItemTheme.cs +++ b/src/AtomUI.Controls/Menu/MenuItemTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Media; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/Menu/TopLevelMenuItemTheme.cs b/src/AtomUI.Controls/Menu/TopLevelMenuItemTheme.cs index e7befe8..81594ab 100644 --- a/src/AtomUI.Controls/Menu/TopLevelMenuItemTheme.cs +++ b/src/AtomUI.Controls/Menu/TopLevelMenuItemTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Message/MessageCard.cs b/src/AtomUI.Controls/Message/MessageCard.cs index 727a1c0..7e608af 100644 --- a/src/AtomUI.Controls/Message/MessageCard.cs +++ b/src/AtomUI.Controls/Message/MessageCard.cs @@ -1,7 +1,7 @@ using AtomUI.Icon; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation.Easings; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Message/MessageCardTheme.cs b/src/AtomUI.Controls/Message/MessageCardTheme.cs index feacabc..67c1e52 100644 --- a/src/AtomUI.Controls/Message/MessageCardTheme.cs +++ b/src/AtomUI.Controls/Message/MessageCardTheme.cs @@ -1,11 +1,8 @@ -using AtomUI.Controls.Primitives; -using AtomUI.MotionScene; +using AtomUI.MotionScene; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; -using Avalonia.Animation; -using Avalonia.Animation.Easings; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Templates; diff --git a/src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs b/src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs index b57a3b3..20fc48f 100644 --- a/src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs +++ b/src/AtomUI.Controls/NavMenu/BaseNavMenuItemTheme.cs @@ -1,8 +1,8 @@ using AtomUI.Icon; using AtomUI.Media; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/NavMenu/HorizontalNavMenuTheme.cs b/src/AtomUI.Controls/NavMenu/HorizontalNavMenuTheme.cs index a10e4ec..a8c0c59 100644 --- a/src/AtomUI.Controls/NavMenu/HorizontalNavMenuTheme.cs +++ b/src/AtomUI.Controls/NavMenu/HorizontalNavMenuTheme.cs @@ -1,11 +1,9 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Shapes; using Avalonia.Controls.Templates; -using Avalonia.Data; -using Avalonia.Data.Converters; using Avalonia.Layout; using Avalonia.Styling; @@ -15,12 +13,12 @@ namespace AtomUI.Controls; internal class HorizontalNavMenuTheme : BaseNavMenuTheme { public const string ID = "HorizontalNavMenu"; - + public HorizontalNavMenuTheme() : base(typeof(NavMenu)) { } - + public override string ThemeResourceKey() { return ID; diff --git a/src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs b/src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs index 8a50680..4c68fdd 100644 --- a/src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs +++ b/src/AtomUI.Controls/NavMenu/InlineNavMenuItemTheme.cs @@ -1,7 +1,6 @@ -using AtomUI.Controls.Primitives; -using AtomUI.MotionScene; +using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; @@ -23,19 +22,19 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme public const string MenuIndicatorIconLayoutPart = "PART_MenuIndicatorIconLayout"; public const string ChildItemsPresenterPart = "PART_ChildItemsPresenter"; public const string ChildItemsLayoutTransformPart = "PART_ChildItemsLayoutTransform"; - + public InlineNavMenuItemTheme() : base(typeof(NavMenuItem)) { } - + public override string ThemeResourceKey() { return ID; } - + protected override Control BuildMenuIndicatorIcon(INameScope scope) { - var indicatorIcon = base.BuildMenuIndicatorIcon(scope); + var indicatorIcon = base.BuildMenuIndicatorIcon(scope); var menuIndicatorIconPresenter = new Border() { Name = MenuIndicatorIconLayoutPart, @@ -55,14 +54,14 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme { Orientation = Orientation.Vertical }; - + var headerContent = base.BuildMenuItemContent(navMenuItem, scope); - + var childItemsLayoutTransform = new MotionActorControl() { - Name = ChildItemsLayoutTransformPart, + Name = ChildItemsLayoutTransformPart, }; - TokenResourceBinder.CreateTokenBinding(childItemsLayoutTransform, MotionActorControl.MarginProperty, + TokenResourceBinder.CreateTokenBinding(childItemsLayoutTransform, MotionActorControl.MarginProperty, NavMenuTokenResourceKey.VerticalItemsPanelSpacing, BindingPriority.Template, (v) => { @@ -74,7 +73,7 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme return new Thickness(); }); childItemsLayoutTransform.RegisterInNameScope(scope); - + var itemsPresenter = new ItemsPresenter { Name = ChildItemsPresenterPart, @@ -84,7 +83,7 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme CreateTemplateParentBinding(itemsPresenter, ItemsPresenter.ItemsPanelProperty, NavMenuItem.ItemsPanelProperty); childItemsLayoutTransform.Child = itemsPresenter; - + rootLayout.Children.Add(headerContent); rootLayout.Children.Add(childItemsLayoutTransform); return rootLayout; @@ -109,8 +108,9 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme { base.BuildStyles(); BuildMenuIndicatorStyle(); - - var itemsPanelStyle = new Style(selector => selector.Nesting().Template().Name(ChildItemsPresenterPart).Child().OfType()); + + var itemsPanelStyle = new Style(selector => + selector.Nesting().Template().Name(ChildItemsPresenterPart).Child().OfType()); itemsPanelStyle.Add(StackPanel.SpacingProperty, NavMenuTokenResourceKey.VerticalItemsPanelSpacing); Add(itemsPanelStyle); } @@ -118,8 +118,9 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme private void BuildMenuIndicatorStyle() { { - var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); - var transformOptions = new TransformOperations.Builder(1); + var menuIndicatorStyle = + new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); + var transformOptions = new TransformOperations.Builder(1); transformOptions.AppendRotate(MathUtils.Deg2Rad(90)); menuIndicatorStyle.Add(Border.RenderTransformProperty, transformOptions.Build()); menuIndicatorStyle.Add(Visual.IsVisibleProperty, true); @@ -127,8 +128,9 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme } var openSubMenuStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Open)); { - var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); - var transformOptions = new TransformOperations.Builder(1); + var menuIndicatorStyle = + new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); + var transformOptions = new TransformOperations.Builder(1); transformOptions.AppendRotate(MathUtils.Deg2Rad(-90)); menuIndicatorStyle.Add(Border.RenderTransformProperty, transformOptions.Build()); openSubMenuStyle.Add(menuIndicatorStyle); @@ -136,7 +138,8 @@ internal class InlineNavMenuItemTheme : BaseNavMenuItemTheme Add(openSubMenuStyle); var emptySubMenuStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Empty)); { - var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); + var menuIndicatorStyle = + new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconLayoutPart)); menuIndicatorStyle.Add(Visual.IsVisibleProperty, false); emptySubMenuStyle.Add(menuIndicatorStyle); } diff --git a/src/AtomUI.Controls/NavMenu/NavMenuItem.cs b/src/AtomUI.Controls/NavMenu/NavMenuItem.cs index 0ba5b6c..96a89c2 100644 --- a/src/AtomUI.Controls/NavMenu/NavMenuItem.cs +++ b/src/AtomUI.Controls/NavMenu/NavMenuItem.cs @@ -1,12 +1,12 @@ using System.Windows.Input; +using AtomUI.Controls.Utils; using AtomUI.Data; using AtomUI.Icon; using AtomUI.Input; using AtomUI.Media; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; diff --git a/src/AtomUI.Controls/NavMenu/NavMenuItemTheme.cs b/src/AtomUI.Controls/NavMenu/NavMenuItemTheme.cs index a9d4726..ce75980 100644 --- a/src/AtomUI.Controls/NavMenu/NavMenuItemTheme.cs +++ b/src/AtomUI.Controls/NavMenu/NavMenuItemTheme.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Templates; @@ -14,23 +14,23 @@ internal class NavMenuItemTheme : BaseNavMenuItemTheme { public const string ItemsPresenterPart = "PART_ItemsPresenter"; public const string PopupFramePart = "PART_PopupFrame"; - + public NavMenuItemTheme() : base(typeof(NavMenuItem)) { } - + protected NavMenuItemTheme(Type targetType) : base(targetType) { } - + protected override void BuildExtraItem(Panel layout, INameScope scope) { var popup = CreateMenuPopup(); popup.RegisterInNameScope(scope); layout.Children.Add(popup); } - + protected Popup CreateMenuPopup() { var popup = new Popup @@ -45,7 +45,7 @@ internal class NavMenuItemTheme : BaseNavMenuItemTheme { Name = PopupFramePart }; - + TokenResourceBinder.CreateTokenBinding(popup, Popup.MarginToAnchorProperty, NavMenuTokenResourceKey.TopLevelItemPopupMarginToAnchor); TokenResourceBinder.CreateTokenBinding(border, Border.CornerRadiusProperty, @@ -80,11 +80,12 @@ internal class NavMenuItemTheme : BaseNavMenuItemTheme return popup; } - + protected override void BuildStyles() { base.BuildStyles(); - var itemsPanelStyle = new Style(selector => selector.Nesting().Template().Name(ItemsPresenterPart).Child().OfType()); + var itemsPanelStyle = new Style(selector => + selector.Nesting().Template().Name(ItemsPresenterPart).Child().OfType()); itemsPanelStyle.Add(StackPanel.SpacingProperty, NavMenuTokenResourceKey.VerticalItemsPanelSpacing); Add(itemsPanelStyle); @@ -93,8 +94,9 @@ internal class NavMenuItemTheme : BaseNavMenuItemTheme popupFrameStyle.Add(Border.BackgroundProperty, GlobalTokenResourceKey.ColorBgContainer); Add(popupFrameStyle); } - - var darkCommonStyle = new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.IsDarkStyleProperty, true)); + + var darkCommonStyle = + new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.IsDarkStyleProperty, true)); { var popupFrameStyle = new Style(selector => selector.Nesting().Template().Name(PopupFramePart)); popupFrameStyle.Add(Border.BackgroundProperty, NavMenuTokenResourceKey.DarkItemBg); diff --git a/src/AtomUI.Controls/NavMenu/NavMenuTheme.cs b/src/AtomUI.Controls/NavMenu/NavMenuTheme.cs index ac336c2..2188f10 100644 --- a/src/AtomUI.Controls/NavMenu/NavMenuTheme.cs +++ b/src/AtomUI.Controls/NavMenu/NavMenuTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/NavMenu/TopLevelHorizontalNavMenuItemTheme.cs b/src/AtomUI.Controls/NavMenu/TopLevelHorizontalNavMenuItemTheme.cs index 28877d7..266a608 100644 --- a/src/AtomUI.Controls/NavMenu/TopLevelHorizontalNavMenuItemTheme.cs +++ b/src/AtomUI.Controls/NavMenu/TopLevelHorizontalNavMenuItemTheme.cs @@ -1,8 +1,8 @@ using AtomUI.Icon; using AtomUI.Media; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Notifications/NotificationCard.cs b/src/AtomUI.Controls/Notifications/NotificationCard.cs index 58a09aa..0ba75b0 100644 --- a/src/AtomUI.Controls/Notifications/NotificationCard.cs +++ b/src/AtomUI.Controls/Notifications/NotificationCard.cs @@ -1,6 +1,6 @@ using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; diff --git a/src/AtomUI.Controls/Notifications/NotificationCardTheme.cs b/src/AtomUI.Controls/Notifications/NotificationCardTheme.cs index 2717a2e..ae3cd65 100644 --- a/src/AtomUI.Controls/Notifications/NotificationCardTheme.cs +++ b/src/AtomUI.Controls/Notifications/NotificationCardTheme.cs @@ -1,12 +1,8 @@ -using AtomUI.Controls.Primitives; -using AtomUI.Controls.Utils; -using AtomUI.MotionScene; +using AtomUI.MotionScene; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; -using Avalonia.Animation; -using Avalonia.Animation.Easings; using Avalonia.Controls; using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Notifications/NotificationProgressBar.cs b/src/AtomUI.Controls/Notifications/NotificationProgressBar.cs index 76bf386..c4c7cf7 100644 --- a/src/AtomUI.Controls/Notifications/NotificationProgressBar.cs +++ b/src/AtomUI.Controls/Notifications/NotificationProgressBar.cs @@ -1,4 +1,5 @@ -using AtomUI.Theme.Styling; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using AtomUI.Utils; using Avalonia; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/PathIcon/PathIcon.cs b/src/AtomUI.Controls/PathIcon/PathIcon.cs index 9b13531..011ae81 100644 --- a/src/AtomUI.Controls/PathIcon/PathIcon.cs +++ b/src/AtomUI.Controls/PathIcon/PathIcon.cs @@ -1,6 +1,6 @@ -using AtomUI.Icon; +using AtomUI.Controls.Utils; +using AtomUI.Icon; using AtomUI.Media; -using AtomUI.Theme.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Popup/Popup.cs b/src/AtomUI.Controls/Popup/Popup.cs index 6997184..38b8af7 100644 --- a/src/AtomUI.Controls/Popup/Popup.cs +++ b/src/AtomUI.Controls/Popup/Popup.cs @@ -1,8 +1,8 @@ using System.Reactive.Disposables; using AtomUI.Data; using AtomUI.MotionScene; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Diagnostics; diff --git a/src/AtomUI.Controls/PopupConfirm/PopupConfirmContainerTheme.cs b/src/AtomUI.Controls/PopupConfirm/PopupConfirmContainerTheme.cs index f2fa127..bccd417 100644 --- a/src/AtomUI.Controls/PopupConfirm/PopupConfirmContainerTheme.cs +++ b/src/AtomUI.Controls/PopupConfirm/PopupConfirmContainerTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/ProgressBar/AbstractCircleProgressTheme.cs b/src/AtomUI.Controls/ProgressBar/AbstractCircleProgressTheme.cs index c83c9c8..3036469 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractCircleProgressTheme.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractCircleProgressTheme.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Templates; diff --git a/src/AtomUI.Controls/ProgressBar/AbstractLineProgressTheme.cs b/src/AtomUI.Controls/ProgressBar/AbstractLineProgressTheme.cs index 5a967f0..b32805f 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractLineProgressTheme.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractLineProgressTheme.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; diff --git a/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs b/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs index dcb25a1..10f3064 100644 --- a/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs +++ b/src/AtomUI.Controls/ProgressBar/AbstractProgressBar.cs @@ -1,6 +1,6 @@ using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; @@ -10,6 +10,7 @@ using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Data; using Avalonia.Media; +using AnimationUtils = AtomUI.Controls.Utils.AnimationUtils; namespace AtomUI.Controls; diff --git a/src/AtomUI.Controls/RadioButton/RadioIndicator.cs b/src/AtomUI.Controls/RadioButton/RadioIndicator.cs index 9af5071..15dc320 100644 --- a/src/AtomUI.Controls/RadioButton/RadioIndicator.cs +++ b/src/AtomUI.Controls/RadioButton/RadioIndicator.cs @@ -2,8 +2,6 @@ using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Segmented/Segmented.cs b/src/AtomUI.Controls/Segmented/Segmented.cs index 60ab476..8dc1803 100644 --- a/src/AtomUI.Controls/Segmented/Segmented.cs +++ b/src/AtomUI.Controls/Segmented/Segmented.cs @@ -1,6 +1,6 @@ -using AtomUI.Data; +using AtomUI.Controls.Utils; +using AtomUI.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Segmented/SegmentedItem.cs b/src/AtomUI.Controls/Segmented/SegmentedItem.cs index 8a95cb6..a935bb1 100644 --- a/src/AtomUI.Controls/Segmented/SegmentedItem.cs +++ b/src/AtomUI.Controls/Segmented/SegmentedItem.cs @@ -1,8 +1,7 @@ using AtomUI.Controls.Utils; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Separator/Separator.cs b/src/AtomUI.Controls/Separator/Separator.cs index 9e1c841..c9ed423 100644 --- a/src/AtomUI.Controls/Separator/Separator.cs +++ b/src/AtomUI.Controls/Separator/Separator.cs @@ -1,4 +1,5 @@ using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Utils; using Avalonia; diff --git a/src/AtomUI.Controls/Slider/SliderThumb.cs b/src/AtomUI.Controls/Slider/SliderThumb.cs index 523d45a..e75c8b2 100644 --- a/src/AtomUI.Controls/Slider/SliderThumb.cs +++ b/src/AtomUI.Controls/Slider/SliderThumb.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Automation.Peers; diff --git a/src/AtomUI.Controls/Slider/SliderTrack.cs b/src/AtomUI.Controls/Slider/SliderTrack.cs index 8aa8221..1e61716 100644 --- a/src/AtomUI.Controls/Slider/SliderTrack.cs +++ b/src/AtomUI.Controls/Slider/SliderTrack.cs @@ -1,7 +1,7 @@ using System.Globalization; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/Switch/SwitchKnob.cs b/src/AtomUI.Controls/Switch/SwitchKnob.cs index 5b66b2b..0aa2cda 100644 --- a/src/AtomUI.Controls/Switch/SwitchKnob.cs +++ b/src/AtomUI.Controls/Switch/SwitchKnob.cs @@ -1,7 +1,7 @@ using AtomUI.Data; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/TabControl/BaseOverflowMenuItemTheme.cs b/src/AtomUI.Controls/TabControl/BaseOverflowMenuItemTheme.cs index bdbb3b8..1256dff 100644 --- a/src/AtomUI.Controls/TabControl/BaseOverflowMenuItemTheme.cs +++ b/src/AtomUI.Controls/TabControl/BaseOverflowMenuItemTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Media; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using AtomUI.Utils; using Avalonia; using Avalonia.Animation; diff --git a/src/AtomUI.Controls/TabControl/BaseTabItemTheme.cs b/src/AtomUI.Controls/TabControl/BaseTabItemTheme.cs index a0f2496..114df8e 100644 --- a/src/AtomUI.Controls/TabControl/BaseTabItemTheme.cs +++ b/src/AtomUI.Controls/TabControl/BaseTabItemTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Icon; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs b/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs index bcacd85..d136cdc 100644 --- a/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs +++ b/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs @@ -1,6 +1,6 @@ using System.Globalization; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Converters; diff --git a/src/AtomUI.Controls/TabControl/CardTabItemTheme.cs b/src/AtomUI.Controls/TabControl/CardTabItemTheme.cs index c6035ab..de27681 100644 --- a/src/AtomUI.Controls/TabControl/CardTabItemTheme.cs +++ b/src/AtomUI.Controls/TabControl/CardTabItemTheme.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/TabControl/TabControl.cs b/src/AtomUI.Controls/TabControl/TabControl.cs index 97c57f3..7f810f6 100644 --- a/src/AtomUI.Controls/TabControl/TabControl.cs +++ b/src/AtomUI.Controls/TabControl/TabControl.cs @@ -1,6 +1,6 @@ -using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; +using AtomUI.Controls.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; diff --git a/src/AtomUI.Controls/TabControl/TabItem.cs b/src/AtomUI.Controls/TabControl/TabItem.cs index abad225..29f7ef9 100644 --- a/src/AtomUI.Controls/TabControl/TabItem.cs +++ b/src/AtomUI.Controls/TabControl/TabItem.cs @@ -1,9 +1,8 @@ using AtomUI.Controls.Utils; using AtomUI.Icon; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStripItemTheme.cs b/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStripItemTheme.cs index cb2ec57..d7482cb 100644 --- a/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStripItemTheme.cs +++ b/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStripItemTheme.cs @@ -1,7 +1,7 @@ using AtomUI.Icon; using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Presenters; diff --git a/src/AtomUI.Controls/TabControl/TabStrip/CardTabStripItemTheme.cs b/src/AtomUI.Controls/TabControl/TabStrip/CardTabStripItemTheme.cs index 59d3c48..3b1d5b7 100644 --- a/src/AtomUI.Controls/TabControl/TabStrip/CardTabStripItemTheme.cs +++ b/src/AtomUI.Controls/TabControl/TabStrip/CardTabStripItemTheme.cs @@ -1,6 +1,6 @@ -using AtomUI.Media; +using AtomUI.Controls.Utils; +using AtomUI.Media; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/TabControl/TabStrip/TabStrip.cs b/src/AtomUI.Controls/TabControl/TabStrip/TabStrip.cs index 60aadb3..8206557 100644 --- a/src/AtomUI.Controls/TabControl/TabStrip/TabStrip.cs +++ b/src/AtomUI.Controls/TabControl/TabStrip/TabStrip.cs @@ -1,6 +1,6 @@ -using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; +using AtomUI.Controls.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Animation; using Avalonia.Animation.Easings; diff --git a/src/AtomUI.Controls/TabControl/TabStrip/TabStripItem.cs b/src/AtomUI.Controls/TabControl/TabStrip/TabStripItem.cs index a170046..7d1da9b 100644 --- a/src/AtomUI.Controls/TabControl/TabStrip/TabStripItem.cs +++ b/src/AtomUI.Controls/TabControl/TabStrip/TabStripItem.cs @@ -1,9 +1,8 @@ using AtomUI.Controls.Utils; using AtomUI.Icon; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Tag/TagTheme.cs b/src/AtomUI.Controls/Tag/TagTheme.cs index 8306a7f..e5b20b7 100644 --- a/src/AtomUI.Controls/Tag/TagTheme.cs +++ b/src/AtomUI.Controls/Tag/TagTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/TimePicker/TimeView/TimeViewTheme.cs b/src/AtomUI.Controls/TimePicker/TimeView/TimeViewTheme.cs index 062abf5..896baa3 100644 --- a/src/AtomUI.Controls/TimePicker/TimeView/TimeViewTheme.cs +++ b/src/AtomUI.Controls/TimePicker/TimeView/TimeViewTheme.cs @@ -1,6 +1,6 @@ using AtomUI.Theme; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/Tooltip/ToolTip.cs b/src/AtomUI.Controls/Tooltip/ToolTip.cs index 4300e17..7c2be78 100644 --- a/src/AtomUI.Controls/Tooltip/ToolTip.cs +++ b/src/AtomUI.Controls/Tooltip/ToolTip.cs @@ -1,7 +1,7 @@ using AtomUI.Reflection; +using AtomUI.Theme.Data; using AtomUI.Theme.Palette; using AtomUI.Theme.Styling; -using AtomUI.Utils; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Diagnostics; diff --git a/src/AtomUI.Controls/TreeView/DragPreviewAdorner.cs b/src/AtomUI.Controls/TreeView/DragPreviewAdorner.cs index fb4068f..76be87a 100644 --- a/src/AtomUI.Controls/TreeView/DragPreviewAdorner.cs +++ b/src/AtomUI.Controls/TreeView/DragPreviewAdorner.cs @@ -1,5 +1,5 @@ -using AtomUI.Theme.Styling; -using AtomUI.Utils; +using AtomUI.Theme.Data; +using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Controls; using Avalonia.Layout; diff --git a/src/AtomUI.Controls/TreeView/NodeSwitcherButton.cs b/src/AtomUI.Controls/TreeView/NodeSwitcherButton.cs index 28f87a1..175eb63 100644 --- a/src/AtomUI.Controls/TreeView/NodeSwitcherButton.cs +++ b/src/AtomUI.Controls/TreeView/NodeSwitcherButton.cs @@ -2,9 +2,8 @@ using AtomUI.Data; using AtomUI.Icon; using AtomUI.Media; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; -using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls.Primitives; diff --git a/src/AtomUI.Controls/TreeView/TreeView.cs b/src/AtomUI.Controls/TreeView/TreeView.cs index 10f90e8..75d27fa 100644 --- a/src/AtomUI.Controls/TreeView/TreeView.cs +++ b/src/AtomUI.Controls/TreeView/TreeView.cs @@ -1,5 +1,6 @@ using AtomUI.Controls.Utils; using AtomUI.Data; +using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Utils; using Avalonia; diff --git a/src/AtomUI.Controls/TreeView/TreeViewItem.cs b/src/AtomUI.Controls/TreeView/TreeViewItem.cs index 42d3918..91ec0b4 100644 --- a/src/AtomUI.Controls/TreeView/TreeViewItem.cs +++ b/src/AtomUI.Controls/TreeView/TreeViewItem.cs @@ -3,7 +3,6 @@ using AtomUI.Media; using AtomUI.Theme.Data; using AtomUI.Theme.Styling; using AtomUI.Theme.Utils; -using AtomUI.Utils; using Avalonia; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/AtomUI.Controls/Utils/AnimationUtils.cs b/src/AtomUI.Controls/Utils/AnimationUtils.cs new file mode 100644 index 0000000..cef6f29 --- /dev/null +++ b/src/AtomUI.Controls/Utils/AnimationUtils.cs @@ -0,0 +1,32 @@ +using AtomUI.Theme.Styling; +using AtomUI.Theme.TokenSystem; +using Avalonia; +using Avalonia.Animation; +using Avalonia.Animation.Easings; +using Avalonia.Controls; + +namespace AtomUI.Controls.Utils; + +public sealed class AnimationUtils : AtomUI.Utils.AnimationUtils +{ + public static ITransition CreateTransition(AvaloniaProperty targetProperty, + TokenResourceKey? durationResourceKey = null, + Easing? easing = null) + where T : TransitionBase, new() + { + easing ??= new LinearEasing(); + durationResourceKey ??= GlobalTokenResourceKey.MotionDurationMid; + var transition = new T + { + Property = targetProperty, + Easing = easing + }; + var application = Application.Current; + if (application is not null) + { + transition.Bind(TransitionBase.DurationProperty, application.GetResourceObservable(durationResourceKey)); + } + + return transition; + } +} \ No newline at end of file diff --git a/src/AtomUI.Icon/AtomUI.Icon.csproj b/src/AtomUI.Icon/AtomUI.Icon.csproj index 644b7f3..f352ba6 100644 --- a/src/AtomUI.Icon/AtomUI.Icon.csproj +++ b/src/AtomUI.Icon/AtomUI.Icon.csproj @@ -7,4 +7,8 @@ + + + + diff --git a/src/AtomUI.Icon/IconImage.cs b/src/AtomUI.Icon/IconImage.cs index 88af8d4..9cf6a0c 100644 --- a/src/AtomUI.Icon/IconImage.cs +++ b/src/AtomUI.Icon/IconImage.cs @@ -3,7 +3,7 @@ using Avalonia.Media; namespace AtomUI.Icon; -public class IconImage : DrawingImage, IImage +internal class IconImage : DrawingImage, IImage { public static readonly StyledProperty DataProperty = AvaloniaProperty.Register< IconImage, diff --git a/src/AtomUI.Icon/PathIcon.cs b/src/AtomUI.Icon/PathIcon.cs new file mode 100644 index 0000000..1ee9e48 --- /dev/null +++ b/src/AtomUI.Icon/PathIcon.cs @@ -0,0 +1,667 @@ +using AtomUI.Media; +using AtomUI.Utils; +using Avalonia; +using Avalonia.Animation; +using Avalonia.Controls; +using Avalonia.Layout; +using Avalonia.LogicalTree; +using Avalonia.Media; +using Avalonia.Reactive; +using Avalonia.Rendering; +using Avalonia.Styling; + +namespace AtomUI.Icon; + +public sealed class PathIcon : Control, ICustomHitTest +{ + public static readonly StyledProperty KindProperty = AvaloniaProperty.Register( + nameof(Kind), string.Empty); + + public static readonly StyledProperty LoadingAnimationProperty = + AvaloniaProperty.Register( + nameof(LoadingAnimation)); + + public static readonly StyledProperty PackageProviderProperty = + AvaloniaProperty.Register( + nameof(PackageProvider)); + + // Fill 和 Outline 支持的颜色 + public static readonly StyledProperty NormalFilledBrushProperty = + AvaloniaProperty.Register( + nameof(NormalFilledBrush)); + + public static readonly StyledProperty ActiveFilledBrushProperty = + AvaloniaProperty.Register( + nameof(ActiveFilledBrush)); + + public static readonly StyledProperty SelectedFilledBrushProperty = + AvaloniaProperty.Register( + nameof(SelectedFilledBrush)); + + public static readonly StyledProperty DisabledFilledBrushProperty = + AvaloniaProperty.Register( + nameof(DisabledFilledBrush)); + + // TwoTone 类型的颜色 + public static readonly StyledProperty PrimaryFilledBrushProperty = + AvaloniaProperty.Register( + nameof(PrimaryFilledBrush)); + + public static readonly StyledProperty SecondaryFilledBrushProperty = + AvaloniaProperty.Register( + nameof(SecondaryFilledBrush)); + + public static readonly StyledProperty LoadingAnimationDurationProperty = + AvaloniaProperty.Register( + nameof(LoadingAnimationDuration), TimeSpan.FromSeconds(1)); + + public static readonly StyledProperty FillAnimationDurationProperty = + AvaloniaProperty.Register( + nameof(FillAnimationDuration), TimeSpan.FromSeconds(300)); + + public static readonly StyledProperty IconModeProperty = + AvaloniaProperty.Register(nameof(IconMode)); + + public string Kind + { + get => GetValue(KindProperty); + set => SetValue(KindProperty, value); + } + + public string? PackageProvider + { + get => GetValue(PackageProviderProperty); + set => SetValue(PackageProviderProperty, value); + } + + public IBrush? NormalFilledBrush + { + get => GetValue(NormalFilledBrushProperty); + set => SetValue(NormalFilledBrushProperty, value); + } + + public IBrush? ActiveFilledBrush + { + get => GetValue(ActiveFilledBrushProperty); + set => SetValue(ActiveFilledBrushProperty, value); + } + + public IBrush? SelectedFilledBrush + { + get => GetValue(SelectedFilledBrushProperty); + set => SetValue(SelectedFilledBrushProperty, value); + } + + public IBrush? DisabledFilledBrush + { + get => GetValue(DisabledFilledBrushProperty); + set => SetValue(DisabledFilledBrushProperty, value); + } + + public IBrush? PrimaryFilledBrush + { + get => GetValue(PrimaryFilledBrushProperty); + set => SetValue(PrimaryFilledBrushProperty, value); + } + + public IBrush? SecondaryFilledBrush + { + get => GetValue(SecondaryFilledBrushProperty); + set => SetValue(SecondaryFilledBrushProperty, value); + } + + public TimeSpan LoadingAnimationDuration + { + get => GetValue(LoadingAnimationDurationProperty); + set => SetValue(LoadingAnimationDurationProperty, value); + } + + public TimeSpan FillAnimationDuration + { + get => GetValue(FillAnimationDurationProperty); + set => SetValue(FillAnimationDurationProperty, value); + } + + /// + /// PathIcon 的模式,只对 Outlined 和 Filled 类型有效 + /// + public IconMode IconMode + { + get => GetValue(IconModeProperty); + set => SetValue(IconModeProperty, value); + } + + private static readonly StyledProperty FilledBrushProperty + = AvaloniaProperty.Register( + nameof(IBrush)); + + /// + /// 当是非 TwoTone icon 的时候,填充色是支持渐变的 + /// + private IBrush? FilledBrush + { + get => GetValue(FilledBrushProperty); + set => SetValue(FilledBrushProperty, value); + } + + public IconThemeType ThemeType => _iconInfo?.ThemeType ?? IconThemeType.Filled; + + public IconAnimation LoadingAnimation + { + get => GetValue(LoadingAnimationProperty); + set => SetValue(LoadingAnimationProperty, value); + } + + #region 内部属性定义 + + internal static readonly StyledProperty AngleAnimationRotateProperty = + AvaloniaProperty.Register( + nameof(AngleAnimationRotate)); + + internal double AngleAnimationRotate + { + get => GetValue(AngleAnimationRotateProperty); + set => SetValue(AngleAnimationRotateProperty, value); + } + + #endregion + + private Animation? _animation; + private CancellationTokenSource? _animationCancellationTokenSource; + private WeakReference? _iconPackageRef; + private readonly List _transforms; + private readonly List _sourceGeometriesData; + private IconInfo? _iconInfo; + private Rect _viewBox; + + static PathIcon() + { + AffectsGeometry(KindProperty, PackageProviderProperty); + AffectsMeasure(HeightProperty, WidthProperty); + AffectsRender(IconModeProperty, + FilledBrushProperty, + PrimaryFilledBrushProperty, + SecondaryFilledBrushProperty); + HorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Left); + VerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Center); + } + + public PathIcon() + { + var rotateTransform = new RotateTransform(); + RenderTransform = rotateTransform; + _sourceGeometriesData = new List(); + _transforms = new List(); + } + + private void SetupTransitions() + { + Transitions ??= new Transitions() + { + AnimationUtils.CreateTransition(FilledBrushProperty, FillAnimationDuration) + }; + } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + if (change.Property == KindProperty) + { + // TODO 这里不存在记录日志吗?暂时构造一个默认的 + if (VisualRoot is not null) + { + BuildSourceRenderData(); + } + } + else if (change.Property == IsEnabledProperty) + { + // TODO 这个地方需要优化一点,是否需要保存老的,当状态为 Enabled 的时候进行还原 + if (!IsEnabled) + { + IconMode = IconMode.Disabled; + } + } + else if (change.Property == NormalFilledBrushProperty || + change.Property == ActiveFilledBrushProperty || + change.Property == SelectedFilledBrushProperty || + change.Property == DisabledFilledBrushProperty || + change.Property == PrimaryFilledBrushProperty || + change.Property == SecondaryFilledBrushProperty || + change.Property == IconModeProperty) + { + SetupFilledBrush(); + } + else if (change.Property == AngleAnimationRotateProperty) + { + SetCurrentValue(RenderTransformProperty, new RotateTransform(AngleAnimationRotate)); + } + + if (VisualRoot is not null) + { + if (change.Property == LoadingAnimationProperty) + { + SetupRotateAnimation(); + } + } + } + + private void SetupRotateAnimation() + { + if (_animation is not null) + { + _animationCancellationTokenSource?.Cancel(); + _animation = null; + _animationCancellationTokenSource = null; + } + + if (LoadingAnimation == IconAnimation.Spin || LoadingAnimation == IconAnimation.Pulse) + { + _animation = new Animation + { + Duration = LoadingAnimationDuration, + IterationCount = new IterationCount(ulong.MaxValue), + Children = + { + new KeyFrame + { + Cue = new Cue(0d), + Setters = { new Setter(AngleAnimationRotateProperty, 0d) } + }, + new KeyFrame + { + Cue = new Cue(1d), + Setters = { new Setter(AngleAnimationRotateProperty, 360d) } + } + } + }; + if (LoadingAnimation == IconAnimation.Pulse) + { + _animation.Easing = new PulseEasing(); + } + + if (VisualRoot is not null) + { + _animationCancellationTokenSource = new CancellationTokenSource(); + _animation.RunAsync(this, _animationCancellationTokenSource.Token); + } + } + } + + private void SetupFilledBrush() + { + var colorInfo = _iconInfo?.ColorInfo; + if (IconMode == IconMode.Normal) + { + if (NormalFilledBrush is not null) + { + FilledBrush = NormalFilledBrush; + } + else if (colorInfo.HasValue) + { + FilledBrush = new SolidColorBrush(colorInfo.Value.NormalColor); + } + } + else if (IconMode == IconMode.Active) + { + if (ActiveFilledBrush is not null) + { + FilledBrush = ActiveFilledBrush; + } + else if (NormalFilledBrush is not null) + { + FilledBrush = NormalFilledBrush; + } + else if (colorInfo.HasValue) + { + FilledBrush = new SolidColorBrush(colorInfo.Value.ActiveColor); + } + } + else if (IconMode == IconMode.Selected) + { + if (SelectedFilledBrush is not null) + { + FilledBrush = SelectedFilledBrush; + } + else if (NormalFilledBrush is not null) + { + FilledBrush = NormalFilledBrush; + } + else if (colorInfo.HasValue) + { + FilledBrush = new SolidColorBrush(colorInfo.Value.SelectedColor); + } + } + else + { + if (DisabledFilledBrush is not null) + { + FilledBrush = DisabledFilledBrush; + } + else if (NormalFilledBrush is not null) + { + FilledBrush = NormalFilledBrush; + } + else if (colorInfo.HasValue) + { + FilledBrush = new SolidColorBrush(colorInfo.Value.DisabledColor); + } + } + } + + /// + /// Invalidates the geometry of this shape. + /// + private void InvalidateGeometry() + { + if (_animation is not null) + { + _animationCancellationTokenSource?.Cancel(); + } + + _sourceGeometriesData.Clear(); + _transforms.Clear(); + _iconInfo = null; + InvalidateMeasure(); + } + + /// + /// Marks a property as affecting the shape's geometry. + /// + /// The properties. + /// + /// After a call to this method in a control's static constructor, any change to the + /// property will cause to be called on the element. + /// + private static void AffectsGeometry(params AvaloniaProperty[] properties) + { + foreach (var property in properties) + { + property.Changed.Subscribe(new AnonymousObserver(e => + { + if (e.Sender is PathIcon icon) + { + AffectsGeometryInvalidate(icon, e); + } + })); + } + } + + private static void AffectsGeometryInvalidate(PathIcon control, AvaloniaPropertyChangedEventArgs e) + { + // If the geometry is invalidated when Bounds changes, only invalidate when the Size + // portion changes. + if (e.Property == BoundsProperty) + { + var oldBounds = (Rect)e.OldValue!; + var newBounds = (Rect)e.NewValue!; + if (oldBounds.Size == newBounds.Size) + { + return; + } + } + + control.InvalidateGeometry(); + } + + private void BuildSourceRenderData() + { + if (_sourceGeometriesData.Count > 0) + { + return; + } + + var manager = IconManager.Current; + PackageProvider ??= manager.DefaultPackage; + + var iconPackage = manager.GetIconProvider(PackageProvider); + // 这里报错还是? + if (iconPackage is not null) + { + _iconPackageRef = new WeakReference(iconPackage); + } + + if (_iconPackageRef != null && _iconPackageRef.TryGetTarget(out var iconPackageProvider)) + { + // TODO 这里可能需要优化,针对 IconInfo 的拷贝问题 + _iconInfo = iconPackageProvider.GetIcon(Kind) ?? new IconInfo(); + foreach (var geometryData in _iconInfo.Data) + { + _sourceGeometriesData.Add(Geometry.Parse(geometryData.PathData)); + } + + _viewBox = _iconInfo!.ViewBox; + // 先求最大的 bounds + // 裁剪边距算法,暂时先注释掉 + Geometry? combined = null; + foreach (var geometry in _sourceGeometriesData) + { + if (combined is null) + { + combined = geometry; + } + else + { + combined = new CombinedGeometry(combined, geometry); + } + } + + var combinedBounds = combined!.Bounds; + + var marginHorizontal = Math.Min(_iconInfo.ViewBox.Right - combinedBounds.Right, combinedBounds.X); + var marginVertical = Math.Min(_iconInfo.ViewBox.Bottom - combinedBounds.Bottom, combinedBounds.Y); + var margin = Math.Min(marginHorizontal, marginVertical); + + var scaleX = 1 - margin / _viewBox.Width; + var scaleY = 1 - margin / _viewBox.Height; + + if (margin > 0) + { + for (var i = 0; i < _sourceGeometriesData.Count; i++) + { + var geometry = _sourceGeometriesData[i]; + var cloned = geometry.Clone(); + var offsetX = -margin / 2; + var offsetY = -margin / 2; + var matrix = Matrix.CreateTranslation(offsetX, offsetY); + matrix = matrix * Matrix.CreateScale(scaleX, scaleY); + cloned.Transform = new MatrixTransform(matrix); + _sourceGeometriesData[i] = cloned; + } + + _viewBox = combined!.Bounds; + } + } + } + + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + SetupTransitions(); + SetupRotateAnimation(); + } + + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnAttachedToVisualTree(e); + if (_sourceGeometriesData.Count == 0) + { + BuildSourceRenderData(); + SetupFilledBrush(); + } + if (_animation is not null && _animationCancellationTokenSource is null) + { + _animationCancellationTokenSource = new CancellationTokenSource(); + _animation.RunAsync(this, _animationCancellationTokenSource.Token); + } + } + + protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnDetachedFromVisualTree(e); + _animationCancellationTokenSource?.Cancel(); + _animationCancellationTokenSource = null; + } + + protected override Size MeasureOverride(Size availableSize) + { + if (_sourceGeometriesData.Count == 0) + { + return default; + } + + Size targetSize = default; + for (var i = 0; i < _sourceGeometriesData.Count; i++) + { + var sourceGeometry = _sourceGeometriesData[i]; + var currentSize = CalculateSizeAndTransform(availableSize, sourceGeometry.Bounds).size; + targetSize = new Size(Math.Max(targetSize.Width, currentSize.Width), + Math.Min(targetSize.Height, currentSize.Height)); + } + + return targetSize; + } + + protected override Size ArrangeOverride(Size finalSize) + { + _transforms.Clear(); + // This should probably use GetRenderBounds(strokeThickness) but then the calculations + // will multiply the stroke thickness as well, which isn't correct. + for (var i = 0; i < _sourceGeometriesData.Count; i++) + { + var sourceGeometry = _sourceGeometriesData[i]; + var (_, transform) = CalculateSizeAndTransform(finalSize, sourceGeometry.Bounds); + _transforms.Insert(i, transform); + } + + return finalSize; + } + + public override void Render(DrawingContext context) + { + if (IsVisible && + _sourceGeometriesData.Count > 0 && + Bounds.Width > 0 && + Bounds.Width > 0) + { + for (var i = 0; i < _sourceGeometriesData.Count; i++) + { + var renderedGeometry = _sourceGeometriesData[i]; + var geometryData = _iconInfo!.Data[i]; + IBrush? fillBrush = null; + if (_iconInfo.ThemeType == IconThemeType.TwoTone) + { + var colorInfo = _iconInfo.TwoToneColorInfo; + if (colorInfo.HasValue) + { + if (geometryData.IsPrimary) + { + if (PrimaryFilledBrush is not null) + { + fillBrush = PrimaryFilledBrush; + } + else + { + fillBrush = new SolidColorBrush(colorInfo.Value.PrimaryColor); + } + } + else + { + if (SecondaryFilledBrush is not null) + { + fillBrush = SecondaryFilledBrush; + } + else + { + fillBrush = new SolidColorBrush(colorInfo.Value.SecondaryColor); + } + } + } + } + else + { + fillBrush = FilledBrush; + } + + using var state = context.PushTransform(_transforms[i]); + context.DrawGeometry(fillBrush, null, renderedGeometry); + } + } + } + + private (Size size, Matrix transform) CalculateSizeAndTransform(Size availableSize, Rect shapeBounds) + { + var shapeSize = new Size(shapeBounds.Width, shapeBounds.Height); + var desiredX = availableSize.Width; + var desiredY = availableSize.Height; + var sx = 0.0; + var sy = 0.0; + var viewBoxWidth = _viewBox.Width; + var viewBoxHeight = _viewBox.Height; + + // 计算大小的比例因子 + var shapeWidthScale = shapeBounds.Width / viewBoxWidth; + var shapeHeightScale = shapeBounds.Height / viewBoxHeight; + + // 计算位移的比例因子 + var offsetXScale = Math.Floor(availableSize.Width / viewBoxWidth); + var offsetYScale = Math.Floor(availableSize.Height / viewBoxHeight); + + var offsetX = shapeBounds.X; + var offsetY = shapeBounds.Y; + + shapeSize = shapeBounds.Size; + + if (double.IsInfinity(availableSize.Width)) + { + desiredX = shapeSize.Width; + } + else + { + desiredX = availableSize.Width * shapeWidthScale; + offsetX *= offsetXScale; + } + + if (double.IsInfinity(availableSize.Height)) + { + desiredY = shapeSize.Height; + } + else + { + desiredY = availableSize.Height * shapeHeightScale; + offsetY *= offsetYScale; + } + + var translate = Matrix.CreateTranslation(-offsetX, -offsetY); + if (shapeBounds.Width > 0) + { + sx = desiredX / shapeSize.Width; + } + + if (shapeBounds.Height > 0) + { + sy = desiredY / shapeSize.Height; + } + + if (double.IsInfinity(availableSize.Width)) + { + sx = sy; + } + + if (double.IsInfinity(availableSize.Height)) + { + sy = sx; + } + + sx = sy = Math.Min(sx, sy); + + translate = translate * Matrix.CreateScale(sx, sy); + var size = new Size(shapeSize.Width * sx, shapeSize.Height * sy); + return (size, translate); + } + + public bool HitTest(Point point) + { + var targetRect = new Rect(0, 0, DesiredSize.Width, DesiredSize.Height); + return targetRect.Contains(point); + } +} \ No newline at end of file diff --git a/src/AtomUI.Theme/Data/TokenResourceBinder.cs b/src/AtomUI.Theme/Data/TokenResourceBinder.cs index 3231df7..258893f 100644 --- a/src/AtomUI.Theme/Data/TokenResourceBinder.cs +++ b/src/AtomUI.Theme/Data/TokenResourceBinder.cs @@ -5,7 +5,7 @@ using Avalonia.Data; using Avalonia.Markup.Xaml.MarkupExtensions; using Avalonia.Styling; -namespace AtomUI.Utils; +namespace AtomUI.Theme.Data; public static class TokenResourceBinder { diff --git a/src/AtomUI.Theme/Utils/AnimationUtils.cs b/src/AtomUI.Theme/Utils/AnimationUtils.cs deleted file mode 100644 index d4093dc..0000000 --- a/src/AtomUI.Theme/Utils/AnimationUtils.cs +++ /dev/null @@ -1,64 +0,0 @@ -using AtomUI.Theme.Styling; -using AtomUI.Theme.TokenSystem; -using Avalonia; -using Avalonia.Animation; -using Avalonia.Animation.Easings; -using Avalonia.Controls; -using Avalonia.Styling; - -namespace AtomUI.Theme.Utils; - -public static class AnimationUtils -{ - public static Animation RunAnimation(AvaloniaProperty targetProperty, - ValueType startValue, - ValueType endValue, - TimeSpan duration, - Easing? easing = null) - { - if (easing is null) - { - easing = new LinearEasing(); - } - - var animation = new Animation - { - Duration = duration, - Easing = easing, - FillMode = FillMode.Backward, - Children = - { - new KeyFrame - { - Setters = { new Setter(targetProperty, startValue) }, KeyTime = TimeSpan.FromMilliseconds(0) - }, - new KeyFrame - { - Setters = { new Setter(targetProperty, endValue) }, KeyTime = duration - } - } - }; - return animation; - } - - public static ITransition CreateTransition(AvaloniaProperty targetProperty, - TokenResourceKey? durationResourceKey = null, - Easing? easing = null) - where T : TransitionBase, new() - { - easing ??= new LinearEasing(); - durationResourceKey ??= GlobalTokenResourceKey.MotionDurationMid; - var transition = new T - { - Property = targetProperty, - Easing = easing - }; - var application = Application.Current; - if (application is not null) - { - transition.Bind(TransitionBase.DurationProperty, application.GetResourceObservable(durationResourceKey)); - } - - return transition; - } -} \ No newline at end of file