diff --git a/Endpoint/IRecipesService.cs b/Endpoint/IRecipesService.cs index 64a392d..5f78d26 100644 --- a/Endpoint/IRecipesService.cs +++ b/Endpoint/IRecipesService.cs @@ -9,12 +9,17 @@ namespace Endpoint { public interface IRecipesService { - public List RecommendedRecipes(Account account); public List PopularRecipes(); public Recipe GetRecipe(RecipeInfo info); + public List RecommendedRecipesOf(Account account); + + public List LookupFavoritesOf(Account account); + + public List<(RecipeInfo, uint)> LookupWeeklyListOf(Account account); + public AccountRecipeRate GetRateOf(Account account, Recipe recipe); } } diff --git a/LocalEndpoint/RecipesService.cs b/LocalEndpoint/RecipesService.cs index 10ad843..ad91dd9 100644 --- a/LocalEndpoint/RecipesService.cs +++ b/LocalEndpoint/RecipesService.cs @@ -17,8 +17,16 @@ namespace LocalEndpoint }; } + public Recipe GetRecipe(RecipeInfo info) + { + User owner = new User(new Uri("https://i.ibb.co/L6t6bGR/DALL-E-2023-05-10-20-27-31-cook-looking-at-the-camera-with-a-chef-s-hat-laughing-in-an-exaggerated-w.png"), "The Funny Chief"); + List ingredients = new List { new Ingredient("Banana", 12), new Ingredient("Apple", 2) }; + List steps = new List { new PreparationStep("Step 1", "This step is an hardcoded step from a stub implementation of IRecipesSeervice") }; + return new Recipe(info, owner, ingredients, steps); + } + - public List RecommendedRecipes(Account account) + public List RecommendedRecipesOf(Account account) { return new List { new RecipeInfo("Chicken Salad", 500, 20, new Uri("https://healthyfitnessmeals.com/wp-content/uploads/2021/04/Southwest-chicken-salad-7-500x500.jpg"), 4), @@ -29,14 +37,26 @@ namespace LocalEndpoint }; } - public Recipe GetRecipe(RecipeInfo info) + public List LookupFavoritesOf(Account account) { - User owner = new User(new Uri("https://i.ibb.co/L6t6bGR/DALL-E-2023-05-10-20-27-31-cook-looking-at-the-camera-with-a-chef-s-hat-laughing-in-an-exaggerated-w.png"), "The Funny Chief"); - List ingredients = new List { new Ingredient("Banana", 12), new Ingredient("Apple", 2) }; - List steps = new List { new PreparationStep("Step 1", "This step is an hardcoded step from a stub implementation of IRecipesSeervice") }; - return new Recipe(info, owner, ingredients, steps); + return new List { + new RecipeInfo("Chicken Salad", 500, 20, new Uri("https://healthyfitnessmeals.com/wp-content/uploads/2021/04/Southwest-chicken-salad-7-500x500.jpg"), 4), + new RecipeInfo("Space Cake", 800, 5, new Uri("https://static.youmiam.com/images/recipe/1500x1000/space-cake-22706?placeholder=web_recipe&sig=f14a7a86da837c6b8cc678cde424d6d5902f99ec&v3"), 5), + new RecipeInfo("Fish And Ships", 450, 15, new Uri("https://upload.wikimedia.org/wikipedia/commons/f/ff/Fish_and_chips_blackpool.jpg"), 4), + new RecipeInfo("Caesar Salad", 150, 20, new Uri("https://www.galbani.fr/wp-content/uploads/2020/04/AdobeStock_157570276-2.jpeg"), 1) + }; } + public List<(RecipeInfo, uint)> LookupWeeklyListOf(Account account) + { + return new List<(RecipeInfo, uint)> { + (new RecipeInfo("Space Cake", 800, 5, new Uri("https://static.youmiam.com/images/recipe/1500x1000/space-cake-22706?placeholder=web_recipe&sig=f14a7a86da837c6b8cc678cde424d6d5902f99ec&v3"), 5), 4), + (new RecipeInfo("Chicken Curry", 500, 45, new Uri("https://cdn.chefclub.tools/uploads/recipes/cover-thumbnail/f287b191-dc8e-4c85-bbb6-e26387c354d3.jpg"), 3), 4), + (new RecipeInfo("Spaghetti Bolognese", 1000, 30, new Uri("https://media.istockphoto.com/id/1144823591/fr/photo/spaghetti-dans-un-plat-sur-un-fond-blanc.jpg?s=612x612&w=0&k=20&c=qFzd8iE185mpsX7hWqYaieOWlzJVCkzFdYsxmwUT3-Q="), 1), 1), + }; + } + + public AccountRecipeRate GetRateOf(Account account, Recipe recipe) { Random random = new Random(); diff --git a/MainAppShell.xaml.cs b/MainAppShell.xaml.cs index 70ce6aa..218e9de 100644 --- a/MainAppShell.xaml.cs +++ b/MainAppShell.xaml.cs @@ -1,17 +1,17 @@ -namespace ShoopNCook; -using Microsoft.Maui.Controls; -using Models; +namespace ShoopNCook; +using Microsoft.Maui.Controls; +using Models; using ShoopNCook.Controllers; using ShoopNCook.Pages; using Endpoint; -public partial class MainAppShell : Shell -{ - public MainAppShell(Account account, IEndpoint endpoint, IApp app) - { - InitializeComponent(); - HomeTab.ContentTemplate = new DataTemplate(() => new HomePage(account, endpoint)); - FavoritesTab.ContentTemplate = new DataTemplate(() => new FavoritesPage(account, app)); - MyListTab.ContentTemplate = new DataTemplate(() => new MyListPage(account, app)); - MoreTab.ContentTemplate = new DataTemplate(() => new MorePage(account, new MorePageController(app))); - } -} +public partial class MainAppShell : Shell +{ + public MainAppShell(Account account, IEndpoint endpoint, IApp app) + { + InitializeComponent(); + HomeTab.ContentTemplate = new DataTemplate(() => new HomePage(account, endpoint)); + FavoritesTab.ContentTemplate = new DataTemplate(() => new FavoritesPage(account, endpoint.RecipesService)); + MyListTab.ContentTemplate = new DataTemplate(() => new MyListPage(account, endpoint.RecipesService)); + MoreTab.ContentTemplate = new DataTemplate(() => new MorePage(account, new MorePageController(app))); + } +} diff --git a/Views/Components/OwnedRecipeView.xaml.cs b/Views/Components/OwnedRecipeView.xaml.cs index d10a211..257d5f9 100644 --- a/Views/Components/OwnedRecipeView.xaml.cs +++ b/Views/Components/OwnedRecipeView.xaml.cs @@ -28,7 +28,7 @@ public partial class OwnedRecipeView : ContentView int i = 1; foreach (Image img in Stars.Children) { - if (i <= note) + if (i < note) { img.Opacity = 0; i++; diff --git a/Views/Components/RecipeView.xaml.cs b/Views/Components/RecipeView.xaml.cs index c5248aa..44d826b 100644 --- a/Views/Components/RecipeView.xaml.cs +++ b/Views/Components/RecipeView.xaml.cs @@ -12,7 +12,7 @@ public partial class RecipeView : ContentView InitializeComponent(); Note = info.AverageNote; Title = info.Name; - Subtitle = info.CookTimeMins + " min"; + Subtitle = info.CookTimeMins + " min"; RecipeImage.Source = ImageSource.FromUri(info.Image); callback = onClickCallback; @@ -40,7 +40,7 @@ public partial class RecipeView : ContentView int i = 1; foreach (Image img in Stars.Children) { - if (i <= note) + if (i < note) { img.Opacity = 0; i++; diff --git a/Views/Components/StoredRecipeView.xaml b/Views/Components/StoredRecipeView.xaml index 84ecb88..23e6035 100644 --- a/Views/Components/StoredRecipeView.xaml +++ b/Views/Components/StoredRecipeView.xaml @@ -14,13 +14,18 @@ MinimumHeightRequest="250" MinimumWidthRequest="150" RowDefinitions="*, Auto"> + + + + + - + - - + diff --git a/Views/Components/StoredRecipeView.xaml.cs b/Views/Components/StoredRecipeView.xaml.cs index 1eb7ae1..da2a32c 100644 --- a/Views/Components/StoredRecipeView.xaml.cs +++ b/Views/Components/StoredRecipeView.xaml.cs @@ -1,16 +1,23 @@ +using Models; + namespace ShoopNCook.Views; public partial class StoredRecipeView : ContentView { - public StoredRecipeView() : this(5, "Title") - { } + private readonly Action clickCallback; + - public StoredRecipeView(float note, string title) + public StoredRecipeView(RecipeInfo info, uint personCount, Action onClickCallback) { InitializeComponent(); - Note = note; - Title = title; + + clickCallback = onClickCallback; + + Note = info.AverageNote; + Title = info.Name; + RecipeImage.Source = ImageSource.FromUri(info.Image); + Counter.Count = personCount; } public float Note @@ -23,14 +30,12 @@ public partial class StoredRecipeView : ContentView set => TitleLabel.Text = value; } - - private void SetNote(float note) { int i = 1; foreach (Image img in Stars.Children) { - if (i <= note) + if (i < note) { img.Opacity = 0; i++; @@ -38,4 +43,9 @@ public partial class StoredRecipeView : ContentView else img.Opacity = 1; } } + + private void OnRecipeTapped(object sender, TappedEventArgs e) + { + clickCallback(Counter.Count); + } } \ No newline at end of file diff --git a/Views/FavoritesPage.xaml b/Views/FavoritesPage.xaml index 8b1f118..ca8b233 100644 --- a/Views/FavoritesPage.xaml +++ b/Views/FavoritesPage.xaml @@ -15,7 +15,6 @@ ColumnDefinitions="*" MaximumHeightRequest="60"> -