using Plugin.Maui.Audio;
using MusiLib.Model;
namespace MusiLib.Views;

public partial class Accueil : ContentPage, IAllowClick
{

    public Manager MyManager => (App.Current as App).MyManager;
    public Accueil()
	{
		InitializeComponent();
        BindingContext = MyManager;
    }

    private void GoToFavorisButton(object sender, EventArgs e)
    {
        if (!IAllowClick.AllowTap) return;
        else IAllowClick.AllowTap = false;

        Navigation.PushAsync(new Favoris());

        IAllowClick.ResumeTap();
    }

    private void GoToPartitionButton(object sender, EventArgs e)
    {
        if (!IAllowClick.AllowTap) return;
        else IAllowClick.AllowTap = false;

        var button = (ImageButton)sender;
        var idAutomation = button.AutomationId;

        if (int.TryParse(idAutomation, out int id))
        {
            Navigation.PushAsync(new Partition(id));
        }


        IAllowClick.ResumeTap();
    }

}