using Gready_Poang.DataLayer.Database;
using System.Diagnostics;

namespace Gready_Poang;

public partial class App : Application
{
    private readonly IServiceProvider _services;

    public App(IServiceProvider services, DataContext dataContext)
    {
        InitializeComponent();
        dataContext.Database.EnsureCreated();
        _services = services;

        AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
        {
            if (Debugger.IsAttached)
                Debugger.Break();
        };

        TaskScheduler.UnobservedTaskException += (sender, e) =>
        {
            if (Debugger.IsAttached)
                Debugger.Break();
        };
    }

    protected override Window CreateWindow(IActivationState? activationState)
    {

        //var splashVm = ServiceLocator.Services.GetRequiredService<SplashViewModelCommands>();
        //var shell = new AppShell(splashVm);

        var shell = _services.GetRequiredService<AppShell>();
        return new Window(shell);
    }
}