using System;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;

namespace detect.gui.Classes;

public abstract class NotificationService
{
    private static WindowNotificationManager? _notificationManager;

    private const int NotificationTimeout = 4;

    public static void SetHostWindow(TopLevel? window)
    {
        var notificationManager = new WindowNotificationManager(window)
        {
            Position = NotificationPosition.TopRight,
            MaxItems = 4
        };

        _notificationManager = notificationManager;
    }

    public static void Show(string title, string? message, NotificationType type,Action? onClick = null)
    {
        if (_notificationManager is { } nm)
        {
            nm.Show(
                new Notification(
                    title,
                    message,
                    type,
                    new TimeSpan(0,0,0, NotificationTimeout),
                    onClick));
        }
    }
}
