using CanYouBuildIt.Model;
using System.Diagnostics;
using System.Reflection;

namespace CanYouBuildIt.Views;

public partial class Acceuil : ContentPage
{
	public Manager manager=> (App.Current as App).manager;
    bool connecte = false;
    int user;

	public Acceuil()
	{
		InitializeComponent();
        BindingContext = manager;
    }

    public Acceuil(int iduser)
    {
        InitializeComponent();
        BindingContext = manager;
        connecte = true;
        user = iduser;
    }

    //Ancien test
    /*private void AddUtilisater(object sender, EventArgs e)
	{
		Utilisateur utilisateur = new Utilisateur("Util1","pdm1");
		Debug.WriteLine("Utilisateur créé");
	}*/

    private async void NavFav(object sender, EventArgs e)
    {
        if (connecte)
            await Navigation.PushAsync(new Favoris(user));
        else
        {
            aConnecter.IsVisible = true;
            await Task.Delay(3000);
            aConnecter.IsVisible = false;
        }
    }

    private async void NavCreds(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new Credits());
    }
    private async void NavLogin(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new Login());
    }

    private void ToQuit(object sender, EventArgs e)
    {
        App.Current.Quit();
    }
}