Merge branch 'main' into new_appserver

# Conflicts:
#	lib/content_views/approach_area_page.dart
#	lib/content_views/assigned_jobs_page.dart
#	lib/content_views/main_page.dart
#	lib/content_views/task_list_page.dart
#	lib/main.dart
#	lib/popups/accept_jobs_popup.dart
#	lib/protocoll_messages/logout_message.dart
#	lib/protocoll_messages/logout_message.g.dart
#	lib/tools/constants.dart
#	lib/tools/mqtt_core.dart
#	pubspec.lock
#	pubspec.yaml
This commit is contained in:
Sven committed 2024-03-26 12:56:04 +01:00
commit 880cdd65ff
74 files changed
+2463 -441

No files matched your search

+43 -54
View File
@@ -1,12 +1,13 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
import 'package:stadtbote/content_views/utils/content_view_widget.dart';
import 'package:stadtbote/content_views/utils/header_info.dart';
import 'package:stadtbote/model/rank.dart';
import 'package:stadtbote/model/ranking.dart';
import 'package:stadtbote/popups/tasks_popups/zip_popup.dart';
import 'package:stadtbote/protocoll_messages/zip_message.dart';
import 'package:stadtbote/tools/constants.dart';
import 'package:stadtbote/tools/message_service.dart';
import 'package:stadtbote/tools/messages/ranking_updated.dart';
import 'package:stadtbote/tools/mqtt_core.dart';
import '../main.dart';
@@ -43,21 +44,30 @@ class ApproachAreaPage extends ContentViewWidget {
}
class _ApproachAreaPageState extends State<ApproachAreaPage> {
late List<Rank>? _rankings;
late Ranking? _ranking;
late bool _initCompleted = false;
@override
void initState() {
super.initState();
Future.delayed(const Duration(seconds: 0), () async {
_rankings = await MyApp.isarInstance.ranks.where().findAll();
_ranking = await MyApp.isarInstance.rankings.where().findFirst();
_initCompleted = true;
setState(() {});
});
super.initState();
_initMessages();
}
@override
void deactivate() {
super.deactivate();
MessageService().unsubscribe(Constants.messageTopicRankingUpdated, this);
}
@override
@@ -84,18 +94,16 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> {
List<Widget> _fillColumns() {
List<Widget> columns = [];
if (_rankings != null) {
for (int i = 0; i < _rankings!.length; i++) {
var rank = _rankings![i];
if (_ranking != null) {
for (int i = 0; i < _ranking!.ranks.length; i++) {
var rank = _ranking!.ranks[i];
List<Widget> entries = [];
entries.add(
GestureDetector(
onTap: ()=> {
onTap: () => {
if (i == 0) {
showZipPopup(context, 'ACHTUNG: Wenn Sie Ihre PLZ ändern, verlieren Sie Ihr Ranking!\n', 'Freimelden', (zip) => {_sendZip(rank, zip, ModeEnum.set)}),
} else {
showZipPopup(context, 'ACHTUNG: Wenn Sie Ihre PLZ ändern, verlieren Sie Ihr Ranking!\n', 'OK', (zip) => {_sendZip(rank, zip, ModeEnum.request)}),
}
},
child: Container(
@@ -103,7 +111,7 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> {
margin: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: i == 0 ? Colors.lightGreen : Colors.white,
color: i == 0 ? Constants.colorPrimary : Colors.white,
border: Border.all(
color: Colors.grey,
width: 0.5,
@@ -114,10 +122,11 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> {
child: Column(children: [
Text(
rank.zip,
style: const TextStyle(fontSize: 20),
style: TextStyle(fontSize: 20, color: (i == 0 ? Colors.white : Colors.black)),
),
Text(
rank.area,
style: TextStyle(fontSize: 13, color: (i == 0 ? Colors.white : Colors.black)),
)
]
)
@@ -168,56 +177,36 @@ class _ApproachAreaPageState extends State<ApproachAreaPage> {
}
_sendZip(Rank rank, String zip, ModeEnum mode) {
var message = ZipMessage();
var zipMessage = ZipMessage();
if (mode == ModeEnum.set) {
var position = MyApp.currentPosition;
message.setPos = ZipSetPos();
message.setPos!.zip = zip;
zipMessage.setPos = ZipSetPos();
zipMessage.setPos!.zip = zip;
if (position != null) {
message.setPos!.track = ZipTrack();
message.setPos!.track.time = DateTime.now().toIso8601String();
message.setPos!.track.pos = ZipTrackPos();
message.setPos!.track.pos!.lat = position.latitude;
message.setPos!.track.pos!.long = position.longitude;
message.setPos!.track.pos!.acc = position.accuracy.toInt();
zipMessage.setPos!.track = ZipTrack();
zipMessage.setPos!.track!.time = DateTime.now().toIso8601String();
zipMessage.setPos!.track!.pos = ZipTrackPos();
zipMessage.setPos!.track!.pos!.lat = position.latitude;
zipMessage.setPos!.track!.pos!.long = position.longitude;
zipMessage.setPos!.track!.pos!.acc = position.accuracy.toInt();
}
} else {
message.reqZip = ZipReqZip();
message.reqZip!.id = rank.id;
message.reqZip!.zip = zip;
zipMessage.reqZip = ZipReqZip();
zipMessage.reqZip!.id = rank.id;
zipMessage.reqZip!.zip = zip;
}
MqttCore.instance.publishText("set_location", jsonEncode(message.toJson()));
MqttCore.instance.publishPayloadMessage("rank", zipMessage.toJson());
}
}
/*
private void SendMessage(int columnNumber, string zipNumber)
{
var payloadObject = new JObject();
_initMessages() {
MessageService().subscribe<RankingUpdated>(Constants.messageTopicRankingUpdated, this, (rankingUpdateMessage) async {
_ranking = await MyApp.isarInstance.rankings.where().findFirst();
if (columnNumber == 0)
{
var setPosObject = new JObject();
payloadObject.Add(new JProperty("set_pos", setPosObject));
setPosObject.Add(new JProperty("zip", zipNumber));
setPosObject.Add(new JProperty("track", CreateTrackObject()));
}
else
{
var regZipObject = new JObject();
payloadObject.Add(new JProperty("reg_zip", regZipObject));
regZipObject.Add(new JProperty("id", columnNumber));
regZipObject.Add(new JProperty("zip", zipNumber));
}
var json = payloadObject.ToString();
App.Core.SendJsonMessageAsync("rank", payloadObject);
}
*/
setState(() {});
});
}
}