From 9c0cbc874a5fa47c38d6058a1fb049f46098e1ee Mon Sep 17 00:00:00 2001 From: "maxime.BATISTA@etu.uca.fr" Date: Thu, 13 Apr 2023 17:23:33 +0200 Subject: [PATCH 1/2] add favorite pages --- AppShell.xaml | 6 ++ ShoopNCook - Backup (2).csproj | 104 +++++++++++++++++++++++++++++++++ ShoopNCook.csproj | 16 +---- Views/FavoritesPage.xaml | 54 +++++++++++++++++ Views/FavoritesPage.xaml.cs | 9 +++ Views/IngredientView.xaml.cs | 6 +- Views/RecipePage.xaml | 40 ++++++------- Views/RecipeView.xaml | 25 +++++++- Views/RecipeView.xaml.cs | 37 +++++++++++- Views/SearchPage.xaml | 18 +++--- 10 files changed, 265 insertions(+), 50 deletions(-) create mode 100644 ShoopNCook - Backup (2).csproj create mode 100644 Views/FavoritesPage.xaml create mode 100644 Views/FavoritesPage.xaml.cs diff --git a/AppShell.xaml b/AppShell.xaml index 4d952b1..2f54421 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -28,9 +28,15 @@ Title="Register Page" ContentTemplate="{DataTemplate views:RegisterPage}" Route="Register" /> + + + \ No newline at end of file diff --git a/ShoopNCook - Backup (2).csproj b/ShoopNCook - Backup (2).csproj new file mode 100644 index 0000000..9099e0e --- /dev/null +++ b/ShoopNCook - Backup (2).csproj @@ -0,0 +1,104 @@ + + + + net7.0-android;net7.0-ios;net7.0-maccatalyst + $(TargetFrameworks);net7.0-windows10.0.19041.0 + + + Exe + ShoopNCook + true + true + enable + + + ShoopNCook + + + com.companyname.shoopncook + bf17e1fe-a722-42f6-a24d-3327d351c924 + + + 1.0 + 1 + + 11.0 + 13.1 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + + + diff --git a/ShoopNCook.csproj b/ShoopNCook.csproj index ff78320..d32645e 100644 --- a/ShoopNCook.csproj +++ b/ShoopNCook.csproj @@ -49,18 +49,10 @@ - - - - - - - - @@ -79,21 +71,15 @@ - + MSBuild:Compile MSBuild:Compile - - MSBuild:Compile - MSBuild:Compile - - MSBuild:Compile - MSBuild:Compile diff --git a/Views/FavoritesPage.xaml b/Views/FavoritesPage.xaml new file mode 100644 index 0000000..2d9bc1b --- /dev/null +++ b/Views/FavoritesPage.xaml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Views/FavoritesPage.xaml.cs b/Views/FavoritesPage.xaml.cs new file mode 100644 index 0000000..b9372af --- /dev/null +++ b/Views/FavoritesPage.xaml.cs @@ -0,0 +1,9 @@ +namespace ShoopNCook.Views; + +public partial class FavoritesPage : ContentPage +{ + public FavoritesPage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Views/IngredientView.xaml.cs b/Views/IngredientView.xaml.cs index 01288d8..2013447 100644 --- a/Views/IngredientView.xaml.cs +++ b/Views/IngredientView.xaml.cs @@ -3,13 +3,13 @@ namespace ShoopNCook.Views; public partial class IngredientView : ContentView { - public static readonly BindableProperty NameProperty = + private readonly BindableProperty NameProperty = BindableProperty.Create(nameof(Name), typeof(string), typeof(IngredientView), default(string)); - public static readonly BindableProperty QuantityProperty = + private readonly BindableProperty QuantityProperty = BindableProperty.Create(nameof(Quantity), typeof(float), typeof(IngredientView), default(float)); - public static readonly BindableProperty UnitProperty = + private readonly BindableProperty UnitProperty = BindableProperty.Create(nameof(Unit), typeof(string), typeof(IngredientView), default(string)); public string Name diff --git a/Views/RecipePage.xaml b/Views/RecipePage.xaml index 16e690b..9423b7c 100644 --- a/Views/RecipePage.xaml +++ b/Views/RecipePage.xaml @@ -108,26 +108,26 @@ x:Name="Stars" Spacing="2" Margin="10, 0, 0, 0"> - - - - - + + + + + - + + + + + + + + + + diff --git a/Views/RecipeView.xaml.cs b/Views/RecipeView.xaml.cs index 07d00b6..65035dd 100644 --- a/Views/RecipeView.xaml.cs +++ b/Views/RecipeView.xaml.cs @@ -2,8 +2,43 @@ namespace ShoopNCook.Views; public partial class RecipeView : ContentView { - public RecipeView() + + private readonly BindableProperty NoteProperty; + + + public float Note { + get => (float) GetValue(NoteProperty); + set => SetValue(NoteProperty, value); + } + + public RecipeView(): this(5) + {} + + public RecipeView(float note) { InitializeComponent(); + NoteProperty = BindableProperty.Create( + nameof(Note), + typeof(float), + typeof(RecipeView), + 0F, + propertyChanged: (_, _, v) => UpdateNotes((float) v) + ); + + Note = note; } + + private void UpdateNotes(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/SearchPage.xaml b/Views/SearchPage.xaml index 728dd96..3cf2376 100644 --- a/Views/SearchPage.xaml +++ b/Views/SearchPage.xaml @@ -12,17 +12,15 @@ + RowDefinitions="Auto, *" + ColumnDefinitions="*, 1.5*" + Margin="0, 0, 0, 30"> - - - + diff --git a/Views/RecipeView.xaml b/Views/RecipeView.xaml index a8e6c8e..5b051ee 100644 --- a/Views/RecipeView.xaml +++ b/Views/RecipeView.xaml @@ -48,10 +48,10 @@ diff --git a/Views/RecipeView.xaml.cs b/Views/RecipeView.xaml.cs index 65035dd..8dcd0ea 100644 --- a/Views/RecipeView.xaml.cs +++ b/Views/RecipeView.xaml.cs @@ -3,32 +3,35 @@ namespace ShoopNCook.Views; public partial class RecipeView : ContentView { - private readonly BindableProperty NoteProperty; - - public float Note { - get => (float) GetValue(NoteProperty); - set => SetValue(NoteProperty, value); - } - - public RecipeView(): this(5) + public RecipeView(): this(5, "Title", "Subtitle") {} - public RecipeView(float note) + public RecipeView(float note, string title, string subtitle) { InitializeComponent(); - NoteProperty = BindableProperty.Create( - nameof(Note), - typeof(float), - typeof(RecipeView), - 0F, - propertyChanged: (_, _, v) => UpdateNotes((float) v) - ); - Note = note; + Title = title; + Subtitle = subtitle; } - private void UpdateNotes(float note) + 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)