Fehlerkorrekturen und Erweiterungen
This commit is contained in:
1 parent
265d75a99b
commit
47b4c85133
14 files changed
+155
-125
No files matched your search
@@ -178,7 +178,7 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> with ProducerMixin,
|
||||
}
|
||||
|
||||
_sendZip(Rank rank, String zip) async {
|
||||
var position = MyApp.currentPosition;
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
|
||||
var setPosMessage = ZipSetPos();
|
||||
setPosMessage.zip = zip;
|
||||
|
||||
@@ -216,7 +216,7 @@ class _AssignedJobsPageState extends State<AssignedJobsPage> with ProducerMixin,
|
||||
}
|
||||
|
||||
_sendAnswer(Job job, int item) async {
|
||||
var currentPosition = MyApp.currentPosition;
|
||||
var currentPosition = await MyApp.getCurrentPosition();
|
||||
|
||||
var message = Reaction();
|
||||
message.id = job.id;
|
||||
|
||||
@@ -401,7 +401,7 @@ class _MainPageState extends State<MainPage> with ConsumerMixin, ProducerMixin {
|
||||
}
|
||||
|
||||
_sendLogoutMessage() async {
|
||||
var position = MyApp.currentPosition;
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
|
||||
var logoutMessage = LogoutMessage();
|
||||
if (position != null) {
|
||||
|
||||
@@ -255,10 +255,10 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
_processTaskArrivedOrFinished(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
showTaskArrivedPopup(context, taskInfo, () {
|
||||
showTaskArrivedPopup(context, taskInfo, () async {
|
||||
DateFormat dateFormat = DateFormat("dd.MM.yyyy HH:mm");
|
||||
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
taskInfo.additionalText = dateFormat.format(DateTime.now());
|
||||
@@ -275,8 +275,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
_processCommissionNumber(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
showComissionNumberPopup(context, taskInfo, (comissionNumber) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
showComissionNumberPopup(context, taskInfo, (comissionNumber) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.val = comissionNumber;
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
@@ -294,8 +294,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
/*_processScanBarcodes(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
showScanBarcodesPopup(context, taskInfo, (List<String> barcodes) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
showScanBarcodesPopup(context, taskInfo, (List<String> barcodes) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.codes = [];
|
||||
for(var barcode in barcodes) {
|
||||
answer.codes!.add(barcode);
|
||||
@@ -343,8 +343,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
void _processStationNotice(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
showStationNoticePopup(context, taskInfo, (notice) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
showStationNoticePopup(context, taskInfo, (notice) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.val = notice;
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
@@ -360,8 +360,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
void _processReceiptGiver(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
showReceiptGiverPopup(context, taskInfo, (receiptGiver, selectedTourEntry) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
showReceiptGiverPopup(context, taskInfo, (receiptGiver, selectedTourEntry) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.code = selectedTourEntry.code;
|
||||
answer.val = receiptGiver;
|
||||
|
||||
@@ -379,8 +379,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
showPickupDeliveryStatusPopup(context, taskInfo, (tourEntry, remark) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
showPickupDeliveryStatusPopup(context, taskInfo, (tourEntry, remark) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.code = tourEntry!.code;
|
||||
answer.val = remark;
|
||||
|
||||
@@ -409,7 +409,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
if (signature != null) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.sign = signature;
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
@@ -465,7 +465,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
message.task.sId = taskInfo.task.sId;
|
||||
message.task.time = DateTime.now().toIso8601String();
|
||||
|
||||
var position = MyApp.currentPosition;
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
if (position != null) {
|
||||
message.task.pos = FinTaskPos();
|
||||
message.task.pos!.lat = position.latitude;
|
||||
@@ -480,8 +480,8 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
);
|
||||
}
|
||||
|
||||
FinTourTask _createAnswerHeader(TaskInfo taskInfo) {
|
||||
var position = MyApp.currentPosition;
|
||||
Future<FinTourTask> _createAnswerHeader(TaskInfo taskInfo) async {
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
|
||||
var finTourTask = FinTourTask();
|
||||
finTourTask.sId = taskInfo.task.sId;
|
||||
@@ -503,7 +503,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
finTourMessage.trId = widget.tour.id;
|
||||
finTourMessage.com = _commisionNumber;
|
||||
|
||||
var position = MyApp.currentPosition;
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
if (position != null) {
|
||||
finTourMessage.track = Track();
|
||||
finTourMessage.track!.time = DateTime.now().toIso8601String();
|
||||
|
||||
+19
-3
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dart_mq/dart_mq.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
@@ -100,10 +101,25 @@ class MyApp extends StatefulWidget {
|
||||
|
||||
static late Isar isarInstance;
|
||||
|
||||
static Position? currentPosition;
|
||||
static Position? _currentPosition;
|
||||
static final Lock _positionLock = Lock();
|
||||
|
||||
static bool suppressAcceptDialog = false;
|
||||
|
||||
/// Thread-safe getter for current position
|
||||
static Future<Position?> getCurrentPosition() async {
|
||||
return await _positionLock.synchronized(() {
|
||||
return _currentPosition;
|
||||
});
|
||||
}
|
||||
|
||||
/// Thread-safe setter for current position
|
||||
static Future<void> setCurrentPosition(Position? position) async {
|
||||
await _positionLock.synchronized(() {
|
||||
_currentPosition = position;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
@@ -138,8 +154,8 @@ class _MyAppState extends State<MyApp> with ConsumerMixin {
|
||||
distanceFilter: 0,
|
||||
);
|
||||
|
||||
Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position? position) {
|
||||
MyApp.currentPosition = position;
|
||||
Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position? position) async {
|
||||
await MyApp.setCurrentPosition(position);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
||||
}
|
||||
|
||||
_sendAnswer(SharedMapReference mapReference, Job job, int item) async {
|
||||
var currentPosition = MyApp.currentPosition;
|
||||
var currentPosition = await MyApp.getCurrentPosition();
|
||||
|
||||
var message = Reaction();
|
||||
message.id = job.id;
|
||||
|
||||
+54
-46
@@ -17,11 +17,12 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
content: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
String getGpsStatustext() {
|
||||
Future<String> getGpsStatustext() async {
|
||||
String gpsStatus = "nicht verfügbar";
|
||||
if (MyApp.currentPosition != null) {
|
||||
var currentPosition = await MyApp.getCurrentPosition();
|
||||
if (currentPosition != null) {
|
||||
var nowUtc = DateTime.now().toUtc();
|
||||
var minutesDelta = nowUtc.difference(MyApp.currentPosition!.timestamp);
|
||||
var minutesDelta = nowUtc.difference(currentPosition.timestamp);
|
||||
|
||||
if (minutesDelta >= const Duration(minutes: 15)) {
|
||||
gpsStatus = "veraltet";
|
||||
@@ -32,51 +33,58 @@ void showInfosPopup(SessionStatus? status) async {
|
||||
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";
|
||||
}
|
||||
return FutureBuilder<String>(
|
||||
future: getGpsStatustext(),
|
||||
builder: (context, snapshot) {
|
||||
String gpsStatus = snapshot.data ?? "wird geladen...";
|
||||
|
||||
var text = "Versionsnummer: a$version\n";
|
||||
text += "Verbindungsstatus: $connectedString\n";
|
||||
text += "GPS-Status: $gpsStatus\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";
|
||||
}
|
||||
|
||||
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',
|
||||
() {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
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',
|
||||
() {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
},
|
||||
);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
}
|
||||
|
||||
_sendSyncMessage() async {
|
||||
var currentPosition = MyApp.currentPosition;
|
||||
var currentPosition = await MyApp.getCurrentPosition();
|
||||
|
||||
var jobs = await MyApp.isarInstance.jobs.filter().stateGreaterThan(-1).findAll();
|
||||
|
||||
@@ -617,9 +617,11 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
}
|
||||
|
||||
void _startTrackTimer() {
|
||||
_trackTimer ??= Timer.periodic(const Duration(seconds: 120), (Timer t) {
|
||||
_cancelTrackTimer();
|
||||
|
||||
_trackTimer ??= Timer.periodic(const Duration(seconds: 120), (Timer t) async {
|
||||
try {
|
||||
var position = MyApp.currentPosition;
|
||||
var position = await MyApp.getCurrentPosition();
|
||||
if (position != null) {
|
||||
var trackMessage = TrackPosition();
|
||||
trackMessage.time = position.timestamp.toIso8601String();
|
||||
@@ -636,8 +638,11 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
}
|
||||
|
||||
void _cancelTrackTimer() {
|
||||
if (_trackTimer != null && _trackTimer!.isActive) {
|
||||
_trackTimer!.cancel();
|
||||
if (_trackTimer != null) {
|
||||
if (_trackTimer!.isActive) {
|
||||
_trackTimer!.cancel();
|
||||
}
|
||||
|
||||
_trackTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user