Created
December 22, 2023 10:02
-
-
Save shaps80/f1783efea58c77dce2f0abaf548ec77f to your computer and use it in GitHub Desktop.
Enables the creation of custom container views in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
public extension View { | |
func variadic<R: View>(@ViewBuilder _ transform: @escaping (_VariadicView.Children) -> R) -> some View { | |
_VariadicView.Tree(Helper(transform: transform)) { self } | |
} | |
} | |
private struct Helper<R: View>: _VariadicView.MultiViewRoot { | |
var transform: (_VariadicView.Children) -> R | |
func body(children: _VariadicView.Children) -> some View { | |
transform(children) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment