Fehlerkorrekturen und Erweiterungen
This commit is contained in:
1 parent
a16a8fcf28
commit
1207d9c517
12 files changed
+158
-60
No files matched your search
@@ -257,6 +257,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
_processTaskArrivedOrFinished(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
if (!mounted) return;
|
||||
showTaskArrivedPopup(context, taskInfo, () async {
|
||||
DateFormat dateFormat = DateFormat("dd.MM.yyyy HH:mm");
|
||||
|
||||
@@ -268,7 +269,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
_sendArrivedMessage(taskInfo);
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
});
|
||||
@@ -277,6 +280,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
_processCommissionNumber(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
if (!mounted) return;
|
||||
showComissionNumberPopup(context, taskInfo, (comissionNumber) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.val = comissionNumber;
|
||||
@@ -287,7 +291,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
_commisionNumber = comissionNumber;
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
});
|
||||
@@ -316,6 +322,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
_processTakePhotos(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
if (!mounted) return;
|
||||
showTakePhotosPopup(context, taskInfo, (List<Uint8List>? photos) async {
|
||||
if (photos != null) {
|
||||
await MyApp.isarInstance.writeTxn(() async {
|
||||
@@ -335,7 +342,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
taskInfo.additionalText = "Fotos aufgenommen";
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
}
|
||||
@@ -362,6 +371,7 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
void _processReceiptGiver(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
if (!mounted) return;
|
||||
showReceiptGiverPopup(context, taskInfo, (receiptGiver, selectedTourEntry) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.code = selectedTourEntry.code;
|
||||
@@ -371,7 +381,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
taskInfo.additionalText = receiptGiver;
|
||||
taskInfo.completed = true;
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
});
|
||||
@@ -380,8 +392,10 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
void _processPickupDeliveryStatusTask(TaskInfo taskInfo) {
|
||||
Util.logInfo('Task ${taskInfo.task.sId} called');
|
||||
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
showPickupDeliveryStatusPopup(context, taskInfo, (tourEntry, remark) async {
|
||||
if (!mounted) return;
|
||||
showPickupDeliveryStatusPopup(currentContext, taskInfo, (tourEntry, remark) async {
|
||||
var answer = await _createAnswerHeader(taskInfo);
|
||||
answer.code = tourEntry!.code;
|
||||
answer.val = remark;
|
||||
@@ -392,7 +406,9 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -404,8 +420,10 @@ class _TaskListPageState extends State<TaskListPage> with ProducerMixin {
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
|
||||
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
showSignaturePopup(context, taskInfo, (String? signature) async {
|
||||
if (!mounted) return;
|
||||
showSignaturePopup(currentContext, taskInfo, (String? signature) async {
|
||||
MyApp.suppressAcceptDialog = false;
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
+24
-9
@@ -211,7 +211,7 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
|
||||
final ValueNotifier<bool> _connectionLostValueNotifier = ValueNotifier<bool>(true);
|
||||
|
||||
late AnimationController? _animationController = null;
|
||||
late AnimationController? _animationController;
|
||||
late Animation<double> _animation;
|
||||
|
||||
Timer? _checkForNewState0JobsJobsTimer;
|
||||
@@ -426,20 +426,28 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
}
|
||||
|
||||
void _replaceContentView(ContentViewWidget widget) async {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
contentStack.clear();
|
||||
|
||||
setState(() {
|
||||
_currentContent = widget;
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentContent = widget;
|
||||
});
|
||||
}
|
||||
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(context);
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _popContentView(int count) {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
contentStack.pop();
|
||||
@@ -449,19 +457,26 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
|
||||
_currentContent = previousContentView;
|
||||
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(context);
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _pushContentView(ContentViewWidget widget) {
|
||||
final currentContext = context;
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
contentStack.push(_currentContent);
|
||||
|
||||
_currentContent = widget;
|
||||
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(context);
|
||||
if (mounted) {
|
||||
_currentTitleWidget = await _currentContent.getHeaderWidget(currentContext);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
|
||||
@@ -198,9 +198,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
||||
payload: RemoveJobMessage(id: job.id),
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
setState(() {});
|
||||
});
|
||||
}),
|
||||
),
|
||||
@@ -217,9 +215,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
|
||||
payload: RemoveJobMessage(id: job.id),
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
setState(() {});
|
||||
});
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -6,10 +6,16 @@ showTaskArrivedPopup(BuildContext context, TaskInfo taskInfo, Function() onFinis
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
}, // False will prevent and true will allow to dismiss
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
|
||||
@@ -7,9 +7,15 @@ showComissionNumberPopup(BuildContext context, TaskInfo taskInfo, Function(Strin
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
@@ -18,10 +18,16 @@ showPickupDeliveryStatusPopup(BuildContext context, TaskInfo taskInfo, Function(
|
||||
TextEditingController controller = TextEditingController();
|
||||
TextEditingController remController = TextEditingController();
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
},
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
|
||||
@@ -17,11 +17,17 @@ showReceiptGiverPopup(BuildContext context, TaskInfo taskInfo, Function(String,
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
},
|
||||
child: AlertDialog(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
@@ -8,15 +8,18 @@ showSignaturePopup(BuildContext context, TaskInfo taskInfo, Function(String?) on
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
var result = await taskDialogSecurityException(context);
|
||||
|
||||
if (result) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
@@ -7,11 +7,17 @@ showStationNoticePopup(BuildContext context, TaskInfo taskInfo, Function(String)
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
},
|
||||
child: AlertDialog(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
@@ -16,10 +16,16 @@ Future<void> showTakePhotosPopup(BuildContext context, TaskInfo taskInfo, Functi
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
},
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
|
||||
@@ -5,11 +5,17 @@ showZipPopup(BuildContext context, String text, String buttonText, Function(Stri
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await taskDialogSecurityException(context);
|
||||
},
|
||||
child: AlertDialog(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (bool didPop) async {
|
||||
if (!didPop) {
|
||||
final shouldPop = await taskDialogSecurityException(context);
|
||||
if (shouldPop && context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shadowColor: Colors.transparent,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:archive/archive.dart';
|
||||
@@ -274,6 +275,10 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
_messageAcknowledgeReceived(jsonDecode(payloadString));
|
||||
break;
|
||||
|
||||
case "command/logout":
|
||||
_commandLogoutReceived(jsonDecode(payloadString));
|
||||
break;
|
||||
|
||||
default:
|
||||
Util.logInfo('Unknown topic: $topic');
|
||||
break;
|
||||
@@ -724,6 +729,25 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
);
|
||||
}
|
||||
|
||||
void _commandLogoutReceived(Map<String, dynamic> payload) {
|
||||
try {
|
||||
String timestamp = payload['timestamp'] ?? 'Unknown timestamp';
|
||||
Util.logInfo('Command logout received with timestamp: $timestamp');
|
||||
|
||||
// Disconnect MQTT client gracefully
|
||||
_disconnectMqttClient();
|
||||
|
||||
// Exit the application reliably
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
exit(0);
|
||||
});
|
||||
} catch (ex) {
|
||||
Util.logException('Error processing logout command: ${ex.toString()}');
|
||||
// Force exit even if there's an error
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
String _encapsulateMessage(String messageId, bool requiresAck, Map<String, dynamic> message) {
|
||||
var messageHeader = MessageHeader();
|
||||
messageHeader.messageId = messageId;
|
||||
|
||||
Reference in new issue
Block a user