diff --git a/AppShell.xaml b/AppShell.xaml index 957514f..cfd4ab8 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -28,5 +28,20 @@ Title="Search Page" ContentTemplate="{DataTemplate views:SearchPage}" Route="Search" /> + + + + + + \ No newline at end of file diff --git a/MainPage.xaml b/MainPage.xaml deleted file mode 100644 index 3c3aa3e..0000000 --- a/MainPage.xaml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Views/RecipePage.xaml.cs b/Views/RecipePage.xaml.cs new file mode 100644 index 0000000..e5a8424 --- /dev/null +++ b/Views/RecipePage.xaml.cs @@ -0,0 +1,115 @@ +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, 2, 0, + new List { + new IngredientView("Chocolate", 25, "g"), + new IngredientView("Flour", 250, "g"), + new IngredientView("Sugar", 0.5F, "kg") + }, + new List { "This is the first preparation step", "add to furnace and wait", "Enjoy !" } + ) + {} + + public RecipePage( + string name, + uint cookTime, + uint energy, + bool isFavorite, + uint nbPers, + uint note, + List ingredients, + List steps + ) + { + InitializeComponent(); + SetNbPers(nbPers); + SetFavorite(isFavorite); + SetNote(note); + + 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 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) + { + SetFavorite(!isFavorite); + } + + private void SetFavorite(bool isFavorite) + { + this.isFavorite = isFavorite; + if (isFavorite) + { + Favorite.Source = ImageSource.FromFile("hearth_on.svg"); + } + else + { + Favorite.Source = ImageSource.FromFile("hearth_off.svg"); + } + } + + private void OnPlus(object o, EventArgs e) + { + SetNbPers(nbPers + 1); + } + + private void OnMinus(object o, EventArgs e) + { + SetNbPers(nbPers - 1); + } + + private void SetNbPers(uint nbPers) + { + this.nbPers = nbPers <= 1 ? 1 : nbPers; + NbPersLabel.Text = this.nbPers.ToString(); + } +} \ No newline at end of file diff --git a/Views/RecipeView.xaml b/Views/RecipeView.xaml index 2108f52..5b051ee 100644 --- a/Views/RecipeView.xaml +++ b/Views/RecipeView.xaml @@ -5,36 +5,55 @@ - - - - - - - - - - + Style="{StaticResource SecondaryBorderShadow}" + StrokeShape="RoundRectangle 30"> + + + + + + + + + + + + + + + + + - - diff --git a/Views/RecipeView.xaml.cs b/Views/RecipeView.xaml.cs index 07d00b6..8dcd0ea 100644 --- a/Views/RecipeView.xaml.cs +++ b/Views/RecipeView.xaml.cs @@ -2,8 +2,46 @@ namespace ShoopNCook.Views; public partial class RecipeView : ContentView { - public RecipeView() + + + public RecipeView(): this(5, "Title", "Subtitle") + {} + + public RecipeView(float note, string title, string subtitle) { InitializeComponent(); + Note = note; + Title = title; + Subtitle = subtitle; } + + public float Note + { + set => SetNote(value); + } + + public string Title + { + set => TitleLabel.Text = value; + } + + public string Subtitle + { + set => SubtitleLabel.Text = value; + } + + + private void SetNote(float note) + { + int i = 1; + foreach (Image img in Stars.Children) + { + if (i <= note) + { + img.Opacity = 0; + i++; + } + else img.Opacity = 1; + } + } } \ No newline at end of file diff --git a/Views/RegisterPage.xaml b/Views/RegisterPage.xaml new file mode 100644 index 0000000..4558723 --- /dev/null +++ b/Views/RegisterPage.xaml @@ -0,0 +1,165 @@ + + + + + +