Last active
June 20, 2019 21:28
-
-
Save erica/01c71785d8c3e3354ba219d8bc32eaa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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