Last active
October 28, 2020 13:24
-
-
Save twittemb/f0eec9290e1a54bddaa4af44eaf53943 to your computer and use it in GitHub Desktop.
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 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