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.
87 lines
2.1 KiB
87 lines
2.1 KiB
using Microsoft.Maui.Controls;
|
|
|
|
namespace ShoopNCook.Views;
|
|
|
|
public partial class RecipePage : ContentPage
|
|
{
|
|
|
|
private uint nbPers;
|
|
private bool isFavorite;
|
|
|
|
public RecipePage() :
|
|
this("Recipe Sample", 32, 250,
|
|
true, 1,
|
|
new List<IngredientView> {
|
|
new IngredientView("Chocolate", 25, "g"),
|
|
new IngredientView("Flour", 250, "g"),
|
|
new IngredientView("Sugar", 0.5F, "kg")
|
|
},
|
|
new List<string> { "This is the first preparation step", "add to furnace and wait", "Enjoy !" }
|
|
)
|
|
{}
|
|
|
|
public RecipePage(
|
|
string name,
|
|
uint cookTime,
|
|
uint energy,
|
|
bool isFavorite,
|
|
uint nbPers,
|
|
List<IngredientView> ingredients,
|
|
List<string> steps
|
|
)
|
|
{
|
|
InitializeComponent();
|
|
this.nbPers = nbPers;
|
|
this.isFavorite = isFavorite;
|
|
|
|
CookTime.Text = cookTime.ToString();
|
|
Energy.Text = energy.ToString();
|
|
RecipeName.Text = name;
|
|
|
|
foreach (IngredientView iv in ingredients)
|
|
IngredientList.Add(iv);
|
|
|
|
var styles = Application.Current.Resources.MergedDictionaries.ElementAt(1);
|
|
|
|
int count = 0;
|
|
foreach (string step in steps) {
|
|
Label label = new Label();
|
|
label.Style = (Style)styles["Small"];
|
|
label.Text = "Step " + ++count + ": " + step;
|
|
StepList.Add(label);
|
|
}
|
|
}
|
|
|
|
private void OnFavorite(object o, EventArgs e)
|
|
{
|
|
isFavorite = !isFavorite;
|
|
if (isFavorite)
|
|
{
|
|
Favorite.Source = ImageSource.FromFile("earth_on.svg");
|
|
}
|
|
else
|
|
{
|
|
Favorite.Source = ImageSource.FromFile("earth_off.svg");
|
|
}
|
|
}
|
|
|
|
private void OnPlus(object o, EventArgs e)
|
|
{
|
|
UpdateCounter(++nbPers);
|
|
}
|
|
|
|
private void OnMinus(object o, EventArgs e)
|
|
{
|
|
if (nbPers <= 1)
|
|
return;
|
|
|
|
nbPers--;
|
|
UpdateCounter(nbPers);
|
|
}
|
|
|
|
private void UpdateCounter(uint counter)
|
|
{
|
|
NbPersLabel.Text = counter.ToString();
|
|
|
|
}
|
|
} |