diff --git a/Resources/Images/earth_off.svg b/Resources/Images/hearth_off.svg
similarity index 100%
rename from Resources/Images/earth_off.svg
rename to Resources/Images/hearth_off.svg
diff --git a/Resources/Images/earth_on.svg b/Resources/Images/hearth_on.svg
similarity index 100%
rename from Resources/Images/earth_on.svg
rename to Resources/Images/hearth_on.svg
diff --git a/Resources/Images/star_empty.svg b/Resources/Images/star_empty.svg
new file mode 100644
index 0000000..2ee298f
--- /dev/null
+++ b/Resources/Images/star_empty.svg
@@ -0,0 +1,3 @@
+
diff --git a/Resources/Images/star_full.svg b/Resources/Images/star_full.svg
new file mode 100644
index 0000000..58bea28
--- /dev/null
+++ b/Resources/Images/star_full.svg
@@ -0,0 +1,3 @@
+
diff --git a/ShoopNCook.csproj b/ShoopNCook.csproj
index de34a4b..ff78320 100644
--- a/ShoopNCook.csproj
+++ b/ShoopNCook.csproj
@@ -50,14 +50,16 @@
-
-
+
+
+
+
diff --git a/Views/RecipePage.xaml b/Views/RecipePage.xaml
index 95bb063..73b3319 100644
--- a/Views/RecipePage.xaml
+++ b/Views/RecipePage.xaml
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ShoopNCook.Views.RecipePage"
Title="RecipePage"
+ x:Name="RecipeViewPage"
BackgroundColor="{StaticResource BackgroundPrimary}">
+ RowDefinitions="*, Auto, Auto, 0.5*">
@@ -99,6 +100,51 @@
x:Name="StepList"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -149,7 +195,7 @@
StrokeShape="RoundRectangle 100"
BackgroundColor="{StaticResource Selected}">
diff --git a/Views/RecipePage.xaml.cs b/Views/RecipePage.xaml.cs
index ba2b5cf..e5a8424 100644
--- a/Views/RecipePage.xaml.cs
+++ b/Views/RecipePage.xaml.cs
@@ -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(count =>
+ {
+ SetNote(uint.Parse(count));
+ });
+
public RecipePage() :
this("Recipe Sample", 32, 250,
- true, 1,
+ true, 2, 0,
new List {
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 ingredients,
List 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();
}
}
\ No newline at end of file