commit
3b9d9f197a
@ -1,4 +1,7 @@
|
|||||||
[*.cs]
|
[*.cs]
|
||||||
|
|
||||||
# CS0618: Le type ou le membre est obsolète
|
# CS0618: Le type ou le membre est obsolète
|
||||||
dotnet_diagnostic.CS0618.severity = silent
|
dotnet_diagnostic.CS0618.severity = silent
|
||||||
|
|
||||||
|
# CS1998: Async method lacks 'await' operators and will run synchronously
|
||||||
|
dotnet_diagnostic.CS1998.severity = none
|
@ -1,42 +1,46 @@
|
|||||||
|
namespace ShoopNCook.Pages;
|
||||||
namespace ShoopNCook.Pages;
|
using Models;
|
||||||
using Models;
|
using ShoopNCook.Views;
|
||||||
using ShoopNCook.Views;
|
using Endpoint;
|
||||||
using Endpoint;
|
using LocalEndpoint;
|
||||||
using LocalEndpoint;
|
|
||||||
|
public partial class HomePage : ContentPage
|
||||||
public partial class HomePage : ContentPage
|
{
|
||||||
{
|
public HomePage(Account account, IEndpoint endpoint)
|
||||||
public HomePage(Account account, IEndpoint endpoint)
|
{
|
||||||
{
|
InitializeComponent();
|
||||||
InitializeComponent();
|
|
||||||
|
IRecipesService service = endpoint.RecipesService;
|
||||||
IRecipesService service = endpoint.RecipesService;
|
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
||||||
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
|
||||||
|
|
||||||
|
//TODO this code can be factorised
|
||||||
//TODO this code can be factorised
|
void PushRecipe(Layout layout, RecipeInfo info)
|
||||||
void PushRecipe(Layout layout, RecipeInfo info)
|
{
|
||||||
{
|
layout.Children.Add(new RecipeView(info, () =>
|
||||||
layout.Children.Add(new RecipeView(info, () =>
|
{
|
||||||
{
|
Recipe? recipe = service.GetRecipe(info);
|
||||||
Recipe recipe = service.GetRecipe(info);
|
if (recipe != null)
|
||||||
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, preferences, 1));
|
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, preferences, 1));
|
||||||
}));
|
else
|
||||||
}
|
{
|
||||||
|
UserNotifier.Error("Could not find recipe");
|
||||||
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;
|
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());
|
|
||||||
}
|
|
||||||
|
private async void OnSyncButtonClicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
await Shell.Current.Navigation.PushAsync(new SearchPage());
|
||||||
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue