SwiftUI Fundamentals

Feb 28 2023 · Swift 5.7, macOS Venture 13.1, Xcode 14.2

Part 2: Navigation & Data Flow

13. Present 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: 12. NavigationStack Next episode: 14. Challenge: Navigation & Bindings

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 Navigation View isn’t the only way to show new views in your app. SwiftUI also gives you a component type called Sheet.

struct DetailView: View {
  let artwork: Artwork
  @State private var showMap = false
HStack(alignment: .firstTextBaseline) {
  Button(action: { showMap = true }) {
    Image(systemName: "mappin.and.ellipse")
  }
.sheet(isPresented: $showMap) {
  LocationMap(artwork: artwork)
}
.❌sheet❌🟢fullScreenCover(isPresented: $showMap)
HStack {
  Text(self.artwork.locationName)
  Spacer()
  Button("Done") {  }
@Binding var showModal: Bool
Button("Done") { self.showModal = false }
static var previews: some View {
  LocationMap(artwork: artData[0], showModal: .constant(true))
}
LocationMap(artwork: self.artwork, showModal: self.$showMap)