more pleasant progress handling, although somewhat flawed

This commit is contained in:
2025-02-14 12:23:41 +01:00
parent aed407e2d0
commit 8f6dfd404d
8 changed files with 287 additions and 172 deletions

View File

@@ -7,14 +7,11 @@ import 'package:anyway/structs/landmark.dart';
import 'package:anyway/structs/trip.dart';
List<Widget> landmarksList(Trip trip) {
log("Trip ${trip.uuid} ${trip.landmarks.length} landmarks");
// Returns a list of widgets that represent the landmarks matching the given selector
List<Widget> landmarksList(Trip trip, {required bool Function(Landmark) selector}) {
List<Widget> children = [];
log("Trip ${trip.uuid} ${trip.landmarks.length} landmarks");
if (trip.landmarks.isEmpty || trip.landmarks.length <= 1 && trip.landmarks.first.type == typeStart ) {
children.add(
const Text("No landmarks in this trip"),
@@ -23,14 +20,16 @@ List<Widget> landmarksList(Trip trip) {
}
for (Landmark landmark in trip.landmarks) {
children.add(
LandmarkCard(landmark, trip),
);
if (landmark.next != null) {
if (selector(landmark)) {
children.add(
StepBetweenLandmarks(current: landmark, next: landmark.next!)
LandmarkCard(landmark, trip),
);
if (!landmark.visited && landmark.next != null) {
children.add(
StepBetweenLandmarks(current: landmark, next: landmark.next!)
);
}
}
}