feat: add new Toast.

This commit is contained in:
Zhang Dian
2024-09-05 01:36:10 +08:00
parent 2b42760673
commit f0b23e1bdf
13 changed files with 858 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using System;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Controls;
namespace Ursa.Demo.ViewModels;
public partial class ToastDemoViewModel : ObservableObject
{
public WindowToastManager? ToastManager { get; set; }
[RelayCommand]
public void ShowNormal(object obj)
{
if (obj is string s)
{
Enum.TryParse<NotificationType>(s, out var notificationType);
ToastManager?.Show(
new Toast("This is message"),
type: notificationType);
}
// ToastManager?.Show(new ToastDemoViewModel
// {
// Content = "This is message",
// ToastManager = ToastManager
// });
}
[RelayCommand]
public void ShowLight(object obj)
{
if (obj is string s)
{
Enum.TryParse<NotificationType>(s, out var notificationType);
ToastManager?.Show(
new Toast("This is message"),
type: notificationType,
classes: ["Light"]);
}
}
public string? Content { get; set; }
[RelayCommand]
public void YesCommand()
{
ToastManager?.Show(new Toast("Yes!"));
}
[RelayCommand]
public void NoCommand()
{
ToastManager?.Show(new Toast("No!"));
}
}