Skip to content

Instantly share code, notes, and snippets.

@erica erica/ModalDetail.swift
Last active Jun 20, 2019

Embed
What would you like to do?
import PlaygroundSupport
import SwiftUI
struct LiveView: View {
@State var isPresented = false
var modalPresentation: some View {
NavigationView {
Text("Hello World")
.font(.caption)
.navigationBarTitle(Text("Modal Contents"))
.navigationBarItems(trailing: Button(action: { self.isPresented = false } ) { Text("Done") })
}
}
var body: some View {
NavigationView {
NavigationButton(destination: Text("Hello World")
.font(.caption)
.navigationBarTitle(Text("Detail View Contents"))
) {
Text("Show Detail View")
}
.navigationBarTitle(Text("Welcome"))
.navigationBarItems(trailing:
Button(action: { self.isPresented = true }) { Text("Show Modal") })
}
.presentation( isPresented ? Modal(modalPresentation, onDismiss: { self.isPresented.toggle() }) : nil )
}
}
let liveView = LiveView()
PlaygroundPage.current.liveView = UIHostingController(rootView: liveView)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.