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.
ShopNCook/Views/Components/StoredRecipeView.xaml.cs

45 lines
976 B

using Models;
namespace ShoopNCook.Views;
public partial class StoredRecipeView : ContentView
{
private readonly Action<uint> clickCallback;
public StoredRecipeView(RecipeInfo info, uint personCount, Action<uint> onClickCallback)
{
InitializeComponent();
Note = info.AverageNote;
BindingContext = info;
clickCallback = onClickCallback;
Counter.Count = personCount;
}
public float Note
{
set => SetNote(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, TappedEventArgs e)
{
clickCallback(Counter.Count);
}
}