Post #1249913
2026-03-31 12:50 UTC
@kylebshr Had to get a code snippet for you, but here's a real world (though oversimplified) example of what I mean, based no how SwiftUI provides multiple initializers for containers like this. https://gist.github.com/mergesort/085eb9986a64f904c17d3c452877d5f9
Replies (2)
-
@kylebshr@mastodon.social 2026-03-31 14:45
@mergesort how would you feel if headerView was optional, and instead of where == EmptyView you used where == Never and assigned nil? Ignoring slots for a moment, I think this is a slightly better design that accomplishes the same thing, because internally you might want to adjust layout based on headerViews presence, e.g., in the body: if let headerView { Spacer() headerView }
-
@kylebshr@mastodon.social 2026-03-31 15:01
@mergesort replied on the gist with how Slots does exactly this!