feat: add new Notification.

This commit is contained in:
Zhang Dian
2024-09-09 19:09:05 +08:00
parent cd8bf3adaf
commit b0bacfa0ae
12 changed files with 649 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
using System;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Notification = Ursa.Controls.Notification;
using WindowNotificationManager = Ursa.Controls.WindowNotificationManager;
namespace Ursa.Demo.ViewModels;
public partial class NotificationDemoViewModel : ObservableObject
{
public WindowNotificationManager? NotificationManager { get; set; }
[ObservableProperty] private bool _showClose = true;
[RelayCommand]
public void ShowNormal(object obj)
{
if (obj is string s)
{
Enum.TryParse<NotificationType>(s, out var notificationType);
NotificationManager?.Show(
new Notification("Welcome", "This is message"),
showClose: ShowClose,
type: notificationType);
}
}
[RelayCommand]
public void ShowLight(object obj)
{
if (obj is string s)
{
Enum.TryParse<NotificationType>(s, out var notificationType);
NotificationManager?.Show(
new Notification("Welcome", "This is message"),
showClose: ShowClose,
type: notificationType,
classes: ["Light"]);
}
}
}