Skip to content

Commit

Permalink
Update SwiftUIBlurryMaskingView (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed Mar 18, 2024
1 parent ca398c0 commit 6cf09f1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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
}


}

0 comments on commit 6cf09f1

Please sign in to comment.