You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
55 lines
1.0 KiB
using ShoopNCook.Pages;
|
|
using Models;
|
|
namespace ShoopNCook.Views;
|
|
|
|
public partial class RecipeView : ContentView
|
|
{
|
|
|
|
private readonly Action callback;
|
|
|
|
public RecipeView(RecipeInfo info, Action onClickCallback)
|
|
{
|
|
InitializeComponent();
|
|
Note = info.AverageNote;
|
|
Title = info.Name;
|
|
Subtitle = info.CookTimeMins + " min";
|
|
RecipeImage.Source = ImageSource.FromUri(info.Image);
|
|
|
|
callback = onClickCallback;
|
|
|
|
}
|
|
|
|
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 void OnRecipeTapped(object sender, EventArgs e)
|
|
{
|
|
callback();
|
|
}
|
|
} |