Chapter 11 Lists & Navigation I just followed book to do til page 584.
Page 584, in the picture at left top corner, there is < Back button, can navigate back to content view. it is departure , which is behaviour the same thing in my simulator.
but my question is why in content view, I click arrivals to navigate to FlightBoard view. at left top corner ,it show < Mountain Airport. not show <Back
why arrivals is different to departure. you can see your page 592 the first image, also show < Mountain Airport. not show <Back
code in contenview
import SwiftUI
struct ContentView: View {
var flightInfo: [FlightInformation] = FlightInformation.generateFlights()
var body: some View {
NavigationView {
ZStack {
Image(systemName: "airplane")
.resizable()
.aspectRatio(contentMode: .fit)
.opacity(0.1)
.rotationEffect(.degrees(-90))
.frame(width: 250, height: 250, alignment: .center)
VStack(alignment: .leading, spacing: 5) {
// 2
NavigationLink(destination: FlightBoard(
boardName: "Arrivals",
flightData: self.flightInfo.arrivals())) {
// 3
Text("Arrivals")
}
NavigationLink(destination: FlightBoard(
boardName: "Departures",flightData: self.flightInfo.departures())) {
Text("Departures")
}
Spacer()
}
.font(.title)
.padding(20)
// 4
}
.navigationBarTitle(Text("Mountain Airport"))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Code in FlightBoard
import SwiftUI
struct FlightBoard: View {
var boardName: String
var flightData: [FlightInformation]
var body: some View {
List(flightData) { flight in
Text("\(flight.airline) \(flight.number)")
}.navigationBarTitle(boardName)
}
}
struct FlightBoard_Previews: PreviewProvider {
static var previews: some View {
FlightBoard(boardName: “Test”,flightData: FlightInformation.generateFlights())
}
}