|
|
|
@ -1,16 +1,23 @@
|
|
|
|
|
using Microsoft.Maui.Controls;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace ShoopNCook.Views;
|
|
|
|
|
|
|
|
|
|
public partial class RecipePage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private uint note;
|
|
|
|
|
private uint nbPers;
|
|
|
|
|
private bool isFavorite;
|
|
|
|
|
|
|
|
|
|
public ICommand StarCommand => new Command<string>(count =>
|
|
|
|
|
{
|
|
|
|
|
SetNote(uint.Parse(count));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
public RecipePage() :
|
|
|
|
|
this("Recipe Sample", 32, 250,
|
|
|
|
|
true, 1,
|
|
|
|
|
true, 2, 0,
|
|
|
|
|
new List<IngredientView> {
|
|
|
|
|
new IngredientView("Chocolate", 25, "g"),
|
|
|
|
|
new IngredientView("Flour", 250, "g"),
|
|
|
|
@ -26,13 +33,15 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
uint energy,
|
|
|
|
|
bool isFavorite,
|
|
|
|
|
uint nbPers,
|
|
|
|
|
uint note,
|
|
|
|
|
List<IngredientView> ingredients,
|
|
|
|
|
List<string> steps
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.nbPers = nbPers;
|
|
|
|
|
this.isFavorite = isFavorite;
|
|
|
|
|
SetNbPers(nbPers);
|
|
|
|
|
SetFavorite(isFavorite);
|
|
|
|
|
SetNote(note);
|
|
|
|
|
|
|
|
|
|
CookTime.Text = cookTime.ToString();
|
|
|
|
|
Energy.Text = energy.ToString();
|
|
|
|
@ -52,36 +61,55 @@ public partial class RecipePage : ContentPage
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetNote(uint note)
|
|
|
|
|
{
|
|
|
|
|
this.note = note;
|
|
|
|
|
int i = 1;
|
|
|
|
|
foreach (ImageButton img in Stars.Children)
|
|
|
|
|
{
|
|
|
|
|
if (i <= note)
|
|
|
|
|
{
|
|
|
|
|
img.Source = ImageSource.FromFile("star_full.svg");
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
img.Source = ImageSource.FromFile("star_empty.svg");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnFavorite(object o, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isFavorite = !isFavorite;
|
|
|
|
|
if (isFavorite)
|
|
|
|
|
SetFavorite(!isFavorite);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetFavorite(bool isFavorite)
|
|
|
|
|
{
|
|
|
|
|
this.isFavorite = isFavorite;
|
|
|
|
|
if (isFavorite)
|
|
|
|
|
{
|
|
|
|
|
Favorite.Source = ImageSource.FromFile("earth_on.svg");
|
|
|
|
|
Favorite.Source = ImageSource.FromFile("hearth_on.svg");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Favorite.Source = ImageSource.FromFile("earth_off.svg");
|
|
|
|
|
Favorite.Source = ImageSource.FromFile("hearth_off.svg");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPlus(object o, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateCounter(++nbPers);
|
|
|
|
|
SetNbPers(nbPers + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMinus(object o, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (nbPers <= 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
nbPers--;
|
|
|
|
|
UpdateCounter(nbPers);
|
|
|
|
|
SetNbPers(nbPers - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateCounter(uint counter)
|
|
|
|
|
private void SetNbPers(uint nbPers)
|
|
|
|
|
{
|
|
|
|
|
NbPersLabel.Text = counter.ToString();
|
|
|
|
|
|
|
|
|
|
this.nbPers = nbPers <= 1 ? 1 : nbPers;
|
|
|
|
|
NbPersLabel.Text = this.nbPers.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|