I have 3 Views A, BSheet, C.
When I click on a button inside A View, B Sheet becomes visible. I have a button in B Sheet. I want to press a button in BSheet View to close/toggle BSheet and then navigate to C View. Any ideas how I can accomplish that?
A.swift
struct A: View{
@State var displayBSheet = false
var body: some View{
NavigationView{
VStack{
Button(action: {self.displayBSheet.toggle()}){
Text("Navigate to BSheet")
}.sheet(isPresented: $displayBSheet){
BSheet()
}
NavgiationLink(destination: C()){
Text("Navigate To C")
}
}
}
}
}
BSheet.swift
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
struct MainView: View {
var body: some View {
Button(action:{
self.presentationMode.wrappedValue.dismiss()//This only sheet but I want to navigate to C View also
}){
Text("Close sheet and navigate to struct C")
}
}
}
C.swift
struct C: View {
var body: some View {
Text("C")
}
}