diff --git a/lib/pages/add_recipe_page.dart b/lib/pages/add_recipe_page.dart index 5c104e0..8af6e33 100644 --- a/lib/pages/add_recipe_page.dart +++ b/lib/pages/add_recipe_page.dart @@ -163,12 +163,9 @@ class AddRecipePageState extends State { width: double.infinity, child: TextButton( onPressed: () async { - if (pizzaRecipe.isInBox){ - pizzaRecipe.save(); - } else { - final pizzaRecipesBox = await Hive.openBox("PizzaRecipes"); - pizzaRecipesBox.add(pizzaRecipe); - } + showDialog(context: context, builder: (BuildContext context) { + return buildConfirmSaveDialog(); + }); }, child: const Text("Save", style: TextStyle(color: Colors.white)), ) @@ -177,6 +174,36 @@ class AddRecipePageState extends State { ), ); } + + AlertDialog buildConfirmSaveDialog(){ + return AlertDialog( + title: const Text("Save?"), + content: const Text("Are you sure you want to save the Pizza Recipe?"), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("No"), + ), + TextButton( + onPressed: () async { + if (pizzaRecipe.isInBox){ + pizzaRecipe.save(); + } else { + final pizzaRecipesBox = await Hive.openBox("PizzaRecipes"); + pizzaRecipesBox.add(pizzaRecipe); + } + if (!mounted){ + return; + } + Navigator.pop(context); + }, + child: const Text("Yes"), + ), + ] + ); + } Widget buildIngredientRow(Ingredient ingredient){ return Row( diff --git a/todo.md b/todo.md index 22f3d5e..ef3ab8f 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,6 @@ # TODO ## Feature -- confirm save recipe, maybe jump back to the recipes page with toast popup - add way to remove recipes - add search to recipes page - add directory structure to recipes?