Skip to content

Instantly share code, notes, and snippets.

@erica
Last active June 20, 2019 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erica/01c71785d8c3e3354ba219d8bc32eaa5 to your computer and use it in GitHub Desktop.
Save erica/01c71785d8c3e3354ba219d8bc32eaa5 to your computer and use it in GitHub Desktop.
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