using Microsoft.Maui.Controls;
using Microsoft.UI.Windowing;

namespace TodoList.Maui.Platforms.Windows
{
    public class WindowsWindowService
    {
        public void MinimizeWindow(Window window)
        {
            if (window == null) return;

            var platformWindow = window.Handler?.PlatformView;
            if (platformWindow == null) return;

            var nativeWindow = (Microsoft.UI.Xaml.Window)platformWindow;
            var appWindow = nativeWindow.AppWindow;

            if (appWindow != null)
            {
                var overlappedPresenter = appWindow.Presenter as OverlappedPresenter;
                if (overlappedPresenter != null)
                {
                    overlappedPresenter.Minimize();
                }
            }
        }
    }
}