import SwiftUI
import CoreLocation

struct LocationSampleListView: View {

    let samples: [CLLocation]

    var body: some View {
        List {
            ForEach(samples, id: \.timestamp) { location in
                NavigationLink(value: location) {
                    DetailRow("", value: location.timestamp.timeAndDateWithSecondsText)
                }
            }
        }
        .navigationTitle("Locations")
        .navigationDestination(for: CLLocation.self) {
            LocationSampleDetailView(location: $0)
        }
    }
}

#Preview {
    NavigationStack {
        LocationSampleListView(samples: [.mock])
    }
}
