parent
c669811f0d
commit
03d02a606b
Before Width: | Height: | Size: 911 B After Width: | Height: | Size: 911 B |
Before Width: | Height: | Size: 461 B After Width: | Height: | Size: 464 B |
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="ShoopNCook.Views.IngredientView"
|
||||||
|
x:Name="Ingredient">
|
||||||
|
<HorizontalStackLayout
|
||||||
|
Spacing="2">
|
||||||
|
<Label
|
||||||
|
Text="•"
|
||||||
|
Style="{StaticResource Small}"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="{Binding Name, Source={x:Reference Ingredient}}"
|
||||||
|
Style="{StaticResource Small}"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="{Binding Quantity, Source={x:Reference Ingredient}}"
|
||||||
|
Style="{StaticResource Small}"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="{Binding Unit, Source={x:Reference Ingredient}}"
|
||||||
|
Style="{StaticResource Small}"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
</ContentView>
|
@ -0,0 +1,41 @@
|
|||||||
|
namespace ShoopNCook.Views;
|
||||||
|
|
||||||
|
public partial class IngredientView : ContentView
|
||||||
|
{
|
||||||
|
|
||||||
|
public static readonly BindableProperty NameProperty =
|
||||||
|
BindableProperty.Create(nameof(Name), typeof(string), typeof(IngredientView), default(string));
|
||||||
|
|
||||||
|
public static readonly BindableProperty QuantityProperty =
|
||||||
|
BindableProperty.Create(nameof(Quantity), typeof(float), typeof(IngredientView), default(float));
|
||||||
|
|
||||||
|
public static readonly BindableProperty UnitProperty =
|
||||||
|
BindableProperty.Create(nameof(Unit), typeof(string), typeof(IngredientView), default(string));
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => (string)GetValue(NameProperty);
|
||||||
|
set => SetValue(NameProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Quantity
|
||||||
|
{
|
||||||
|
get => (float)GetValue(QuantityProperty);
|
||||||
|
set => SetValue(QuantityProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Unit
|
||||||
|
{
|
||||||
|
get => (string)GetValue(UnitProperty);
|
||||||
|
set => SetValue(UnitProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IngredientView(string name, float quantity, string unit)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
Name = name;
|
||||||
|
Quantity = quantity;
|
||||||
|
Unit = unit;
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,87 @@
|
|||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
|
||||||
namespace ShoopNCook.Views;
|
namespace ShoopNCook.Views;
|
||||||
|
|
||||||
public partial class RecipePage : ContentPage
|
public partial class RecipePage : ContentPage
|
||||||
{
|
{
|
||||||
public RecipePage()
|
|
||||||
|
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();
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue