You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
|
|
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)
|
|
{
|
|
InitializeComponent();
|
|
|
|
IRecipesService service = endpoint.RecipesService;
|
|
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
|
|
|
|
|
//TODO this code can be factorised
|
|
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);
|
|
ProfilePictureName.Text = account.User.Name;
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSyncButtonClicked(object sender, EventArgs e)
|
|
{
|
|
Shell.Current.Navigation.PushAsync(new SearchPage());
|
|
}
|
|
} |