Using the very helpful answer by @nocsi I have the following working solutions...
List {
ForEach(gardens) { section in
DisclosureGroup(section.id, content: {
ForEach(section) { garden in
NavigationLink(destination: GardenDetail(...),
tag: garden.uuID!.uuidString,
selection: $appData.selectedGardens
) {
GardenRow(garden: garden,
selected: garden.uuID?.uuidString == appData.selectedGardens)
}
}
})
}
}
OR
List {
ForEach(gardens) { section in
DisclosureGroup(section.id, content: {
ForEach(section) { garden in
NavigationLink(destination: GardenDetail(...),
tag: garden.uuID!.uuidString,
selection: $appData.selectedGardens
) {
GardenRow(garden: garden,
selected: garden.uuID?.uuidString == appData.selectedGardens)
}
}
},
label: { Text(section.id)
})
}
}
However this solution...
provides only a top level disclosure group, not the cascading outline group style that I was hoping to achieve;
does not provide section headers for iOS and macOS;
in my humble opinion, does not work as well as the disclosure indicators for iOS and sizeClassHorizontal == .compact that are automatically provided for each section.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: