#577 und Refactoring
This commit is contained in:
1 parent
d59260fe24
commit
f8100facf3
3 files changed
+81
-63
No files matched your search
@@ -130,20 +130,12 @@ class _TourListPageState extends State<TourListPage> {
|
||||
JobTour? lastTour;
|
||||
|
||||
for (var tour in _tours) {
|
||||
bool tourActive = false;
|
||||
|
||||
if (lastTour == null) {
|
||||
tourActive = true;
|
||||
} else {
|
||||
if (lastTour.state != 0) {
|
||||
tourActive = true;
|
||||
}
|
||||
}
|
||||
bool tourReadOnly = isTourReadOnly(lastTour, tour);
|
||||
|
||||
Color color = Colors.transparent;
|
||||
switch (tour.state) {
|
||||
case 0:
|
||||
color = tourActive ? Colors.white : Colors.grey;
|
||||
color = !tourReadOnly ? Colors.white : Colors.grey;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -161,11 +153,7 @@ class _TourListPageState extends State<TourListPage> {
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
onTap: () {
|
||||
if (tourActive) {
|
||||
_clicked(tour, false);
|
||||
} else {
|
||||
_clicked(tour, true);
|
||||
}
|
||||
_clicked(tour, tourReadOnly);
|
||||
},
|
||||
title: Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -200,6 +188,26 @@ class _TourListPageState extends State<TourListPage> {
|
||||
return tourWidgets;
|
||||
}
|
||||
|
||||
bool isTourReadOnly(JobTour? lastTour, JobTour tour) {
|
||||
bool readOnly;
|
||||
|
||||
if (!widget.readOnly) {
|
||||
readOnly = false;
|
||||
|
||||
if (lastTour == null) {
|
||||
readOnly = tour.state != 0;
|
||||
} else {
|
||||
if (lastTour.state == 0) {
|
||||
readOnly = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
readOnly = true;
|
||||
}
|
||||
|
||||
return readOnly;
|
||||
}
|
||||
|
||||
void _clicked(JobTour tour, bool readOnly) {
|
||||
MessageService().publish<ContentViewWidget>(Constants.messageTopicPushContentView, arguments: TourDetailsPage(job: widget.job, tour: tour, readOnly: readOnly));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user