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