Вот как это выглядит:
список
Код: Выделить всё
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)
Подробнее здесь: https://stackoverflow.com/questions/784 ... in-swiftui