Your Second iOS & SwiftUI App

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

Part 2: Data Flow

11. Modal Views

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: 10. Introduction Next episode: 12. Image Binding

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've reached locked video content where the transcript will be shown as obfuscated text.

The next feature we’re going to work on will let users add their own images to the app from the Detail View.

import SwiftUI
  ]

  var images: [Book: Image] = [:]
}
struct Book: Hashable {
List(Library().sortedBooks, id: \.self) { book in
extension PHPickerViewController {
  struct View {
    @Binding var image: UIImage?
  }
}
  let book: Book
  @State var showingImagePicker

  var body: some View {
  @State var modalIsPresented👉 = false
      )

      VStack {
        Book.Image(title: book.title)
      }
      
      Spacer()
        Book.Image(title: book.title)
        
        Button(<#T##title: StringProtocol##StringProtocol#>, action: <#T##() -> Void#>)
      }
Button("Update Image…", action: <#T##() -> Void#>)
        Book.Image(title: book.title)
        
        Button("Update Image…") {
          showingImagePicker = true
        }
      }
          showingImagePicker = true
        }
        .padding()
      }
    .padding()
    .sheet(isPresented: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Is Presented@*/.constant(false)/*@END_MENU_TOKEN@*/) {
      /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Content@*/Text("Sheet Content")/*@END_MENU_TOKEN@*/
    }
.sheet(isPresented: 👉$showingImagePicker) {
/// THE SOFTWARE.

import class PhotosUI.PHPickerViewController
import SwiftUI
    .sheet(isPresented: $showingImagePicker) {
      PHPickerViewController.View(image: <#T##Binding<Image?>#>)
    }
struct DetailView: View {
  let book: Book
  @Binding var image: Image?
  @State var showingImagePicker = false
PHPickerViewController.View(image: $image)
DetailView(book: .init(), image: .constant(nil))