using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using LindtLeerformPlugin.Views;
using VisionBuilder.UI.Common.ViewModel.Interfaces.UI;

namespace LindtLeerformPlugin;

public class LeerformRecipeCreationTool : IRecipeCreationTool
{
    public bool Enabled { get; set; } = true;

    public async Task<string?> CreateRecipeAsync()
    {
        if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
            return null;

        var parent = desktop.MainWindow;
        if (parent == null)
            return null;

        var dialog = new RecipeNameDialog();
        var result = await dialog.ShowDialog<string?>(parent);

        return string.IsNullOrWhiteSpace(result) ? null : result;
    }
}
