I'm trying to make a fully custom list of expandable sections that have projects inside them in SwiftUI. This is how I want it to look in the end:
I think I have the SwiftUI code set up right, but I'm having trouble finding view modifiers to accomplish what I want.
Here is my code with most style modifiers removed for brevity:
List {
ForEach(sections, id: \.self) { section in
DisclosureGroup(isExpanded: $expand) {
ForEach(section.projectArray, id: \.self) { project in
//--- Projects ---
HStack{
Image("project")
Text(project.wrappedName)
Spacer()
}
.padding(EdgeInsets(top: 0, leading: 0, bottom:0, trailing: 0))
}
} label: {
//--- Sections ---
HStack{
Text(section.wrappedName)
Spacer()
//Custom Toggle Arrow
Button(action: {
//Toggle logic
}){
if expand{
Image("section-open")
}else{
Image("section-closed")
}
}
}
.padding(0)
}
}
}.listStyle(PlainListStyle())
I can't find anything to change DisclosureGroup that adds a few default styles I don't want:
A - A default expand/collapse arrow
B - When expanded, the DisclosureGroup's label grows horizontally
C - Default padding on the child elements
I checked the docs and don't see a way to remove these default styles. Any ideas how I can pull off this design?


