more pleasant progress handling, although somewhat flawed
This commit is contained in:
@@ -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!)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user