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 Services;
|
|
using Services;
|
|
using Models;
|
|
using ShoopNCook.Views;
|
|
|
|
namespace ShoopNCook.Pages;
|
|
|
|
public partial class MyListPage : ContentPage
|
|
{
|
|
|
|
private readonly IAccountRecipesPreferencesService preferences;
|
|
private readonly IRecipesService service;
|
|
|
|
public MyListPage(Account account, IRecipesService service)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.preferences = service.GetPreferencesOf(account);
|
|
this.service = service;
|
|
|
|
UpdateMyList();
|
|
}
|
|
|
|
private void UpdateMyList()
|
|
{
|
|
RecipesLayout.Children.Clear();
|
|
preferences.GetWeeklyList().ForEach(tuple =>
|
|
{
|
|
RecipeInfo info = tuple.Item1;
|
|
RecipesLayout.Children.Add(new StoredRecipeView(info, tuple.Item2, amount =>
|
|
{
|
|
Recipe recipe = service.GetRecipe(info);
|
|
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, preferences, amount));
|
|
}));
|
|
});
|
|
}
|
|
|
|
private async void ContentPage_NavigatedTo(object sender, NavigatedToEventArgs e)
|
|
{
|
|
UpdateMyList();
|
|
}
|
|
} |