Get started
Swift SDK
Show itinerary data

List segments and waypoints

List segments and waypoints

The two tables read the same itinerary the profile does, through the same cache: one request for all of them.

List the legs

ItinerarySegmentTable states the legs as a roadbook: a row per leg with its sparkline, length, climb and descent.

import MountayaElements
import MountayaGeo
import SwiftUI

struct Roadbook: View {
  let itineraries: ItineraryResourceCache

  var body: some View {
    ScrollView {
      ItinerarySegmentTable(
        itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries)
    }
  }
}

List the places

ItineraryWaypointTable states the places, a row per pass, with a chip per service that keeps the places offering every service picked:

import MountayaElements
import MountayaGeo
import SwiftUI

struct Places: View {
  let itineraries: ItineraryResourceCache

  var body: some View {
    ItineraryWaypointTable(
      itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries,
      columns: [.waypoint, .distance, .amenities, .cutoff],
      formatCutoffAt: { cutoff in
        formatDateTime(cutoff, locale: "fr-FR", timeZone: "Europe/Paris", timeLength: .short) ?? ""
      })
  }
}

Draw a sparkline

ItinerarySparkline draws a small elevation curve from a series you build with Geo:

import MountayaClient
import MountayaElements
import MountayaGeo
import SwiftUI

struct TourSparkline: View {
  let itinerary: RestSchema.ItineraryWithDetails

  var body: some View {
    ItinerarySparkline(series: buildElevationSeries(ResolvedItinerary(itinerary).geometry))
      .frame(width: 120, height: 32)
  }
}

Show one place in a card

WaypointCard shows one place: its name, its services, when it can be used, how to reach it, its links and its photos.

import MountayaElements
import MountayaGeo
import SwiftUI

struct PlaceSheet: View {
  let place: ItineraryPlace

  var body: some View {
    ScrollView {
      WaypointCard(
        place: place,
        formatCutoffAt: { cutoff in
          formatDateTime(cutoff, locale: "fr-FR", timeZone: "Europe/Paris", timeLength: .short) ?? ""
        })
    }
  }
}

The places of an itinerary are ResolvedItinerary(itinerary).waypoints.

Link a table to a map

Hand a table your map. A row pointed at pins a marker on the map, and a leg the map's cursor is over lights its row:

import MountayaElements
import MountayaGeo
import SwiftUI

struct TablesBesideMap: View {
  let map: MapEngine
  let itineraries: ItineraryResourceCache

  var body: some View {
    VStack(spacing: 0) {
      MapView(map)
      ItinerarySegmentTable(
        itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries, map: map)
    }
  }
}

Next steps

Last updated