feat: add new Notification.
This commit is contained in:
42
demo/Ursa.Demo/ViewModels/NotificationDemoViewModel.cs
Normal file
42
demo/Ursa.Demo/ViewModels/NotificationDemoViewModel.cs
Normal 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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user