using LocationTrackerApp.Views;
using LocationTrackerApp.ViewModels;
using LocationTrackerApp.Data;

namespace LocationTrackerApp;

public partial class App : Application
{
	public App()
	{
		InitializeComponent();
	}

	protected override Window CreateWindow(IActivationState? activationState)
	{
		// Get services from DI container
		var dbContext = Handler?.MauiContext?.Services?.GetService<LocationDbContext>();
		var mainViewModel = Handler?.MauiContext?.Services?.GetService<MainViewModel>();
		
		if (dbContext != null)
		{
			// Ensure database is created
			_ = Task.Run(async () => await dbContext.EnsureDatabaseCreatedAsync());
		}

		return new Window(new AppShell());
	}
}