mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-20 23:58:05 +08:00
Refactor Popup
This commit is contained in:
@@ -7,6 +7,7 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives.PopupPositioning;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Metadata;
|
||||
using Avalonia.Styling;
|
||||
@@ -127,9 +128,9 @@ public class Flyout : PopupFlyoutBase
|
||||
|
||||
public Flyout()
|
||||
{
|
||||
TokenResourceBinder.CreateTokenBinding(this, MotionDurationTokenProperty,
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(this, MotionDurationTokenProperty,
|
||||
SharedTokenKey.MotionDurationMid);
|
||||
TokenResourceBinder.CreateTokenBinding(this, MaskShadowsProperty,
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(this, MaskShadowsProperty,
|
||||
SharedTokenKey.BoxShadowsSecondary);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,16 +155,20 @@ public class FlyoutHost : Control
|
||||
_flyoutStateHelper = new FlyoutStateHelper();
|
||||
}
|
||||
|
||||
public override void ApplyTemplate()
|
||||
{
|
||||
base.ApplyTemplate();
|
||||
TokenResourceBinder.CreateTokenBinding(this, MarginToAnchorProperty, SharedTokenKey.MarginXXS);
|
||||
SetupFlyoutProperties();
|
||||
}
|
||||
// public override void ApplyTemplate()
|
||||
// {
|
||||
// // TODO 需要审查到底是否合适
|
||||
// base.ApplyTemplate();
|
||||
// TokenResourceBinder.CreateTokenBinding(this, MarginToAnchorProperty, SharedTokenKey.MarginXXS);
|
||||
// SetupFlyoutProperties();
|
||||
// }
|
||||
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
TokenResourceBinder.CreateTokenBinding(this, MarginToAnchorProperty, SharedTokenKey.MarginXXS);
|
||||
SetupFlyoutProperties();
|
||||
|
||||
BindUtils.RelayBind(this, AnchorTargetProperty, _flyoutStateHelper, FlyoutStateHelper.AnchorTargetProperty);
|
||||
BindUtils.RelayBind(this, FlyoutProperty, _flyoutStateHelper, FlyoutStateHelper.FlyoutProperty);
|
||||
BindUtils.RelayBind(this, MouseEnterDelayProperty, _flyoutStateHelper,
|
||||
|
||||
@@ -75,7 +75,6 @@ public class Popup : AvaloniaPopup
|
||||
private PopupShadowLayer? _shadowLayer;
|
||||
private CompositeDisposable? _compositeDisposable;
|
||||
private IDisposable? _selfLightDismissDisposable;
|
||||
private bool _initialized;
|
||||
private ManagedPopupPositionerInfo? _managedPopupPositioner;
|
||||
private bool _isNeedFlip = true;
|
||||
private bool _openAnimating;
|
||||
@@ -102,14 +101,8 @@ public class Popup : AvaloniaPopup
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
if (!_initialized)
|
||||
{
|
||||
TokenResourceBinder.CreateTokenBinding(this, MaskShadowsProperty,
|
||||
SharedTokenKey.BoxShadowsSecondary);
|
||||
TokenResourceBinder.CreateTokenBinding(this, MotionDurationProperty,
|
||||
SharedTokenKey.MotionDurationMid);
|
||||
_initialized = true;
|
||||
}
|
||||
TokenResourceBinder.CreateTokenBinding(this, MaskShadowsProperty, SharedTokenKey.BoxShadowsSecondary);
|
||||
TokenResourceBinder.CreateTokenBinding(this, MotionDurationProperty, SharedTokenKey.MotionDurationMid);
|
||||
}
|
||||
|
||||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user