From 70b1237f2ed3c378678758473110750d02e2764d Mon Sep 17 00:00:00 2001 From: Maxime BATISTA Date: Mon, 22 May 2023 16:12:13 +0200 Subject: [PATCH] add error notification when a RecipeView is clicked without the recipe being found --- Views/HomePage.xaml.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Views/HomePage.xaml.cs b/Views/HomePage.xaml.cs index b74cfd2..3b46cb2 100644 --- a/Views/HomePage.xaml.cs +++ b/Views/HomePage.xaml.cs @@ -20,8 +20,13 @@ public partial class HomePage : ContentPage { layout.Children.Add(new RecipeView(info, () => { - Recipe recipe = service.GetRecipe(info); - Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1)); + Recipe? recipe = service.GetRecipe(info); + if (recipe != null) + Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1)); + else + { + notifier.Error("Could not find recipe"); + } })); }