SwiftUIcon icon indicating copy to clipboard operation
SwiftUIcon copied to clipboard

Add canvas environment

Open Tunous opened this issue 2 years ago • 0 comments

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
    }
}

Tunous avatar May 01 '22 18:05 Tunous