Refactor MessageCard Style

This commit is contained in:
chinboy
2025-03-06 11:05:54 +08:00
parent de5c5a6aa4
commit 2acded0d9a
2 changed files with 3 additions and 23 deletions
+2 -23
View File
@@ -1,12 +1,9 @@
using System.Diagnostics;
using System.Reactive.Disposables;
using AtomUI.Controls.Utils;
using AtomUI.IconPkg;
using AtomUI.IconPkg.AntDesign;
using AtomUI.MotionScene;
using AtomUI.Theme;
using AtomUI.Theme.Data;
using AtomUI.Theme.Styling;
using AtomUI.Theme.Utils;
using Avalonia;
using Avalonia.Animation.Easings;
@@ -15,7 +12,6 @@ using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.VisualTree;
namespace AtomUI.Controls;
@@ -23,8 +19,7 @@ namespace AtomUI.Controls;
[PseudoClasses(ErrorPC, InformationPC, SuccessPC, WarningPC, LoadingPC)]
public class MessageCard : TemplatedControl,
IAnimationAwareControl,
IControlSharedTokenResourcesHost,
ITokenResourceConsumer
IControlSharedTokenResourcesHost
{
public const string ErrorPC = ":error";
public const string InformationPC = ":information";
@@ -152,12 +147,9 @@ public class MessageCard : TemplatedControl,
Control IAnimationAwareControl.PropertyBindTarget => this;
Control IControlSharedTokenResourcesHost.HostControl => this;
string IControlSharedTokenResourcesHost.TokenId => MessageToken.ID;
CompositeDisposable? ITokenResourceConsumer.TokenBindingsDisposable => _tokenBindingsDisposable;
#endregion
private CompositeDisposable? _tokenBindingsDisposable;
private bool _isClosing;
private MotionActorControl? _motionActor;
@@ -330,18 +322,5 @@ public class MessageCard : TemplatedControl,
Debug.Assert(Icon != null);
Icon.SetTemplatedParent(this);
}
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnAttachedToLogicalTree(e);
_tokenBindingsDisposable = new CompositeDisposable();
this.AddTokenBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, OpenCloseMotionDurationProperty,
SharedTokenKey.MotionDurationMid));
}
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
{
base.OnDetachedFromLogicalTree(e);
this.DisposeTokenBindings();
}
}
@@ -138,6 +138,7 @@ internal class MessageCardTheme : BaseControlTheme
{
var commonStyle = new Style(selector => selector.Nesting());
commonStyle.Add(MessageCard.OpenCloseMotionDurationProperty, SharedTokenKey.MotionDurationMid);
commonStyle.Add(Layoutable.HorizontalAlignmentProperty, HorizontalAlignment.Center);
var frameStyle = new Style(selector => selector.Nesting().Template().Name(FramePart));