Fehlerkorrekturen
This commit is contained in:
1 parent
38f5d374b2
commit
584f7dc8f7
2 files changed
+70
-94
No files matched your search
+62
-94
@@ -1,115 +1,83 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stadtbote/main.dart';
|
import 'package:stadtbote/main.dart';
|
||||||
import 'package:stadtbote/model/session_status.dart';
|
import 'package:stadtbote/model/session_status.dart';
|
||||||
|
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||||
import 'package:stadtbote/tools/util.dart';
|
import 'package:stadtbote/tools/util.dart';
|
||||||
|
|
||||||
void showInfosPopup(SessionStatus? status) async {
|
void showInfosPopup(SessionStatus? status) async {
|
||||||
final int version = await Util.getAppVersion();
|
final int version = await Util.getAppVersion();
|
||||||
|
|
||||||
late String connectedString = "Bitte warten...";
|
|
||||||
|
|
||||||
Future.delayed(const Duration(seconds: 2), () async {
|
|
||||||
//await MessageService().publish<RequestConnectionStatusMessage>(Constants.messageTopicRequestConnectionStatus, arguments: RequestConnectionStatusMessage());
|
|
||||||
});
|
|
||||||
|
|
||||||
void unsubscribeMessages() {
|
|
||||||
//MessageService().unsubscribe(Constants.messageTopicCurrentConnectionStatus, version);
|
|
||||||
//MessageService().unsubscribe(Constants.messageTopicConnectionStatusChanged, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
await showDialog(
|
await showDialog(
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
context: MyApp.appNavigatorKey.currentContext!,
|
context: MyApp.appNavigatorKey.currentContext!,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
// ignore: deprecated_member_use
|
late String connectedString = MqttCore.instance.getConnectionStatus() == ConnectionStateEnum.connected ? "Verbunden" : "NICHT verbunden";
|
||||||
return WillPopScope(
|
|
||||||
onWillPop: () async {
|
|
||||||
unsubscribeMessages();
|
|
||||||
|
|
||||||
return true;
|
return AlertDialog(
|
||||||
},
|
contentPadding: EdgeInsets.zero,
|
||||||
child: AlertDialog(
|
shadowColor: Colors.transparent,
|
||||||
contentPadding: EdgeInsets.zero,
|
backgroundColor: Colors.white,
|
||||||
shadowColor: Colors.transparent,
|
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||||
backgroundColor: Colors.white,
|
String getGpsStatustext() {
|
||||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
String gpsStatus = "nicht verfügbar";
|
||||||
String getGpsStatustext() {
|
if (MyApp.currentPosition != null) {
|
||||||
String gpsStatus = "nicht verfügbar";
|
var nowUtc = DateTime.now().toUtc();
|
||||||
if (MyApp.currentPosition != null) {
|
var minutesDelta = nowUtc.difference(MyApp.currentPosition!.timestamp);
|
||||||
var nowUtc = DateTime.now().toUtc();
|
|
||||||
var minutesDelta = nowUtc.difference(MyApp.currentPosition!.timestamp);
|
|
||||||
|
|
||||||
if (minutesDelta >= const Duration(minutes: 15)) {
|
if (minutesDelta >= const Duration(minutes: 15)) {
|
||||||
gpsStatus = "veraltet";
|
gpsStatus = "veraltet";
|
||||||
} else {
|
|
||||||
gpsStatus = "aktuell";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gpsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
var text = "Versionsnummer: a$version\n";
|
|
||||||
text += "Verbindungsstatus: $connectedString\n";
|
|
||||||
text += "GPS-Status: ${getGpsStatustext()}\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 {
|
} else {
|
||||||
text += "Keine Informationen gefunden";
|
gpsStatus = "aktuell";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return gpsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
/*MessageService().subscribe<CurrentConnectionStatusMessage>(Constants.messageTopicCurrentConnectionStatus, version,
|
var text = "Versionsnummer: a$version\n";
|
||||||
(CurrentConnectionStatusMessage currentConnectionStatusMessage) async {
|
text += "Verbindungsstatus: $connectedString\n";
|
||||||
connectedString = currentConnectionStatusMessage.state ? "Verbunden" : "NICHT verbunden";
|
text += "GPS-Status: ${getGpsStatustext()}\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";
|
||||||
|
}
|
||||||
|
|
||||||
if (context.mounted) setState(() {});
|
return SizedBox(
|
||||||
});
|
key: GlobalKey(),
|
||||||
|
height: 350,
|
||||||
MessageService().subscribe<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, version,
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
(ConnectionStatus connectionStatus) async {
|
child: Container(
|
||||||
connectedString = connectionStatus.status == ConnectionStatusEnum.connected ? "Verbunden" : "NICHT verbunden";
|
height: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
if (context.mounted) setState(() {});
|
borderRadius: BorderRadius.circular(10),
|
||||||
});*/
|
color: Colors.white,
|
||||||
|
border: Border.all(
|
||||||
return SizedBox(
|
color: Colors.grey,
|
||||||
key: GlobalKey(),
|
width: 1,
|
||||||
height: 350,
|
),
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
),
|
||||||
child: Container(
|
child: Padding(
|
||||||
height: 100,
|
padding: const EdgeInsets.all(12.0),
|
||||||
decoration: BoxDecoration(
|
child: Column(
|
||||||
borderRadius: BorderRadius.circular(10),
|
children: [
|
||||||
color: Colors.white,
|
Expanded(child: Text(text, textAlign: TextAlign.left)),
|
||||||
border: Border.all(
|
getDefaultButton(
|
||||||
color: Colors.grey,
|
'OK',
|
||||||
width: 1,
|
() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
child: Padding(
|
),
|
||||||
padding: const EdgeInsets.all(12.0),
|
),
|
||||||
child: Column(
|
));
|
||||||
children: [
|
}));
|
||||||
Expanded(child: Text(text, textAlign: TextAlign.left)),
|
|
||||||
getDefaultButton(
|
|
||||||
'OK',
|
|
||||||
() {
|
|
||||||
unsubscribeMessages();
|
|
||||||
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
})));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ import 'util.dart';
|
|||||||
enum ConnectionStateEnum { notConnected, connected }
|
enum ConnectionStateEnum { notConnected, connected }
|
||||||
|
|
||||||
class MqttCore with ProducerMixin, ConsumerMixin {
|
class MqttCore with ProducerMixin, ConsumerMixin {
|
||||||
|
static late MqttCore instance;
|
||||||
|
|
||||||
late ConnectionStateEnum connectionState = ConnectionStateEnum.notConnected;
|
late ConnectionStateEnum connectionState = ConnectionStateEnum.notConnected;
|
||||||
|
|
||||||
late bool _disconnectInProgress = false;
|
late bool _disconnectInProgress = false;
|
||||||
@@ -69,6 +71,8 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
|||||||
Timer? _trackTimer;
|
Timer? _trackTimer;
|
||||||
|
|
||||||
MqttCore() {
|
MqttCore() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
initMessages();
|
initMessages();
|
||||||
|
|
||||||
_disconnectInProgress = false;
|
_disconnectInProgress = false;
|
||||||
@@ -76,6 +80,10 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
|||||||
_processBootstrap();
|
_processBootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConnectionStateEnum getConnectionStatus() {
|
||||||
|
return connectionState;
|
||||||
|
}
|
||||||
|
|
||||||
_disconnectMqttClient() async {
|
_disconnectMqttClient() async {
|
||||||
// TODO MESSAGING
|
// TODO MESSAGING
|
||||||
sendMessage(
|
sendMessage(
|
||||||
|
|||||||
Reference in new issue
Block a user