From 890ad7fd80a8f391f279dca16ab4c59cd23fa08a Mon Sep 17 00:00:00 2001 From: chinboy Date: Mon, 20 Apr 2026 13:41:35 +0800 Subject: [PATCH] refactor(DrawerContainer): migrate Transitions from C# to XAML theme - Removed ConfigureTransitions method and lifecycle hooks (OnLoaded/OnUnloaded) - Added ^[IsMotionEnabled=True] style selector with SolidColorBrushTransition for Background property - Transitions now handled declaratively in XAML theme --- .../Drawer/DrawerContainer.cs | 43 ------------------- .../Drawer/Themes/DrawerContainerTheme.axaml | 10 ++++- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/AtomUI.Desktop.Controls/Drawer/DrawerContainer.cs b/src/AtomUI.Desktop.Controls/Drawer/DrawerContainer.cs index 7a0509c28..a5b3e3dc4 100644 --- a/src/AtomUI.Desktop.Controls/Drawer/DrawerContainer.cs +++ b/src/AtomUI.Desktop.Controls/Drawer/DrawerContainer.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using AtomUI.Animations; using AtomUI.Controls; using AtomUI.Controls.Primitives; using AtomUI.Desktop.Controls.Themes; @@ -12,7 +11,6 @@ using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.Data; using Avalonia.Input; -using Avalonia.Interactivity; using Avalonia.Layout; using Avalonia.Media; using Avalonia.Media.Transformation; @@ -449,45 +447,4 @@ internal class DrawerContainer : ContentControl _infoContainer.RenderTransform = _originInfoContainerTransform; } } - - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) - { - base.OnPropertyChanged(change); - if (IsLoaded) - { - if (change.Property == IsMotionEnabledProperty) - { - ConfigureTransitions(true); - } - } - } - - private void ConfigureTransitions(bool force) - { - if (IsMotionEnabled) - { - if (force || Transitions == null) - { - Transitions = [ - TransitionUtils.CreateTransition(Border.BackgroundProperty) - ]; - } - } - else - { - Transitions = null; - } - } - - protected override void OnLoaded(RoutedEventArgs e) - { - base.OnLoaded(e); - ConfigureTransitions(false); - } - - protected override void OnUnloaded(RoutedEventArgs e) - { - base.OnUnloaded(e); - Transitions = null; - } } \ No newline at end of file diff --git a/src/AtomUI.Desktop.Controls/Drawer/Themes/DrawerContainerTheme.axaml b/src/AtomUI.Desktop.Controls/Drawer/Themes/DrawerContainerTheme.axaml index e96becfb3..1a80177a1 100644 --- a/src/AtomUI.Desktop.Controls/Drawer/Themes/DrawerContainerTheme.axaml +++ b/src/AtomUI.Desktop.Controls/Drawer/Themes/DrawerContainerTheme.axaml @@ -36,6 +36,14 @@ Value="{atom:SharedTokenResource MotionDurationSlow}" /> - + + + \ No newline at end of file