37 lines
999 B
Dart
37 lines
999 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:anyway/structs/landmark.dart';
|
|
import 'package:anyway/structs/trip.dart';
|
|
import 'package:anyway/modules/step_between_landmarks.dart';
|
|
import 'package:anyway/modules/landmark_card.dart';
|
|
|
|
|
|
// 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 = [];
|
|
|
|
if (trip.landmarks.isEmpty || trip.landmarks.length <= 1 && trip.landmarks.first.type == typeStart ) {
|
|
children.add(
|
|
const Text("No landmarks in this trip"),
|
|
);
|
|
return children;
|
|
}
|
|
|
|
for (Landmark landmark in trip.landmarks) {
|
|
if (selector(landmark)) {
|
|
children.add(
|
|
LandmarkCard(landmark, trip),
|
|
);
|
|
|
|
if (!landmark.visited && landmark.next != null) {
|
|
children.add(
|
|
StepBetweenLandmarks(current: landmark, next: landmark.next!)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
return children;
|
|
}
|