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.
59 lines
1.1 KiB
59 lines
1.1 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();
|
|
|
|
if (info.Image != null)
|
|
RecipeImage.Source = ImageSource.FromUri(info.Image);
|
|
|
|
Note = info.AverageNote;
|
|
Title = info.Name;
|
|
Subtitle = info.CookTimeMins + " min";
|
|
|
|
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)
|
|
{
|
|
note = (uint)note; //truncate integer as we currently do not handle semi stars
|
|
foreach (Image img in Stars.Children.Reverse())
|
|
{
|
|
if (note > 0)
|
|
{
|
|
img.Opacity = 1;
|
|
note--;
|
|
}
|
|
else img.Opacity = 0;
|
|
}
|
|
}
|
|
private void OnRecipeTapped(object sender, EventArgs e)
|
|
{
|
|
callback();
|
|
}
|
|
} |