When I embed a List
grouped into Section
s into a NavigationView
the section headers become collapsible. I'd like to keep them non-collapsible, just like when the List
is not embedded into the NavigationView
.
My current code (with the NavigationView):
import SwiftUI
struct MyGroup {
var name:String, items:[String]
}
struct ContentView: View {
var groups : [MyGroup] = [
.init(name: "Animals", items: ["π","π©","π","π","π","π¦©","πΏ","π"]),
.init(name: "Vehicles", items: ["π","π","π","π","π","π€","π₯","β΅οΈ"])]
var body: some View {
NavigationView {
VStack {
List {
ForEach(groups, id: \.self.name) { group in
Section(header: Text(group.name)) {
ForEach(group.items, id:\.self) { item in
Text(item)
}
}
}
}
}.navigationTitle("collections")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
.collapsible(false)
on macOS. File a bug with Apple if you want this to change in the future. β Keratin