Im trying to build a nested layers menu, like Sketch or Photoshop.
Bellow is what I did so far, using VStack with Sections to Group layers.
import SwiftUI
struct NestedList: View {
var body: some View {
ScrollView {
VStack {
Section (header: HStack {
Image(systemName: "arrowtriangle.down")
.accentColor(.black)
Text("Layer Group 1")
}) {
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
}
Section (header: HStack {
Image(systemName: "arrowtriangle.down")
.accentColor(.black)
Text("Layer Group 2")
}) {
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
HStack {
Image(systemName: "arrowtriangle.right")
.accentColor(.black)
Text("Layer 1")
}
}
}
}
}
}
struct NestedList_Previews: PreviewProvider {
static var previews: some View {
NestedList()
}
}
Now I am trying to show/hide sublayers, when tapped on the Grouped Layer arrow so that:
Anyone know how to do that? Really appreciate any help! : )
2
Answers
I show you a snippet, which is workable and you can modify to see Better result.
you can do it like this, i just did it for first section…and of course you should also animate the triangle… 😉 but that is your task 😉