import 'dart:developer';
import 'package:anyway/modules/step_between_landmarks.dart';
import 'package:flutter/material.dart';

import 'package:anyway/modules/landmark_card.dart';
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");
  
  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"),
    );
    return children;
  }

  for (Landmark landmark in trip.landmarks) {
    children.add(
      LandmarkCard(landmark, trip),
    );

    if (landmark.next != null) {
      children.add(
        StepBetweenLandmarks(current: landmark, next: landmark.next!)
      );
    }
  }

  return children;
}

