Refactor codebase using ConfirmDialog whenever possible
This commit is contained in:
@ -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),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user