using Common.Library;
using Gready_Poang.Core;
using Gready_Poang.DataLayer;
using Gready_Poang.EntityLayer;
using Gready_Poang.Services;
using Gready_Poang.ViewModelLayer;
using System.Windows.Input;

namespace Gready_Poang.CommandClasses;

public class RoundRunningViewModelCommands : RoundRunningViewModel
{
    public RoundRunningViewModelCommands() : base()
    {
    }

    public RoundRunningViewModelCommands(
        IRepository<GameRound> roundsRepo,
        IRepository<GamePoint> pointsRepo,
        IMethodSharingService<Participant> sharingService,
        ICombinedRepository combined,
        IObjectMessageService objectMessage,
        ISplashService splashService,
        AppShellViewModel appShell)
        : base(roundsRepo,
            pointsRepo,
            sharingService,
            combined,
            objectMessage,
            splashService,
            appShell)
    {
    }

    #region Commands
    public ICommand GobackCommand { get; private set; }
    public ICommand StoreAndHandlePointsCommand { get; private set; }
    public ICommand OnSplashClickedCommand { get; private set; }

    #endregion

    public override void Init()
    {
        base.Init();
        StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
        OnSplashClickedCommand = new Command(async () => await ToggleSplash());
        GobackCommand = new Command(async () => GobackAsync());
    }

    private async void GobackAsync()
    {
        base.GobackAsync();
        await Shell.Current.GoToAsync("..");
    }

    private async Task StoreAndHandleAsync()
    {
        base.StoreAndHandlePoints();
        //await Shell.Current.GoToAsync("..");
        //        await Shell.Current.GoToAsync("RoundRunningPage");
    }

    private async Task ToggleSplash()
    {
        base.ToggleSplash();
    }
}
