using System; using System.Threading.Tasks; using Avalonia; using Avalonia.Controls.Notifications; using Microsoft.Extensions.Logging; using StabilityMatrix.Core.Exceptions; using StabilityMatrix.Core.Models; namespace StabilityMatrix.Avalonia.Services; public interface INotificationService { public void Initialize( Visual? visual, NotificationPosition position = NotificationPosition.BottomRight, int maxItems = 3 ); public void Show(INotification notification); /// /// Attempt to run the given task, showing a generic error notification if it fails. /// /// The task to run. /// The title to show in the notification. /// The message to show, default to exception.Message /// The appearance of the notification. Task> TryAsync( Task task, string title = "Error", string? message = null, NotificationType appearance = NotificationType.Error ); /// /// Attempt to run the given void task, showing a generic error notification if it fails. /// Return a TaskResult with true if the task succeeded, false if it failed. /// /// The task to run. /// The title to show in the notification. /// The message to show, default to exception.Message /// The appearance of the notification. Task> TryAsync( Task task, string title = "Error", string? message = null, NotificationType appearance = NotificationType.Error ); /// /// Show a notification with the given parameters. /// void Show( string title, string message, NotificationType appearance = NotificationType.Information, TimeSpan? expiration = null ); /// /// Show a notification that will not auto-dismiss. /// /// /// /// void ShowPersistent( string title, string message, NotificationType appearance = NotificationType.Information ); /// /// Show a notification for a that will not auto-dismiss. /// void ShowPersistent( AppException exception, NotificationType appearance = NotificationType.Error, LogLevel logLevel = LogLevel.Warning ); }