This file contains 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