Fehlerkorrekturen

This commit is contained in:
Sven committed 2024-02-28 14:46:51 +01:00
1 parent faef9ac5d9
commit 125e6eb03e
16 files changed
+335 -48

No files matched your search

+47 -9
View File
@@ -230,7 +230,7 @@ class _MainPageState extends State<MainPage> {
getDefaultButton(
_loggedOut ? 'Anmelden' : 'Abmelden',
image: Image.asset(_loggedOut ? 'assets/anmelden.png' : 'assets/abmelden.png', width: 30, height: 30),
() async => {_logout()}),
() async => {_logout(context)}),
Expanded(
child: Container(
decoration: BoxDecoration(
@@ -305,20 +305,58 @@ class _MainPageState extends State<MainPage> {
}
}
_logout() {
_logout(context) {
if (!_loggedOut) {
_sendLogoutMessage();
Future.delayed(const Duration(seconds: 1), () async {
MqttCore.instance.diconnect();
});
showLogoutAlertDialog(context);
} else {
MqttCore.setup();
_loggedOut = false;
setState(() {});
}
}
_loggedOut = !_loggedOut;
showLogoutAlertDialog(BuildContext context) {
Widget yesButton = TextButton(
child: const Text("Ja"),
onPressed: () {
Navigator.of(context).pop();
_sendLogoutMessage();
setState(() {});
Future.delayed(const Duration(seconds: 1), () async {
MqttCore.instance.diconnect();
});
_loggedOut = true;
setState(() {});
},
);
Widget noButton = TextButton(
child: const Text("Nein"),
onPressed: () {
Navigator.of(context).pop();
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: const Text("Warnung"),
content: const Text("Wollen Sie sich wirklich abmelden?"),
actions: [
yesButton, noButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
_sendLogoutMessage() {