How to properly inspect SwiftUI View Tree?

465 Views Asked by At

The problem I'm trying to solve is quite similar to reimplementing a part of List.

So for example I have this:

struct MyList<Content: View>: View {
    
    var content: Content
    
    init(@ViewBuilder content: @escaping () -> Content) {
        self.content = content()
    }
    
    var body: some View {
        content
    }
}

Here my content can be a Section, a View or a TupleView composed by Sections or others Views, or even nested ForEachs (so others Sections). How can I flatMap the content to a simple array of Sections?

0

There are 0 best solutions below