If you use the new TabView in conjunction with ".tabViewStyle(.sidebarAdaptable)" and have a NavigationSplitView in the tabs, the result is a very confusing user experience.
When the TabView is displayed as tabs, there are two sidebar buttons. The left one closes/opens the sidebar of the view of the selected tab.
The sidebar button of the Top-TabView closes/opens the sidebar for customizing the tabbar. However, this sidebar overlays the sidebar of the selected tab. To be able to use the underlying sidebar again, the user must actively close the TabView sidebar again (turn it into the top tabbar)
Has anyone found ways to improve this behavior, or is this wrong by design?
My expected behavior would be: If you use the new TabView with ".tabViewStyle(.sidebarAdaptable)" and have a two column NavigationSplitView in a tab, it automatically becomes a three column view when the top tabbar becomes a sidebar.
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Tab("Home", systemImage: "house") {
HomeView()
}
Tab("Settings", systemImage: "gearshape") {
Text("Settings")
}
}
.tabViewStyle(.sidebarAdaptable)
}
}
enum TabItem: String, Identifiable, CaseIterable {
case first
case second
case third
var id: String { rawValue }
var content: String { rawValue }
}
struct HomeView: View {
@State var selectedTab: String?
var body: some View {
NavigationSplitView {
List(TabItem.allCases, selection: $selectedTab) { item in
Text(item.content)
}
} detail: {
if let selectedTab {
Text("Detail: \(selectedTab)")
} else {
Text("Select an item")
}
}
}
}