Erweiterungen
This commit is contained in:
1 parent
955d7b3cb4
commit
e9811da904
25 files changed
+1505
-128
No files matched your search
+62
-15
@@ -1,6 +1,7 @@
|
||||
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';
|
||||
|
||||
@@ -10,7 +11,9 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
await showDialog(
|
||||
context: MyApp.appNavigatorKey.currentContext!,
|
||||
builder: (BuildContext context) {
|
||||
late String connectedString = MqttCore.instance.getConnectionStatus() == ConnectionStateEnum.connected ? "Verbunden" : "NICHT verbunden";
|
||||
late String connectedString = MqttCore.instance.getConnectionStatus() == ConnectionStateEnum.connected
|
||||
? 'connected'.tr
|
||||
: 'not_connected'.tr;
|
||||
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
@@ -18,31 +21,42 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
backgroundColor: Colors.white,
|
||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
Future<String> getGpsStatustext() async {
|
||||
String gpsStatus = "nicht verfügbar";
|
||||
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 = "veraltet";
|
||||
gpsStatus = 'gps_outdated'.tr;
|
||||
} else {
|
||||
gpsStatus = "aktuell";
|
||||
gpsStatus = 'gps_available'.tr;
|
||||
}
|
||||
}
|
||||
return gpsStatus;
|
||||
}
|
||||
|
||||
void onLanguageChanged(AppLanguage? newLanguage) {
|
||||
if (newLanguage != null) {
|
||||
AppLocalizations().setLanguage(newLanguage);
|
||||
setState(() {});
|
||||
|
||||
// Sende Nachricht an MainPage, um UI zu aktualisieren
|
||||
// Wir verwenden einen einfachen Ansatz: Die App wird neu geladen
|
||||
// In einer echten App würde man hier einen State-Management-Mechanismus verwenden
|
||||
}
|
||||
}
|
||||
|
||||
return FutureBuilder<String>(
|
||||
future: getGpsStatustext(),
|
||||
builder: (context, snapshot) {
|
||||
String gpsStatus = snapshot.data ?? "wird geladen...";
|
||||
String gpsStatus = snapshot.data ?? 'loading'.tr;
|
||||
|
||||
var text = "Versionsnummer: a$version\n";
|
||||
text += "Verbindungsstatus: $connectedString\n";
|
||||
text += "GPS-Status: $gpsStatus\n";
|
||||
var text = "${'version'.tr}: a$version\n";
|
||||
text += "${'connection_status'.tr}: $connectedString\n";
|
||||
text += "${'gps_status'.tr}: $gpsStatus\n";
|
||||
text += "\n";
|
||||
text += "User Status:\n";
|
||||
text += "${'user_status'.tr}:\n";
|
||||
if (status != null) {
|
||||
text += "cr_id: ${status.crId}\n";
|
||||
text += "cust_id: ${status.custId}\n";
|
||||
@@ -51,12 +65,12 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
text += "server_version: ${status.serverVersion}\n";
|
||||
text += "server_instance: ${status.serverInstance}\n";
|
||||
} else {
|
||||
text += "Keine Informationen gefunden";
|
||||
text += 'no_info_found'.tr;
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
key: GlobalKey(),
|
||||
height: 350,
|
||||
height: 450,
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
child: Container(
|
||||
height: 100,
|
||||
@@ -72,9 +86,44 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: Text(text, textAlign: TextAlign.left)),
|
||||
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',
|
||||
'ok'.tr,
|
||||
() {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
@@ -88,5 +137,3 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user