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.
44 lines
1.2 KiB
44 lines
1.2 KiB
using Models;
|
|
|
|
namespace ShoopNCook.Pages;
|
|
|
|
using Endpoint;
|
|
using Models;
|
|
using ShoopNCook.Views;
|
|
|
|
public partial class FavoritesPage : ContentPage
|
|
{
|
|
|
|
private readonly Account account;
|
|
private readonly IUserNotifier notifier;
|
|
private IRecipesService service;
|
|
|
|
public FavoritesPage(Account account, IUserNotifier notifier, IRecipesService service)
|
|
{
|
|
InitializeComponent();
|
|
this.account = account;
|
|
this.notifier = notifier;
|
|
this.service = service;
|
|
|
|
UpdateFavorites();
|
|
}
|
|
|
|
private void UpdateFavorites()
|
|
{
|
|
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
|
RecipeViewLayout.Children.Clear();
|
|
preferences.GetFavorites().ForEach(info =>
|
|
{
|
|
RecipeViewLayout.Children.Add(new RecipeView(info, () =>
|
|
{
|
|
Recipe recipe = service.GetRecipe(info);
|
|
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1));
|
|
}));
|
|
});
|
|
}
|
|
|
|
private void ContentPage_NavigatedTo(object sender, NavigatedToEventArgs e)
|
|
{
|
|
UpdateFavorites();
|
|
}
|
|
} |