confirm dialog when deleting a folder
This commit is contained in:
parent
a7c30732f4
commit
e104f445ab
@ -90,32 +90,62 @@ class _FolderDrawerState extends State<FolderDrawer> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text("Rename Mailbox"),
|
title: Text("Rename Mailbox"),
|
||||||
content: TextField(
|
content: TextField(
|
||||||
controller: _renameController,
|
controller: _renameController,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: "New Name",
|
hintText: "New Name",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
String newfolderName = _renameController.text;
|
String newfolderName = _renameController.text;
|
||||||
if (newfolderName.isNotEmpty) {
|
if (newfolderName.isNotEmpty) {
|
||||||
//make an and to make sure there's two folders with the same name
|
//make an and to make sure there's two folders with the same name
|
||||||
ApiService().renameFolder(oldFolder, newfolderName);
|
ApiService().renameFolder(oldFolder, newfolderName);
|
||||||
}
|
}
|
||||||
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"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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"),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user