Refactor codebase using ConfirmDialog whenever possible
This commit is contained in:
parent
f0da6f2596
commit
e26a1e9598
lib/view
pages
settings
@ -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;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../widget/confirmDialog.dart';
|
||||
|
||||
class GradeAverage extends StatefulWidget {
|
||||
const GradeAverage({Key? key}) : super(key: key);
|
||||
|
||||
@ -33,22 +35,18 @@ class _GradeAverageState extends State<GradeAverage> {
|
||||
title: const Text("Notendurschnittsrechner"),
|
||||
actions: [
|
||||
IconButton(onPressed: () {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Zurücksetzen?"),
|
||||
content: const Text("Alle Einträge werden entfernt."),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Abbrechen")),
|
||||
TextButton(onPressed: () {
|
||||
grades.clear();
|
||||
setState(() {});
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Zurücksetzen"))
|
||||
],
|
||||
);
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ConfirmDialog(
|
||||
title: "Zurücksetzen?",
|
||||
content: "Alle Einträge werden entfernt.",
|
||||
confirmButton: "Zurücksetzen",
|
||||
onConfirm: () {
|
||||
grades.clear();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
);
|
||||
}, icon: const Icon(Icons.delete_forever)),
|
||||
PopupMenuButton<bool>(
|
||||
enableFeedback: true,
|
||||
@ -71,21 +69,15 @@ class _GradeAverageState extends State<GradeAverage> {
|
||||
});
|
||||
|
||||
if(grades.isNotEmpty) {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Notensystem wechseln"),
|
||||
content: const Text("Beim wechsel des Notensystems werden alle Einträge zurückgesetzt."),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Abbrechen")),
|
||||
TextButton(onPressed: () {
|
||||
switchSystem();
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Fortfahren")),
|
||||
],
|
||||
);
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ConfirmDialog(
|
||||
title: "Notensystem wechseln",
|
||||
content: "Beim wechsel des Notensystems werden alle Einträge zurückgesetzt.",
|
||||
confirmButton: "Fortfahren",
|
||||
onConfirm: () => switchSystem(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
switchSystem();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../../api/mhsl/message/getMessages/getMessagesResponse.dart';
|
||||
import '../../../../widget/confirmDialog.dart';
|
||||
|
||||
class MessageView extends StatefulWidget {
|
||||
final String basePath;
|
||||
@ -41,20 +42,12 @@ class _MessageViewState extends State<MessageView> {
|
||||
onHyperlinkClicked: (PdfHyperlinkClickedDetails e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Link öffnen"),
|
||||
content: Text("Möchtest du den folgenden Link öffnen?\n${e.uri}"),
|
||||
actions: [
|
||||
TextButton(onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
}, child: const Text("Abbrechen")),
|
||||
TextButton(onPressed: () {
|
||||
launchUrl(Uri.parse(e.uri), mode: LaunchMode.externalApplication);
|
||||
}, child: const Text("Öffnen")),
|
||||
],
|
||||
);
|
||||
},
|
||||
builder: (context) => ConfirmDialog(
|
||||
title: "Link öffnen",
|
||||
content: "Möchtest du den folgenden Link öffnen?\n${e.uri}",
|
||||
confirmButton: "Öffnen",
|
||||
onConfirm: () => launchUrl(Uri.parse(e.uri), mode: LaunchMode.externalApplication),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -7,6 +7,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../model/accountModel.dart';
|
||||
import '../../model/appTheme.dart';
|
||||
import '../../widget/confirmDialog.dart';
|
||||
import 'debug/debugOverview.dart';
|
||||
|
||||
class Settings extends StatefulWidget {
|
||||
@ -41,32 +42,19 @@ class _SettingsState extends State<Settings> {
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Abmelden?"),
|
||||
content: const Text("Möchtest du dich wirklich abmelden?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("Abmelden"),
|
||||
onPressed: () {
|
||||
SharedPreferences.getInstance().then((value) => {
|
||||
value.clear(),
|
||||
}).then((value) => {
|
||||
Provider.of<AccountModel>(context, listen: false).logout(),
|
||||
Navigator.popUntil(context, (route) => !Navigator.canPop(context)),
|
||||
});
|
||||
}
|
||||
),
|
||||
|
||||
TextButton(
|
||||
child: const Text("Abbrechen"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
builder: (context) => ConfirmDialog(
|
||||
title: "Abmelden?",
|
||||
content: "Möchtest du dich wirklich abmelden?",
|
||||
confirmButton: "Abmelden",
|
||||
onConfirm: () {
|
||||
SharedPreferences.getInstance().then((value) => {
|
||||
value.clear(),
|
||||
}).then((value) => {
|
||||
Provider.of<AccountModel>(context, listen: false).logout(),
|
||||
Navigator.popUntil(context, (route) => !Navigator.canPop(context)),
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user