35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
namespace ytLive.Services;
|
|
|
|
/// <summary>How urgent a user-facing notification is. Drives the toast's tint and lifetime.</summary>
|
|
public enum AppNotificationSeverity
|
|
{
|
|
Info,
|
|
Success,
|
|
Warning,
|
|
Error,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Non-blocking user-facing messages (toasts). VMs and services raise events through
|
|
/// this seam so failures surface without MessageBox calls blocking the UI thread.
|
|
/// </summary>
|
|
public interface INotificationService
|
|
{
|
|
void Show(string title, string message, AppNotificationSeverity severity);
|
|
}
|
|
|
|
public static class NotificationServiceExtensions
|
|
{
|
|
public static void Info(this INotificationService service, string title, string message = "")
|
|
=> service.Show(title, message, AppNotificationSeverity.Info);
|
|
|
|
public static void Success(this INotificationService service, string title, string message = "")
|
|
=> service.Show(title, message, AppNotificationSeverity.Success);
|
|
|
|
public static void Warning(this INotificationService service, string title, string message = "")
|
|
=> service.Show(title, message, AppNotificationSeverity.Warning);
|
|
|
|
public static void Error(this INotificationService service, string title, string message = "")
|
|
=> service.Show(title, message, AppNotificationSeverity.Error);
|
|
}
|