Refactoring

This commit is contained in:
Sven committed 2024-04-30 14:47:13 +02:00
1 parent f8100facf3
commit 91d50fe58c
11 files changed
+198 -107

No files matched your search

+44 -15
View File
@@ -1,28 +1,57 @@
import 'package:flutter/material.dart';
import 'package:stadtbote/main.dart';
import 'package:stadtbote/model/session_status.dart';
import 'package:stadtbote/tools/constants.dart';
import 'package:stadtbote/tools/message_service.dart';
import 'package:stadtbote/tools/mqtt_core.dart';
import 'package:stadtbote/tools/util.dart';
void showInfosPopup(BuildContext context, SessionStatus? status) async {
var version = await Util.getAppVersion();
final int version = await Util.getAppVersion();
var text = "Versionsnummer: a$version\n";
text += "Verbindungsstatus: ${MqttCore.instance.connectionState == ConnectionStateEnum.connected ? "Verbunden" : "NICHT verbunden"}\n";
text += "GPS-Status: ${MyApp.currentPosition != null ? MyApp.currentPosition!.timestamp.toString() : "Unbekannt"}\n";
text += "\n";
text += "User Status:\n";
if (status != null) {
text += "cr_id: ${status.crId}\n";
text += "cust_id: ${status.custId}\n";
text += "sid: ${status.sid}\n";
text += "vht_id: ${status.vhtId}\n";
text += "server_version: ${status.serverVersion}\n";
text += "server_instance: ${status.serverInstance}\n";
} else {
text += "Keine Informationen gefunden";
late String connectedString = "Bitte warten...";
Future.delayed(const Duration(seconds: 2), () async {
MessageService().publish<RequestConnectionStatusMessage>(Constants.messageTopicRequestConnectionStatus, arguments: RequestConnectionStatusMessage());
});
void unsubscribeMessages() {
MessageService().unsubscribe(Constants.messageTopicCurrentConnectionStatus, version);
MessageService().unsubscribe(Constants.messageTopicConnectionStatusChanged, version);
}
await showDialog(
// ignore: use_build_context_synchronously
context: context,
builder: (BuildContext context) {
// ignore: deprecated_member_use
return WillPopScope(
onWillPop: () async {
unsubscribeMessages();
return true;
},
child: AlertDialog(
contentPadding: EdgeInsets.zero,
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
var text = "Versionsnummer: a$version\n";
text += "Verbindungsstatus: $connectedString\n";
text += "GPS-Status: ${MyApp.currentPosition != null ? MyApp.currentPosition!.timestamp.toString() : "Unbekannt"}\n";
text += "\n";
text += "User Status:\n";
if (status != null) {
text += "cr_id: ${status.crId}\n";
text += "cust_id: ${status.custId}\n";
text += "sid: ${status.sid}\n";
text += "vht_id: ${status.vhtId}\n";
text += "server_version: ${status.serverVersion}\n";
text += "server_instance: ${status.serverInstance}\n";
} else {
text += "Keine Informationen gefunden";
}
await showDialog(
context: context,
builder: (BuildContext context) {