Expected use case Tab B -> list View -> Detail View
On tapping notification Tab B -> list view -> Detail view -> Notification detail view
navigating back
Tab B -> list view -> Detail View
but it working like below
Tab B -> list View -> Detail View
On tapping notification Tab B -> list view -> Detail view -> Notification detail view
navigating back
Tab B -> list view
struct ContentView: View {
let todoPublisher = NotificationCenter.default.publisher(for: NSNotification.Name("Detail"))
@State var show: Bool = false
@State var navigationTitle: String = "First"
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: Detail(), isActive: self.$show) { Text("")}.hidden()
// HiddenNavigationLink(destination: Detail(), isActive: self.$show)
TabView() {
FirtstView(navigationTitle: self.$navigationTitle)
.tabItem {
Image(systemName: "1.circle")
Text("First")
}.tag(0)
ListView(navigationTitle: self.$navigationTitle)
// ListView()
.tabItem {
Image(systemName: "2.circle")
Text("Second")
}.tag(1)
}
}
.navigationBarTitle(navigationTitle)
}
.onReceive(todoPublisher) {notification in
self.show = true
}
}
}
Here is the list view code
struct ListView: View {
@Binding var navigationTitle: String
var body: some View {
List {
ForEach(0..<5) {data in
NavigationLink(destination: DetailView()) {
Text("Text for row \(data)")
}
}
}
.onAppear() {
self.navigationTitle = "Second"
}
}
}