[ad_1]
I’ve an app that has “two root navigation” buildings. The primary view (you’ll be able to consider a login display screen) comprises navigation hyperlinks to different element views that are dismissable. One of many navigation hyperlinks goes to a TabView, which I need to be a “new root” navigation view; which means, a person shouldn’t be capable of view the again button or swipe again to the primary view. This TabView itself has navigation hyperlinks, to different dismissables.
I used the .hideNavigationBar() modifier on the TabView to cover the navigation on this view, nonetheless the again button remains to be current. Nonetheless if I swap to a different tab, go to a element, and dismiss that element, the TabBar all of the sudden respects this hidden navigation bar. A minimal working instance is pasted under:
struct BaseView: View {
var physique: some View {
NavigationView {
ZStack {
Shade.grey
VStack{
Textual content("Root Navigation View").padding()
NavigationLink(vacation spot: RootTabNavView()) {
Textual content("To New Root View")
}.padding()
NavigationLink(vacation spot: TestDetailView()) {
Textual content("To a element view")
}.padding()
}
}
.hideNavigationBar()
}
}
}
struct RootTabNavView: View {
var physique: some View {
ZStack {
TabView {
TestTabView1()
.tabItem {
Textual content("1")
}
TestTabView2()
.tabItem {
Textual content("2")
}
}
}
.hideNavigationBar()
}
}
struct TestTabView1: View {
var physique: some View {
ZStack {
Shade.purple
Textual content("Check Tab View 1 (New Nav Root / Hidden Navigation)")
}
.hideNavigationBar()
}
}
struct TestTabView2: View {
var physique: some View {
ZStack {
Shade.inexperienced
NavigationLink (vacation spot: TestDetailView()) {
Textual content("To a element view")
}
}
.hideNavigationBar()
}
}
struct TestDetailView: View {
var physique: some View {
ZStack {
Shade.purple
Textual content("A Dismissable Element")
}
}
}
struct BaseView_Previews: PreviewProvider {
static var previews: some View {
BaseView()
}
}
When the app hundreds, the BaseView is proven with hyperlinks to a TestDetailView and the RootTabNavView. When navigating to a TestDetailView we see the navigation bar on the prime as meant, and dismissable again to the BaseView. Nonetheless, when urgent the button to the RootTabNavView, the navigation tab remains to be current (letting the person swipe away the tabview). Nonetheless if we swap to Tab 2, go to a element view, and dismiss that element view, unexpectedly the tab view has a hidden navigation bar.
What’s extra attention-grabbing is that if I add to the RootTabNavView Navigation Hyperlink a isDetailLink(false) modifier, Tab 1 has a hidden navbar however when i swap to Tab 2 it reappears, solely when i’m going to a element and dismiss, it then hides once more.
Is that this a bug in SwiftUI? Am I misconfiguring one thing? Is .hideNavigationBar() or isDetailLink() behaving in methods I am not conscious of?
[ad_2]
