I don’t understand why listRowBackground is only being applied to the list items without children, and not applying in the expandable ones?
This is how it looks:
list
List(viewModel.tree, id: .id, children: .children) { tree in
HStack{
Image(systemName:tree.children != nil ? "folder" : "antenna.radiowaves.left.and.right")
.fontWeight(.medium)
Text(tree.name)
.fontWeight(.medium)
.textCase(.uppercase)
.padding(.vertical, 5)
}
.foregroundStyle(colorScheme == .light ? .black : Color.cGray)
.listRowSeparator(.hidden)
.onTapGesture {
if tree.children == nil {
changeView = true
}
}
.listRowBackground(colorScheme == .light ? .white : Color.dBackground)
}
.listRowSpacing(10)
.listStyle(.plain)
.background(colorScheme == .light ? .white : Color.dBackground)
Shouldn’t listRowBackground(colorScheme == .light ? .white : Color.dBackground)
change the background of every item?
New contributor
Alicia Batistella is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.