Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SwiftUIBlurryMaskingView #227

Merged
merged 1 commit into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 24 additions & 1 deletion Dev/Sources/SwiftUIDemo/DemoMaskingView.swift
Expand Up @@ -6,12 +6,35 @@ struct DemoMaskingView: View {

@ObjectEdge var editingStack: EditingStack

@State var brushSize: CanvasView.BrushSize = .point(30)

init(editingStack: @escaping () -> EditingStack) {
self._editingStack = .init(wrappedValue: editingStack())
}

var body: some View {
SwiftUIBlurryMaskingView(editingStack: editingStack)
VStack {
SwiftUIBlurryMaskingView(editingStack: editingStack)
.blushSize(brushSize)

HStack {
Button(action: {
brushSize = .point(10)
}, label: {
Text("10")
})
Button(action: {
brushSize = .point(30)
}, label: {
Text("30")
})
Button(action: {
brushSize = .point(50)
}, label: {
Text("50")
})
}
}
}

}
Expand Down
Expand Up @@ -283,6 +283,8 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable {

private let editingStack: EditingStack

private var _brushSize: CanvasView.BrushSize?

public init(
editingStack: EditingStack
) {
Expand All @@ -300,6 +302,17 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable {

public func updateUIViewController(_ uiViewController: _PixelEditor_WrapperViewController<BlurryMaskingView>, context: Context) {

if let _brushSize {
uiViewController.bodyView.setBrushSize(_brushSize)
}
}

public func blushSize(_ brushSize: CanvasView.BrushSize?) -> Self {

var modified = self
modified._brushSize = brushSize
return modified
}


}