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