Erweiterungen

This commit is contained in:
Sven committed 2024-11-14 10:56:36 +01:00
1 parent 96544ca924
commit def0f3fc2f
136 files changed
+4172 -499

No files matched your search

+23 -19
View File
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:math';
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
@@ -21,12 +20,10 @@ import '../tools/messages/publish_payload_message.dart';
late bool _initTimer;
late Timer _checkForNewJobsTimer;
late Map<int, DateTime> _firstDelayTimeMap;
late Map<int, bool> _infoExpandedMap;
Future<void> showAcceptJobsPopup(SharedMapReference mapReference, Function() onFinished) async {
_initTimer = true;
_firstDelayTimeMap = {};
_infoExpandedMap = {};
await showDialog<void>(
@@ -97,7 +94,6 @@ void _stopTimer() {
_checkForNewJobsTimer.cancel();
}
Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFinished, SharedMapReference mapReference) async {
List<Widget> widgets = [];
@@ -107,15 +103,6 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
for (var jobEntry in entries) {
var job = jobEntry.value;
int enableDelay = job.delayOrderTime;
if (!_firstDelayTimeMap.containsKey(job.id)) {
_firstDelayTimeMap[job.id] = DateTime.now();
} else {
DateTime firstDisplayTime = _firstDelayTimeMap[job.id]!;
int diffInSeconds = DateTime.now().difference(firstDisplayTime).inSeconds;
enableDelay = min(0, diffInSeconds);
}
ExpandableController controller = ExpandableController();
controller.expanded = _infoExpandedMap[job.id] != null ? _infoExpandedMap[job.id]! : false;
@@ -165,7 +152,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
child: Text(
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
textAlign: TextAlign.left,
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.transparent),
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.red : Colors.transparent),
),
),
SizedBox(width: double.infinity, child: Text('Auftragsnummer: ${job.id}', textAlign: TextAlign.left)),
@@ -231,7 +218,10 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
jobMap.remove(job.id);
MessageService().publish<RemoveJobMessage>(Constants.messageTopicRemoveJob, arguments: RemoveJobMessage(id: job.id));
job.sendMessage(
routingKey: Constants.messageTopicRemoveJob,
payload: RemoveJobMessage(id: job.id),
);
setState(() {});
@@ -245,7 +235,7 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
),
const SizedBox(width: 20),
Expanded(
child: getDefaultButton('Annehmen', enabledTimerActive: enableDelay > 0, enabledTimerDelay: enableDelay, () {
child: getDefaultButton('Annehmen', enabledTimerActive: false, () {
dialogState(() {
if (jobMap.length() == 1) {
_stopTimer();
@@ -255,7 +245,10 @@ Future<List<Widget>> _fetchJobWidgets(StateSetter dialogState, Function() onFini
jobMap.remove(job.id);
MessageService().publish<RemoveJobMessage>(Constants.messageTopicRemoveJob, arguments: RemoveJobMessage(id: job.id));
job.sendMessage(
routingKey: Constants.messageTopicRemoveJob,
payload: RemoveJobMessage(id: job.id),
);
setState(() {});
@@ -295,8 +288,19 @@ _sendAnswer(SharedMapReference mapReference, Job job, int item) async {
message.track.pos!.long = currentPosition != null ? currentPosition.longitude : 0.0;
message.track.pos!.acc = currentPosition != null ? currentPosition.accuracy.toInt() : 0;
await MessageService().publish<PublishPayloadMessage>(Constants.messageTopicPublishPayload, arguments: PublishPayloadMessage(topic: "reaction", message: message.toJson(), qos: MqttQos.exactlyOnce));
// TODO MESSAGING
job.sendMessage(
routingKey: Constants.messageTopicPublishPayload,
payload: PublishPayloadMessage(topic: "reaction", message: message.toJson(), qos: MqttQos.exactlyOnce),
);
await MessageService().publish(Constants.messageTopicUpdateBadges, arguments: RefreshBadgesMessage());
//await MessageService().publish<PublishPayloadMessage>(Constants.messageTopicPublishPayload, arguments: PublishPayloadMessage(topic: "reaction", message: message.toJson(), qos: MqttQos.exactlyOnce));
// TODO MESSAGING
job.sendMessage(
routingKey: Constants.messageTopicUpdateBadges,
payload: RefreshBadgesMessage(),
);
//await MessageService().publish(Constants.messageTopicUpdateBadges, arguments: RefreshBadgesMessage());
}