I want to have horizontal paging with navigation bars on each page. Going with TabView
, there is an issue in combination with page
style when nesting NavigationStack. Let me show you an example.
The following code works but uses tabs.
var body: some View {
TabView(selection: $selectedTab) {
NavigationStack {
List {
Text("Page 1")
}
.tag(LandingPage.activity)
.navigationTitle("Title")
}
.tabItem {
Text("Tab 1")
}
NavigationStack {
List {
Text("Page 2")
}
.tag(LandingPage.activity)
.navigationTitle("Title 2")
}
.tabItem {
Text("Tab 2")
}
}.tabViewStyle(.automatic)
}
Now switching tabViewStyle
to "page", it renders weird.
var body: some View {
TabView(selection: $selectedTab) {
NavigationStack {
List {
Text("Page 1")
}
.tag(LandingPage.activity)
.navigationTitle("Title")
}
NavigationStack {
List {
Text("Page 2")
}
.tag(LandingPage.activity)
.navigationTitle("Title 2")
}
}.tabViewStyle(.page)
}
Does anyone have any experience with such setup?