mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-26 11:10:34 +08:00
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
This commit is contained in:
@@ -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<SolidColorBrushTransition>(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;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,14 @@
|
||||
Value="{atom:SharedTokenResource MotionDurationSlow}" />
|
||||
<Setter Property="MaskBgColor"
|
||||
Value="{atom:SharedTokenResource ColorBgMask}" />
|
||||
|
||||
|
||||
<Style Selector="^[IsMotionEnabled=True]">
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<atom:SolidColorBrushTransition Property="Background" Duration="{atom:SharedTokenResourceValue Kind=MotionDurationMid}" />
|
||||
</Transitions>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user