Fehlerkorrekturen
This commit is contained in:
1 parent
faef9ac5d9
commit
125e6eb03e
16 files changed
+335
-48
No files matched your search
@@ -88,7 +88,7 @@ class _AcceptedJobsPageState extends State<AcceptedJobsPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(),
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
|
||||
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.transparent),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
|
||||
@@ -121,7 +121,7 @@ class _AssignedJobsPageState extends State<AssignedJobsPage> {
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(),
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(backgroundColor: isJobInFuture(job) ? Colors.yellow : Colors.white),
|
||||
),
|
||||
|
||||
@@ -88,7 +88,7 @@ class _FinishedJobsPageState extends State<FinishedJobsPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime)).toString(),
|
||||
DateFormat('dd.MM.yyyy HH:mm').format(DateTime.parse(job.ordertime).toLocal()).toString(),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Text(
|
||||
|
||||
@@ -230,7 +230,7 @@ class _MainPageState extends State<MainPage> {
|
||||
getDefaultButton(
|
||||
_loggedOut ? 'Anmelden' : 'Abmelden',
|
||||
image: Image.asset(_loggedOut ? 'assets/anmelden.png' : 'assets/abmelden.png', width: 30, height: 30),
|
||||
() async => {_logout()}),
|
||||
() async => {_logout(context)}),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -305,20 +305,58 @@ class _MainPageState extends State<MainPage> {
|
||||
}
|
||||
}
|
||||
|
||||
_logout() {
|
||||
_logout(context) {
|
||||
if (!_loggedOut) {
|
||||
_sendLogoutMessage();
|
||||
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
MqttCore.instance.diconnect();
|
||||
});
|
||||
showLogoutAlertDialog(context);
|
||||
} else {
|
||||
MqttCore.setup();
|
||||
|
||||
_loggedOut = false;
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
_loggedOut = !_loggedOut;
|
||||
showLogoutAlertDialog(BuildContext context) {
|
||||
Widget yesButton = TextButton(
|
||||
child: const Text("Ja"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
_sendLogoutMessage();
|
||||
|
||||
setState(() {});
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
MqttCore.instance.diconnect();
|
||||
});
|
||||
|
||||
_loggedOut = true;
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
|
||||
Widget noButton = TextButton(
|
||||
child: const Text("Nein"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
|
||||
// set up the AlertDialog
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: const Text("Warnung"),
|
||||
content: const Text("Wollen Sie sich wirklich abmelden?"),
|
||||
actions: [
|
||||
yesButton, noButton,
|
||||
],
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_sendLogoutMessage() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:stadtbote/content_views/utils/content_view_widget.dart';
|
||||
import 'package:stadtbote/content_views/utils/header_info.dart';
|
||||
import 'package:stadtbote/main.dart';
|
||||
import 'package:stadtbote/model/message.dart' as sbmessage;
|
||||
import 'package:stadtbote/model/message.dart';
|
||||
import 'package:stadtbote/model/session_status.dart';
|
||||
import 'package:stadtbote/tools/mqtt_core.dart';
|
||||
|
||||
@@ -93,16 +94,17 @@ class _MessagesPageState extends State<MessagesPage> {
|
||||
void _handleSendPressed(types.PartialText text) async {
|
||||
var now = DateTime.now();
|
||||
|
||||
var message = sbmessage.Message();
|
||||
message.text = [text.text];
|
||||
message.from = _sid;
|
||||
message.subj = '';
|
||||
message.time = now.toIso8601String();
|
||||
message.read = true;
|
||||
message.id = await sbmessage.Message.getNextId();
|
||||
var message = MessageMessage();
|
||||
message.mssg = sbmessage.Message();
|
||||
message.mssg.text = [text.text];
|
||||
message.mssg.from = _sid;
|
||||
message.mssg.subj = '';
|
||||
message.mssg.time = now.toIso8601String();
|
||||
message.mssg.read = true;
|
||||
message.mssg.id = await sbmessage.Message.getNextId();
|
||||
|
||||
MyApp.isarInstance.writeTxnSync(() {
|
||||
MyApp.isarInstance.messages.putSync(message);
|
||||
MyApp.isarInstance.messages.putSync(message.mssg);
|
||||
});
|
||||
|
||||
MqttCore.instance.publishPayloadMessage('mssg', message.toJson());
|
||||
@@ -110,7 +112,7 @@ class _MessagesPageState extends State<MessagesPage> {
|
||||
_messages.insert(0, types.TextMessage(
|
||||
author: _user,
|
||||
createdAt: now.millisecondsSinceEpoch,
|
||||
id: message.id.toString(),
|
||||
id: message.mssg.id.toString(),
|
||||
text: text.text,
|
||||
));
|
||||
|
||||
|
||||
@@ -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