Skip to content

Instantly share code, notes, and snippets.

@twittemb
Last active October 28, 2020 13:24
Show Gist options
  • Save twittemb/f0eec9290e1a54bddaa4af44eaf53943 to your computer and use it in GitHub Desktop.
Save twittemb/f0eec9290e1a54bddaa4af44eaf53943 to your computer and use it in GitHub Desktop.
import SwiftUI
struct DetailView : View {
var body : some View {
// In order for the dismiss to happen, either NavigationView or VStack has to be commented
NavigationView {
VStack {
InnerView()
}
.navigationTitle("Detail")
}
}
}
struct InnerView: View {
@Environment (\.presentationMode) var presentationMode
var body: some View {
VStack {
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Text("Back")
})
}
}
}
struct ContentView: View {
@State
var show: Bool = false
var body: some View {
Button(action: {
self.show = true
}, label: {
Text("Show Detail")
})
.sheet(isPresented: self.$show) { DetailView() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment