I'm trying to replicate the some of the behavior of List. I specifically want to add dividers between all elements. My current code looks like this
Customlist {
Text("...")
Divider()
Text("...")
Divider()
Text("...")
}
I want to remove the dividers and just provide the text nodes, but I have no idea how to inject the dividers automatically in Customlist. So the usage I want looks like this:
Customlist {
Text("...")
Text("...")
Text("...")
}
I assume Customlist would have to look something like this (but I don't know how to implement body):
Customlist<Content: View>: View {
var content: Content
init(@ViewBuilder _ b: () -> Content) {
self.content = b()
}
var body: some View {
// Something using self.content here
}
}