Skip to content

Conversation

Tunous
Copy link

@Tunous Tunous commented May 1, 2022

This pull request adds a convenience canvas environment value. It can be used to avoid having to pass canvas to subviews through parameters. Instead it will now be possible to directly get it from environment. This is useful for icons that consist of mutliple subviews.

Example usage

struct Icon: View {
    var body: some View {
        IconStack { canvas in
            // Main content that somewhere uses subview
            SubView()
        }
    }
}

struct SubView: View {
    @Environment(\.canvas) private var canvas

    var body: some View {
        // Use canvas
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant