-
-
Save indyfromoz/fe223d84bde099f3321f9f420d2444fd 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 SwiftUI | |
extension Notification.Name { | |
static let popEverything = Notification.Name("pop_everything") | |
} | |
struct MoreTabView: View { | |
@State var triggerNext: Bool = false | |
@State var allowNavigationLinks: Bool = true | |
var body: some View { | |
VStack { | |
NavigationLink( | |
destination: View2(), | |
isActive: $triggerNext) { | |
Text("tap1") | |
}.isDetailLink(false) | |
}.onReceive(NotificationCenter.default.publisher(for: .popEverything)) { _ in | |
self.triggerNext = false | |
} | |
} | |
} | |
struct View2: View { | |
@State var showingNext: Bool = false | |
var body: some View { | |
VStack { | |
NavigationLink(destination: View3(), isActive: $showingNext) { | |
Text("tap2") | |
} | |
} | |
} | |
} | |
struct View3: View { | |
var body: some View { | |
VStack { | |
Button(action: { | |
NotificationCenter.default.post(name: .popEverything, object: nil) | |
}) { | |
Text("last tap") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment