Refactor codebase using ConfirmDialog whenever possible

This commit is contained in:
2023-06-03 11:59:09 +02:00
parent f0da6f2596
commit e26a1e9598
4 changed files with 63 additions and 93 deletions

View File

@ -96,28 +96,25 @@ class _FileElementState extends State<FileElement> {
));
} else {
if(widget.file.currentlyDownloading) {
showDialog(context: context, builder: (context) {
return AlertDialog(
title: const Text("Download abbrechen?"),
content: const Text("Möchtest du den Download abbrechen?"),
actions: [
TextButton(onPressed: () {
Navigator.of(context).pop();
}, child: const Text("Nein")),
TextButton(onPressed: () {
downloadCore?.then((value) {
if(!value.isCancelled) value.cancel();
Navigator.of(context).pop();
});
setState(() {
widget.file.currentlyDownloading = false;
percent = 0;
downloadCore = null;
});
}, child: const Text("Ja, Abbrechen"))
],
);
});
showDialog(
context: context,
builder: (context) => ConfirmDialog(
title: "Download abbrechen?",
content: "Möchtest du den Download abbrechen?",
cancelButton: "Nein",
confirmButton: "Ja, Abbrechen",
onConfirm: () {
downloadCore?.then((value) {
if(!value.isCancelled) value.cancel();
});
setState(() {
widget.file.currentlyDownloading = false;
percent = 0;
downloadCore = null;
});
},
),
);
return;
}