If you do want SwiftUI only solution, you should not have included the tag UIKit.
When the tags or the terms may not be appropriate enough, you should better try to explain your issue more precisely.
Including codes and/or images will help avoiding confusion of readers.
What I want to really achieve is the sidebar that is used in the iPad Settings app
I could not find a simple way to hide Collapse button on navigation bar.
Also, as far as I checked the UI design of Settings app of iOS 14 & 15
The UI does not change whether in portrait or in landscape
Each row in the list does not have a disclosure indicator (⟩)
So, I guess, the Settings app is not constructed simply using the ColumnNavigationViewStyle and NavigationLink.
You may need to do it all by yourself.
A little bit simplified example:
struct ContentView: View {
@State var secondViewTitle: String?
let rows = ["Hello", "World"]
var body: some View {
HStack {
NavigationView {
List {
Section {
ForEach(rows, id: \.self) { row in
Button(action: {
if self.secondViewTitle == row {
self.secondViewTitle = nil
} else {
self.secondViewTitle = row
}
}, label: {
HStack {
Text(row)
.padding()
Spacer()
}
})
.background(self.secondViewTitle == row ? Color.accentColor : Color.white)
.listRowInsets(EdgeInsets())
}
.foregroundColor(Color.primary)
}
}
.listStyle(InsetGroupedListStyle())
.navigationTitle("Test")
}
.navigationViewStyle(StackNavigationViewStyle())
.frame(width: 360)
SecondView(title: secondViewTitle)
.frame(maxWidth: .infinity)
}
}
}
struct SecondView: View {
let title: String?
var body: some View {
Text("\(title ?? "")")
}
}