diff --git a/Views/Components/RecipeView.xaml.cs b/Views/Components/RecipeView.xaml.cs index 315a4c1..de7cbc9 100644 --- a/Views/Components/RecipeView.xaml.cs +++ b/Views/Components/RecipeView.xaml.cs @@ -1,72 +1,9 @@ -/*using ShoopNCook.Pages; -using Models; -namespace ShoopNCook.Views; - -public partial class RecipeView : ContentView -{ - - private readonly Action callback; - - public RecipeView(RecipeInfo info, Action onClickCallback) - { - InitializeComponent(); - - if (info.Image != null) - RecipeImage.Source = ImageSource.FromUri(info.Image); - - Note = info.AverageNote; - Title = info.Name; - Subtitle = info.CookTimeMins + " min"; - - callback = onClickCallback; - - } - - - - 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) - { - note = (uint)note; //truncate integer as we currently do not handle semi stars - foreach (Image img in Stars.Children.Reverse()) - { - if (note > 0) - { - img.Opacity = 1; - note--; - } - else img.Opacity = 0; - } - } - private void OnRecipeTapped(object sender, EventArgs e) - { - callback(); - } -}*/ - - - -using ShoopNCook.Pages; using Models; + namespace ShoopNCook.Views { public partial class RecipeView : ContentView { - private readonly Action callback; diff --git a/Views/HomePage.xaml.cs b/Views/HomePage.xaml.cs index 69b42f9..5b942e3 100644 --- a/Views/HomePage.xaml.cs +++ b/Views/HomePage.xaml.cs @@ -1,42 +1,41 @@ - -namespace ShoopNCook.Pages; -using Models; -using ShoopNCook.Views; -using Endpoint; -using LocalEndpoint; - -public partial class HomePage : ContentPage -{ - - public HomePage(Account account, IUserNotifier notifier, IEndpoint endpoint) - { - + +namespace ShoopNCook.Pages; +using Models; +using ShoopNCook.Views; +using Endpoint; + +public partial class HomePage : ContentPage +{ + + public HomePage(Account account, IUserNotifier notifier, IEndpoint endpoint) + { + InitializeComponent(); - BindingContext = account; - IRecipesService service = endpoint.RecipesService; - IAccountRecipesPreferences preferences = service.GetPreferencesOf(account); - - - void PushRecipe(Layout layout, RecipeInfo info) - { - layout.Children.Add(new RecipeView(info, () => - { - Recipe recipe = service.GetRecipe(info); - Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1)); - })); - } - - service.PopularRecipes().ForEach(recipe => PushRecipe(PopularsList, recipe)); - preferences.GetRecommendedRecipes().ForEach(recipe => PushRecipe(RecommendedList, recipe)); - - ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture); - } - - - - - private void OnSyncButtonClicked(object sender, EventArgs e) - { - Shell.Current.Navigation.PushAsync(new SearchPage()); - } + BindingContext = account; + IRecipesService service = endpoint.RecipesService; + IAccountRecipesPreferences preferences = service.GetPreferencesOf(account); + + + void PushRecipe(Layout layout, RecipeInfo info) + { + layout.Children.Add(new RecipeView(info, () => + { + Recipe recipe = service.GetRecipe(info); + Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1)); + })); + } + + service.PopularRecipes().ForEach(recipe => PushRecipe(PopularsList, recipe)); + preferences.GetRecommendedRecipes().ForEach(recipe => PushRecipe(RecommendedList, recipe)); + + ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture); + } + + + + + private void OnSyncButtonClicked(object sender, EventArgs e) + { + Shell.Current.Navigation.PushAsync(new SearchPage()); + } } \ No newline at end of file