feat: add ShowIcon property.

This commit is contained in:
Zhang Dian
2024-09-11 19:32:13 +08:00
parent c1e58d5e71
commit 621f55674c
12 changed files with 72 additions and 43 deletions

View File

@@ -12,6 +12,11 @@ public interface IMessage
/// </summary>
NotificationType Type { get; }
/// <summary>
/// Gets a value indicating whether the message should show an icon.
/// </summary>
bool ShowIcon { get; }
/// <summary>
/// Gets a value indicating whether the message should show a close button.
/// </summary>

View File

@@ -78,6 +78,15 @@ public abstract class MessageCard : ContentControl
public static readonly StyledProperty<NotificationType> NotificationTypeProperty =
AvaloniaProperty.Register<MessageCard, NotificationType>(nameof(NotificationType));
public bool ShowIcon
{
get => GetValue(ShowIconProperty);
set => SetValue(ShowIconProperty, value);
}
public static readonly StyledProperty<bool> ShowIconProperty =
AvaloniaProperty.Register<MessageCard, bool>(nameof(ShowIcon), true);
public bool ShowClose
{
get => GetValue(ShowCloseProperty);
@@ -187,19 +196,19 @@ public abstract class MessageCard : ContentControl
{
switch (NotificationType)
{
case NotificationType.Error:
case Avalonia.Controls.Notifications.NotificationType.Error:
PseudoClasses.Add(PC_Error);
break;
case NotificationType.Information:
case Avalonia.Controls.Notifications.NotificationType.Information:
PseudoClasses.Add(PC_Information);
break;
case NotificationType.Success:
case Avalonia.Controls.Notifications.NotificationType.Success:
PseudoClasses.Add(PC_Success);
break;
case NotificationType.Warning:
case Avalonia.Controls.Notifications.NotificationType.Warning:
PseudoClasses.Add(PC_Warning);
break;
}