137 lines
6.3 KiB
Dart
137 lines
6.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:stadtbote/main.dart';
|
|
import 'package:stadtbote/model/session_status.dart';
|
|
import 'package:stadtbote/tools/app_localizations.dart';
|
|
import 'package:stadtbote/tools/mqtt_core.dart';
|
|
import 'package:stadtbote/tools/util.dart';
|
|
|
|
void showInfosPopup(SessionStatus? status) async {
|
|
final int version = await Util.getAppVersion();
|
|
|
|
await showDialog(
|
|
context: MyApp.appNavigatorKey.currentContext!,
|
|
builder: (BuildContext context) {
|
|
late String connectedString = MqttCore.instance.getConnectionStatus() == ConnectionStateEnum.connected
|
|
? 'connected'.tr
|
|
: 'not_connected'.tr;
|
|
|
|
return AlertDialog(
|
|
contentPadding: EdgeInsets.zero,
|
|
shadowColor: Colors.transparent,
|
|
backgroundColor: Colors.white,
|
|
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
|
Future<String> getGpsStatustext() async {
|
|
String gpsStatus = 'gps_not_available'.tr;
|
|
var currentPosition = await MyApp.getCurrentPosition();
|
|
if (currentPosition != null) {
|
|
var nowUtc = DateTime.now().toUtc();
|
|
var minutesDelta = nowUtc.difference(currentPosition.timestamp);
|
|
|
|
if (minutesDelta >= const Duration(minutes: 15)) {
|
|
gpsStatus = 'gps_outdated'.tr;
|
|
} else {
|
|
gpsStatus = 'gps_available'.tr;
|
|
}
|
|
}
|
|
return gpsStatus;
|
|
}
|
|
|
|
void onLanguageChanged(AppLanguage? newLanguage) {
|
|
if (newLanguage != null && newLanguage != AppLocalizations().currentLanguage) {
|
|
AppLocalizations().setLanguage(newLanguage);
|
|
setState(() {});
|
|
// Der ValueNotifier in AppLocalizations signalisiert die Änderung automatisch
|
|
}
|
|
}
|
|
|
|
return FutureBuilder<String>(
|
|
future: getGpsStatustext(),
|
|
builder: (context, snapshot) {
|
|
String gpsStatus = snapshot.data ?? 'loading'.tr;
|
|
|
|
var text = "${'version'.tr}: a$version\n";
|
|
text += "${'connection_status'.tr}: $connectedString\n";
|
|
text += "${'gps_status'.tr}: $gpsStatus\n";
|
|
text += "\n";
|
|
text += "${'user_status'.tr}:\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 += 'no_info_found'.tr;
|
|
}
|
|
|
|
return SizedBox(
|
|
key: GlobalKey(),
|
|
height: 450,
|
|
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: SingleChildScrollView(child: Text(text, textAlign: TextAlign.left))),
|
|
const Divider(),
|
|
// Sprachauswahl
|
|
Row(
|
|
children: [
|
|
Text('${'language'.tr}: ', style: const TextStyle(fontWeight: FontWeight.bold)),
|
|
Expanded(
|
|
child: DropdownButtonHideUnderline(
|
|
child: DropdownButton<AppLanguage>(
|
|
isExpanded: true,
|
|
value: AppLocalizations().currentLanguage,
|
|
items: AppLanguage.values.map((AppLanguage language) {
|
|
return DropdownMenuItem<AppLanguage>(
|
|
value: language,
|
|
child: Row(
|
|
children: [
|
|
Text(language.flag, style: const TextStyle(fontSize: 20)),
|
|
const SizedBox(width: 8),
|
|
Flexible(
|
|
child: Text(
|
|
language.name,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontSize: 14),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
onChanged: onLanguageChanged,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 12),
|
|
getDefaultButton(
|
|
'ok'.tr,
|
|
() {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
},
|
|
);
|
|
}));
|
|
});
|
|
}
|