import 'package:flutter/material.dart'; import 'package:stadtbote/main.dart'; import 'package:stadtbote/model/session_status.dart'; import 'package:stadtbote/tools/util.dart'; void showInfosPopup(SessionStatus? status) async { final int version = await Util.getAppVersion(); late String connectedString = "Bitte warten..."; Future.delayed(const Duration(seconds: 2), () async { //await MessageService().publish(Constants.messageTopicRequestConnectionStatus, arguments: RequestConnectionStatusMessage()); }); void unsubscribeMessages() { //MessageService().unsubscribe(Constants.messageTopicCurrentConnectionStatus, version); //MessageService().unsubscribe(Constants.messageTopicConnectionStatusChanged, version); } await showDialog( // ignore: use_build_context_synchronously context: MyApp.appNavigatorKey.currentContext!, 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) { String getGpsStatustext() { String gpsStatus = "nicht verfügbar"; if (MyApp.currentPosition != null) { var nowUtc = DateTime.now().toUtc(); var minutesDelta = nowUtc.difference(MyApp.currentPosition!.timestamp); if (minutesDelta >= const Duration(minutes: 15)) { 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 { text += "Keine Informationen gefunden"; } /*MessageService().subscribe(Constants.messageTopicCurrentConnectionStatus, version, (CurrentConnectionStatusMessage currentConnectionStatusMessage) async { connectedString = currentConnectionStatusMessage.state ? "Verbunden" : "NICHT verbunden"; if (context.mounted) setState(() {}); }); MessageService().subscribe(Constants.messageTopicConnectionStatusChanged, version, (ConnectionStatus connectionStatus) async { connectedString = connectionStatus.status == ConnectionStatusEnum.connected ? "Verbunden" : "NICHT verbunden"; if (context.mounted) setState(() {}); });*/ return SizedBox( key: GlobalKey(), height: 350, width: MediaQuery.of(context).size.width * 0.8, child: Container( height: 100, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border.all( color: Colors.grey, width: 1, ), ), child: Padding( padding: const EdgeInsets.all(12.0), child: Column( children: [ Expanded(child: Text(text, textAlign: TextAlign.left)), getDefaultButton( 'OK', () { unsubscribeMessages(); Navigator.pop(context); }, ), ], ), ), )); }))); }); }