Fehlerkorrekturen
This commit is contained in:
1 parent
faef9ac5d9
commit
125e6eb03e
16 files changed
+335
-48
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -20,6 +21,7 @@ import 'package:stadtbote/popups/tasks_popups/take_photos_popup.dart';
|
||||
import 'package:stadtbote/protocoll_messages/accept_job_message.dart';
|
||||
import 'package:stadtbote/protocoll_messages/fin_task_message.dart';
|
||||
import 'package:stadtbote/protocoll_messages/fin_tour_message.dart';
|
||||
import 'package:stadtbote/protocoll_messages/pic_message.dart';
|
||||
import 'package:stadtbote/tools/constants.dart';
|
||||
import 'package:stadtbote/tools/message_service.dart';
|
||||
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||
@@ -64,6 +66,8 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
|
||||
late List<TaskInfo> _taskList;
|
||||
|
||||
List<Uint8List> _photos = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Future.delayed(const Duration(seconds: 0), () async {
|
||||
@@ -282,6 +286,7 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
answer.codes!.add(barcode);
|
||||
}
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
taskInfo.additionalText = "Barcodes gescannt";
|
||||
taskInfo.completed = true;
|
||||
|
||||
@@ -292,13 +297,17 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
}
|
||||
|
||||
_processTakePhotos(TaskInfo taskInfo) {
|
||||
showTakePhotosPopup(context, taskInfo, () {
|
||||
taskInfo.additionalText = "Fotos aufgenommen";
|
||||
taskInfo.completed = true;
|
||||
showTakePhotosPopup(context, taskInfo, (List<Uint8List>? photos) {
|
||||
if (photos != null) {
|
||||
_photos = photos;
|
||||
|
||||
setState(() {});
|
||||
taskInfo.additionalText = "Fotos aufgenommen";
|
||||
taskInfo.completed = true;
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
setState(() {});
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -349,23 +358,29 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
}
|
||||
|
||||
void _processSignature(TaskInfo taskInfo) {
|
||||
MyApp.suppressAcceptDialog = true;
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
|
||||
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
showSignaturePopup(context, taskInfo, () {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
answer.sign = 'A110';
|
||||
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
taskInfo.completed = true;
|
||||
showSignaturePopup(context, taskInfo, (String? signature) {
|
||||
MyApp.suppressAcceptDialog = false;
|
||||
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
_sendFinTourMessage();
|
||||
if (signature != null) {
|
||||
var answer = _createAnswerHeader(taskInfo);
|
||||
answer.sign = signature;
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
taskInfo.answer = jsonEncode(answer.toJson());
|
||||
taskInfo.completed = true;
|
||||
|
||||
MessageService().publish<PopContentViewMessage>(Constants.messageTopicPopContentView, arguments: PopContentViewMessage(count: 2));
|
||||
_sendFinTourMessage();
|
||||
|
||||
_finishTaskProcessing(taskInfo);
|
||||
|
||||
MessageService().publish<PopContentViewMessage>(Constants.messageTopicPopContentView, arguments: PopContentViewMessage(count: 2));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -457,5 +472,84 @@ class _TaskListPageState extends State<TaskListPage> {
|
||||
await MyApp.isarInstance.writeTxn(() async {
|
||||
await MyApp.isarInstance.jobs.put(widget.job);
|
||||
});
|
||||
|
||||
_sendImages();
|
||||
}
|
||||
|
||||
_sendImages() {
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
if (_photos.isNotEmpty) {
|
||||
int photoIndex = 0;
|
||||
|
||||
for (var photoData in _photos) {
|
||||
var message = PicMessage();
|
||||
message.pic = PicData();
|
||||
message.pic.trId = widget.tour.id;
|
||||
message.pic.num = photoIndex;
|
||||
message.pic.time = DateTime.now().millisecondsSinceEpoch;
|
||||
message.pic.data = base64Encode(photoData);
|
||||
|
||||
var position = MyApp.currentPosition;
|
||||
if (position != null) {
|
||||
message.pos = PicMessagePos();
|
||||
message.pos.lat = position.latitude;
|
||||
message.pos.long = position.longitude;
|
||||
}
|
||||
|
||||
MqttCore.instance.publishPayloadMessage("job", message.toJson());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*private void SendImages()
|
||||
{
|
||||
var tourId = _jobTour.Id;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
|
||||
var index = 0;
|
||||
var realm = Realm.GetInstance();
|
||||
var tourImages = realm.All<TourImage>().Where(tourImage => tourImage.TourId == tourId);
|
||||
if (tourImages.Any())
|
||||
{
|
||||
foreach (var tourImage in tourImages)
|
||||
{
|
||||
var payloadObject = new JObject();
|
||||
|
||||
var picObject = new JObject();
|
||||
payloadObject.Add(new JProperty("pic", picObject));
|
||||
|
||||
picObject.Add(new JProperty("tr_id", tourImage.TourId));
|
||||
picObject.Add(new JProperty("num", index));
|
||||
picObject.Add(new JProperty("time", DateTime.Now.ToString("o")));
|
||||
picObject.Add(new JProperty("data", tourImage.ImageData));
|
||||
|
||||
var location = App.CurrentLocation;
|
||||
if (location != null)
|
||||
{
|
||||
var posObject = new JObject();
|
||||
picObject.Add(new JProperty("pos", posObject));
|
||||
|
||||
posObject.Add(new JProperty("lat", location.Latitude));
|
||||
posObject.Add(new JProperty("long", location.Longitude));
|
||||
}
|
||||
|
||||
App.Core.SendJsonMessageAsync("job", payloadObject);
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
Reference in new issue
Block a user