added confirm dialog when saving a recipe
This commit is contained in:
parent
ce9ddf3722
commit
a70f561eaa
2 changed files with 33 additions and 7 deletions
|
@ -163,12 +163,9 @@ class AddRecipePageState extends State<AddRecipePage> {
|
|||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: () async {
|
||||
if (pizzaRecipe.isInBox){
|
||||
pizzaRecipe.save();
|
||||
} else {
|
||||
final pizzaRecipesBox = await Hive.openBox<PizzaRecipe>("PizzaRecipes");
|
||||
pizzaRecipesBox.add(pizzaRecipe);
|
||||
}
|
||||
showDialog(context: context, builder: (BuildContext context) {
|
||||
return buildConfirmSaveDialog();
|
||||
});
|
||||
},
|
||||
child: const Text("Save", style: TextStyle(color: Colors.white)),
|
||||
)
|
||||
|
@ -178,6 +175,36 @@ class AddRecipePageState extends State<AddRecipePage> {
|
|||
);
|
||||
}
|
||||
|
||||
AlertDialog buildConfirmSaveDialog(){
|
||||
return AlertDialog(
|
||||
title: const Text("Save?"),
|
||||
content: const Text("Are you sure you want to save the Pizza Recipe?"),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("No"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (pizzaRecipe.isInBox){
|
||||
pizzaRecipe.save();
|
||||
} else {
|
||||
final pizzaRecipesBox = await Hive.openBox<PizzaRecipe>("PizzaRecipes");
|
||||
pizzaRecipesBox.add(pizzaRecipe);
|
||||
}
|
||||
if (!mounted){
|
||||
return;
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Yes"),
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildIngredientRow(Ingredient ingredient){
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
|
|
1
todo.md
1
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?
|
||||
|
|
Loading…
Add table
Reference in a new issue