diff --git a/src/Ursa.Themes.Semi/Controls/Toast.axaml b/src/Ursa.Themes.Semi/Controls/Toast.axaml index 256140b..d34388b 100644 --- a/src/Ursa.Themes.Semi/Controls/Toast.axaml +++ b/src/Ursa.Themes.Semi/Controls/Toast.axaml @@ -6,10 +6,10 @@ - Hello, Semi.Avalonia! + Hello, Ursa! - + @@ -87,7 +87,7 @@ Grid.Column="2" Theme="{StaticResource ToastCloseButton}" IsVisible="{TemplateBinding ShowClose}" - u:ToastCard.CloseOnClick="True" /> + u:MessageCard.CloseOnClick="True" /> diff --git a/src/Ursa/Controls/NotificationShared/IMessage.cs b/src/Ursa/Controls/NotificationShared/IMessage.cs new file mode 100644 index 0000000..b1cad33 --- /dev/null +++ b/src/Ursa/Controls/NotificationShared/IMessage.cs @@ -0,0 +1,35 @@ +using Avalonia.Controls.Notifications; + +namespace Ursa.Controls; + +/// +/// Represents a message that can be shown in a window or by the host operating system. +/// +public interface IMessage +{ + /// + /// Gets the of the message. + /// + NotificationType Type { get; } + + /// + /// Gets a value indicating whether the message should show a close button. + /// + bool ShowClose { get; } + + /// + /// Gets the expiration time of the message after which it will automatically close. + /// If the value is then the message will remain open until the user closes it. + /// + TimeSpan Expiration { get; } + + /// + /// Gets an Action to be run when the message is clicked. + /// + Action? OnClick { get; } + + /// + /// Gets an Action to be run when the message is closed. + /// + Action? OnClose { get; } +} \ No newline at end of file diff --git a/src/Ursa/Controls/NotificationShared/MessageCard.cs b/src/Ursa/Controls/NotificationShared/MessageCard.cs new file mode 100644 index 0000000..d244a69 --- /dev/null +++ b/src/Ursa/Controls/NotificationShared/MessageCard.cs @@ -0,0 +1,207 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Metadata; +using Avalonia.Controls.Notifications; +using Avalonia.Interactivity; +using Avalonia.LogicalTree; + +namespace Ursa.Controls; + +/// +/// Control that represents and displays a message. +/// +[PseudoClasses(PC_Information, PC_Success, PC_Warning, PC_Error)] +public abstract class MessageCard : ContentControl +{ + public const string PC_Information = ":information"; + public const string PC_Success = ":success"; + public const string PC_Warning = ":warning"; + public const string PC_Error = ":error"; + + private bool _isClosing; + + static MessageCard() + { + CloseOnClickProperty.Changed.AddClassHandler