I have a list with sections headers on two views. One view has the section headers as collapsible, the other doesn't. Both use pretty much the same code, what defines if a section header is collapsible? Code for the one that doesn't collapse
ForEach(cards) { section in
let header: String = nameForSectionHeader(sectionID: section.id)
Section(header: Text(header)) {
ForEach(section) { card in
NavigationLink(destination: CardView(card: card)) {
HStack {
Image(card.imageName ?? "")
.renderingMode(.original)
.resizable()
.scaledToFit()
.frame(width: 50.0)
VStack(alignment: .leading) {
if let name = card.name, let id = card.cardID {
Text("\(id) - \(name)")
}
Text("Owned: \(card.owned)")
}
}
}
}
}
}
}
and the code for the one that does
ForEach(cards) { section in
let header: String = nameForSectionHeader(sectionID: section.id)
Section(header: Text(header)) {
ForEach(section) { card in
NavigationLink(destination: CardView(card: card)) {
VStack(alignment: .leading) {
if let name = card.name, let id = card.cardID {
Text("\(id) - \(name)")
}
if let set = card.set, let setName = set.name {
Text("Set: \(setName)")
}
if card.owned > 0 {
Text("Owned: \(card.owned)")
}
}
}
}
}
}
.listRowBackground(lightGreen)
}