@@ -14,6 +14,30 @@ enum _ShoppinglistAction {
14
14
class HouseholdSettingsShoppinglistPage extends StatelessWidget {
15
15
const HouseholdSettingsShoppinglistPage ({super .key});
16
16
17
+ static Future <bool > confirmDeleteShoppingList (
18
+ BuildContext context, ShoppingList shoppinglist) async {
19
+ return await askForConfirmation (
20
+ context: context,
21
+ title: Text (
22
+ AppLocalizations .of (context)! .shoppingListDelete,
23
+ ),
24
+ content: SingleChildScrollView (
25
+ child: ListBody (
26
+ children: [
27
+ Text (
28
+ AppLocalizations .of (context)! .shoppingListDeleteConfirmation (
29
+ shoppinglist.name,
30
+ ),
31
+ ),
32
+ if (shoppinglist.items.length > 0 ) const SizedBox (height: 20 ),
33
+ if (shoppinglist.items.length > 0 )
34
+ Text (AppLocalizations .of (context)!
35
+ .shoppingListContainsEntries (shoppinglist.items.length))
36
+ ],
37
+ ),
38
+ ));
39
+ }
40
+
17
41
@override
18
42
Widget build (BuildContext context) {
19
43
return Scaffold (
@@ -66,20 +90,9 @@ class HouseholdSettingsShoppinglistPage extends StatelessWidget {
66
90
state.shoppingLists.elementAt (i).name,
67
91
),
68
92
isDismissable: i != 0 ,
69
- confirmDismiss: (direction) async {
70
- return (await askForConfirmation (
71
- context: context,
72
- title: Text (
73
- AppLocalizations .of (context)! .shoppingListDelete,
74
- ),
75
- content: Text (
76
- AppLocalizations .of (context)!
77
- .shoppingListDeleteConfirmation (
78
- state.shoppingLists.elementAt (i).name,
79
- ),
80
- ),
81
- ));
82
- },
93
+ confirmDismiss: (direction) async =>
94
+ await confirmDeleteShoppingList (
95
+ context, state.shoppingLists.elementAt (i)),
83
96
onDismissed: (direction) {
84
97
BlocProvider .of <HouseholdUpdateCubit >(context)
85
98
.deleteShoppingList (
@@ -201,17 +214,8 @@ class HouseholdSettingsShoppinglistPage extends StatelessWidget {
201
214
}
202
215
break ;
203
216
case _ShoppinglistAction .delete:
204
- if (await askForConfirmation (
205
- context: context,
206
- title: Text (
207
- AppLocalizations .of (context)! .shoppingListDelete,
208
- ),
209
- content: Text (
210
- AppLocalizations .of (context)! .shoppingListDeleteConfirmation (
211
- shoppingLists.elementAt (shoppingListIndex).name,
212
- ),
213
- ),
214
- )) {
217
+ if (await confirmDeleteShoppingList (
218
+ context, shoppingLists.elementAt (shoppingListIndex))) {
215
219
BlocProvider .of <HouseholdUpdateCubit >(context).deleteShoppingList (
216
220
shoppingLists.elementAt (shoppingListIndex),
217
221
);
0 commit comments