Skip to content

Instantly share code, notes, and snippets.

@Thomvis
Created June 6, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thomvis/dac2327ea253ed2c3ed6bd3dc13a95f2 to your computer and use it in GitHub Desktop.
Save Thomvis/dac2327ea253ed2c3ed6bd3dc13a95f2 to your computer and use it in GitHub Desktop.
Thought it would be nice to create a custom stack implementation. Immediately ran into all kinds of walls.
struct Stack<Item>: View where Item: View {
let items: [Item]
init(@ViewBuilder items: () -> Item) {
fatalError("How to get the views out of the view builder's result (TupleView) into self.items?")
}
var body: some View {
fatalError("How to layout self.items in a Group/ZStack?")
return EmptyView()
}
}
@darknoon
Copy link

You could make your own @_functionBuilder equivalent of ViewBuilder where you can build a type you can peek at. Agree it's a little bogus the way it's all hidden from the outside tho!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment