using Gready_Poang.CommandClasses;
using Gready_Poang.Core;
using Gready_Poang.Views;

namespace Gready_Poang.Pages;

public class RoundRunningPage : BasePage
{
    private readonly RoundRunningViewModelCommands _vm;
    private readonly SplashViewModelCommands _splashVm;
    public ISplashService Splash { get; set; }

    public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm)
        : base(new RoundRunningView(Vm), splashVm)
    {
        Title = "Starta/Fortsätt runda";
        _vm = Vm;
        Splash = ServiceLocator.Services?.GetRequiredService<ISplashService>();
        _splashVm = splashVm;
    }


    public SplashViewModelCommands SplashVm { get; }

    protected override async void OnAppearing()
    {
        base.OnAppearing();
        BindingContext = _vm;
        _vm.Get();
        //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten
        //// _vm.RebuildRequested += ViewModel_RebuildRequested;
        if (_splashVm != null)
        {
            await Splash.ShowSplash("Nu kan du spela vidare", 3000);
            //await Splash.ShowSplash("Nu kan du spela vidare", 3000).GetAwaiter().GetResult();
        }
        //_splashVm.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ;

    }



}
