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

namespace GreadyPoang.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)
        : base(roundsRepo,
            pointsRepo,
            sharingService,
            combined,
            objectMessage,
            splashService)
    {
    }

    #region Commands
    public ICommand SaveCommand { get; private set; }
    public ICommand EditCommand { get; private set; }
    public ICommand RensaCommand { get; private set; }
    public ICommand ElementTappedCommand { get; private set; }
    public ICommand ParticipantTappedCommand { 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());
        //EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
        //RensaCommand = new Command(async () => RensaAsync());
        //ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
        //ElementTappedCommand = new Command<RoundBuilderElement>((selectedElement) => RoundSelected(selectedElement));

    }

    private async Task StoreAndHandleAsync()
    {
        base.StoreAndHandlePoints();
        //await Shell.Current.GoToAsync("..");
        await Shell.Current.GoToAsync("Påbörja eller fortsätt Runda");
    }

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