confirm dialog when deleting a folder

This commit is contained in:
Juan Marulanda De Los Rios 2025-04-28 20:08:35 -04:00
parent a7c30732f4
commit e104f445ab

View File

@ -108,6 +108,12 @@ class _FolderDrawerState extends State<FolderDrawer> {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: const Text("Rename"), child: const Text("Rename"),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("Cancel"),
) )
], ],
); );
@ -116,6 +122,30 @@ class _FolderDrawerState extends State<FolderDrawer> {
return false; return false;
} }
Future<void> doubleCheckDelete(String folderTobeDeleted) async {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Confirm delete of: $folderTobeDeleted"),
actions: [
TextButton(
onPressed: () {
ApiService().deleteFolder(folderTobeDeleted);
Navigator.of(context).pop();
},
child: Text("Yes")),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text("No")),
],
);
});
}
void _showOptions(BuildContext context, String folderName) async { void _showOptions(BuildContext context, String folderName) async {
final RenderBox overlay = final RenderBox overlay =
Overlay.of(context).context.findRenderObject() as RenderBox; Overlay.of(context).context.findRenderObject() as RenderBox;
@ -143,7 +173,8 @@ class _FolderDrawerState extends State<FolderDrawer> {
} else if (value == 'Delete') { } else if (value == 'Delete') {
// Logic for deleting the folder // Logic for deleting the folder
print("Deleting $folderName"); print("Deleting $folderName");
ApiService().deleteFolder(folderName); doubleCheckDelete(folderName);
// ApiService().deleteFolder(folderName);
print('Deleted folder'); print('Deleted folder');
} }
}); });
@ -179,6 +210,12 @@ class NewMailbox extends StatelessWidget {
}, },
child: const Text("Approve"), child: const Text("Approve"),
), ),
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("Cancel"),
)
], ],
); );
} }