Toasts: non-blocking notifications replace MessageBoxes + log-only failures (TASK 24)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user