// // ContentView.swift // Shared // // Created by Eric Mader on 7/6/20. // import SwiftUI struct SomeObject : Identifiable, Hashable { let id = UUID() let name: String let otherStuff: [String] } let someObjects: [SomeObject] = [ SomeObject(name: "An object", otherStuff: [ "An object 1", "An object 2" ]), SomeObject(name: "Another Object", otherStuff: [ "Another object 1", "Another object 2" ]) ] struct ContentView: View { @State var isExpanded: Bool = false var useListForContent: Bool = true var body: some View { List(someObjects, id: \.self) { someObject in DisclosureGroup( //isExpanded: $isExpanded, content: { if (useListForContent) { List(someObject.otherStuff, id: \.self) {stuff in Text(stuff) } } else { VStack(content: { ForEach(someObject.otherStuff, id: \.self) { stuff in Text(stuff) } }) } }, label: { Text(someObject.name) } ) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }