using ShoopNCook.Pages;

namespace ShoopNCook.Views;

public partial class RecipeView : ContentView
{

	public RecipeView(): this(5, "Title", "Subtitle")
	{}

	public RecipeView(float note, string title, string subtitle)
	{
		InitializeComponent();
        Note = note;
        Title = title;
        Subtitle = subtitle;
	}

    public float Note
    {
        set => SetNote(value);
    }

    public string Title
    {
        set => TitleLabel.Text = value;
    }

    public string Subtitle
    {
        set => SubtitleLabel.Text = value;
    }


    private void SetNote(float note)
	{
        int i = 1;
        foreach (Image img in Stars.Children)
        {
            if (i <= note)
            {
                img.Opacity = 0;
                i++;
            }
            else img.Opacity = 1;
        }
	}
    private async void OnRecipeTapped(object sender, EventArgs e)
    {
        await Shell.Current.Navigation.PushAsync(new RecipePage());
    }
}