From 34d4420855a5fa184cc8d28645165c958429753a Mon Sep 17 00:00:00 2001 From: Sven Carstensen Date: Mon, 12 Feb 2024 10:33:06 +0100 Subject: [PATCH] Erweiterungen --- lib/content_views/task_list_page.dart | 29 ++++++---------- lib/model/tour_task.dart | 4 +-- lib/model/tour_task.g.dart | 48 +++++---------------------- 3 files changed, 20 insertions(+), 61 deletions(-) diff --git a/lib/content_views/task_list_page.dart b/lib/content_views/task_list_page.dart index 818fe46..f8ca2e4 100644 --- a/lib/content_views/task_list_page.dart +++ b/lib/content_views/task_list_page.dart @@ -358,12 +358,19 @@ class _TaskListPageState extends State { } bool isTaskActive(int index) { - for (int i = 0; i < index; i++) { - var taskInfo = _taskList[i]; + var currentTaskInfo = _taskList[index]; - if (!taskInfo.completed) return false; + if (currentTaskInfo.completed && !currentTaskInfo.task.reenter!) return false; + + for (var taskInfo in _taskList) + { + if (taskInfo == currentTaskInfo) break; + + if (!taskInfo.task.opt! && !taskInfo.completed) return false; } + if (currentTaskInfo.task.reenter!) return true; + return true; } @@ -385,22 +392,6 @@ class _TaskListPageState extends State { MqttCore.instance.publishPayloadMessage("job", finTaskMessage.toJson()); } - /*_sendTrackStationMessage(TaskInfo taskInfo) - { - var trackStationMessage = TrackStationMessage(); - trackStationMessage.sid = taskInfo.task.sId; - trackStationMessage.time = DateTime.now().toIso8601String(); - - var position = MyApp.currentPosition; - if (position != null) { - trackStationMessage.pos = FinTaskPos(); - trackStationMessage.pos!.lat = position.latitude; - trackStationMessage.pos!.long = position.latitude; - } - - MqttCore.instance.publishPayloadMessage("", trackStationMessage.toJson()); - }*/ - _sendFinTourMessage() async { var finTourMessage = FinTourMessage(); finTourMessage.finTour = FinTour(); diff --git a/lib/model/tour_task.dart b/lib/model/tour_task.dart index b6d3937..a17e0c5 100644 --- a/lib/model/tour_task.dart +++ b/lib/model/tour_task.dart @@ -10,8 +10,8 @@ class TourTask { late int sId; late int type; late String topic; - late bool? opt; - late bool? reenter; + late bool opt = true; + late bool reenter = false; late int? min; late int? max; @JsonKey(name: 'max_len') diff --git a/lib/model/tour_task.g.dart b/lib/model/tour_task.g.dart index 0dd8ed5..2a484ca 100644 --- a/lib/model/tour_task.g.dart +++ b/lib/model/tour_task.g.dart @@ -170,8 +170,8 @@ TourTask _tourTaskDeserialize( object.max = reader.readLongOrNull(offsets[1]); object.maxLen = reader.readLongOrNull(offsets[2]); object.min = reader.readLongOrNull(offsets[3]); - object.opt = reader.readBoolOrNull(offsets[4]); - object.reenter = reader.readBoolOrNull(offsets[5]); + object.opt = reader.readBool(offsets[4]); + object.reenter = reader.readBool(offsets[5]); object.rt = reader.readBoolOrNull(offsets[6]); object.sId = reader.readLong(offsets[7]); object.taskArrival = reader.readLongOrNull(offsets[8]); @@ -204,9 +204,9 @@ P _tourTaskDeserializeProp

( case 3: return (reader.readLongOrNull(offset)) as P; case 4: - return (reader.readBoolOrNull(offset)) as P; + return (reader.readBool(offset)) as P; case 5: - return (reader.readBoolOrNull(offset)) as P; + return (reader.readBool(offset)) as P; case 6: return (reader.readBoolOrNull(offset)) as P; case 7: @@ -538,24 +538,8 @@ extension TourTaskQueryFilter }); } - QueryBuilder optIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNull( - property: r'opt', - )); - }); - } - - QueryBuilder optIsNotNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'opt', - )); - }); - } - QueryBuilder optEqualTo( - bool? value) { + bool value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'opt', @@ -564,24 +548,8 @@ extension TourTaskQueryFilter }); } - QueryBuilder reenterIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNull( - property: r'reenter', - )); - }); - } - - QueryBuilder reenterIsNotNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'reenter', - )); - }); - } - QueryBuilder reenterEqualTo( - bool? value) { + bool value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'reenter', @@ -1550,8 +1518,8 @@ TourTask _$TourTaskFromJson(Map json) => TourTask() ..sId = json['s_id'] as int ..type = json['type'] as int ..topic = json['topic'] as String - ..opt = json['opt'] as bool? - ..reenter = json['reenter'] as bool? + ..opt = json['opt'] as bool + ..reenter = json['reenter'] as bool ..min = json['min'] as int? ..max = json['max'] as int? ..maxLen = json['max_len'] as int?