Last active
December 18, 2023 02:33
-
-
Save zntfdr/64e27da563b6a601615dd3b704e9bab8 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 | |
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