Your Second iOS & SwiftUI App

Nov 4 2021 · Swift 5.5, iOS 15, Xcode 13

Part 1: List View Fundamentals

07. Navigation

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 06. Lists Next episode: 08. Challenge: View Reuse

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

We’ve got a bare-bones list up and running, and we’re ready to start adding features to our app. We can start by creating a detail view to show us more about each book when we tap on a row.

import SwiftUI

struct DetailView: View {
  var body: some View {
    Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
  }
}

struct DetailView_Previews: PreviewProvider {
  static var previews: some View {
    DetailView()
  }
}
struct DetailView: View {
  let book: Book

  var body: some View {
DetailView(book: .init())
  var body: some View {
    Book.Image(title: book.title)
  }
    VStack {
      Book.Image(title: book.title)
      Spacer()
    }
  var body: some View {
    NavigationLink(
      destination: /*@START_MENU_TOKEN@*/Text("Destination")/*@END_MENU_TOKEN@*/,
      label: {
        /*@START_MENU_TOKEN@*/Text("Navigate")/*@END_MENU_TOKEN@*/
      })
    HStack {
destination: DetailView(book: <#T##Book#>),
book: book)
  var body: some View {
    NavigationLink(
      destination: DetailView(book: book)
    ) {
      HStack {
        Book.Image(title: book.title)

        VStack(alignment: .leading) {
          Text(book.title)
            .font(.title2)
          Text(book.author)
            .font(.title3)
            .foregroundColor(.secondary)
        }
        .lineLimit(1)
      }
    }
  }
struct ContentView: View {
  var body: some View {
    NavigationView {
      List(Library().sortedBooks, id: \.title) { book in
        BookRow(book: book)
      }
    }
  }
}
        BookRow(book: book)
      }
      .navigationTitle("My Library")
    }