Skip to content

Commit

Permalink
Update SwiftUIBlurryMaskingView (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed Mar 19, 2024
1 parent 6cf09f1 commit 13ed48a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
10 changes: 8 additions & 2 deletions Dev/Sources/SwiftUIDemo/DemoMaskingView.swift
@@ -1,4 +1,5 @@
import BrightroomEngine
import SwiftUISupport
import BrightroomUI
import SwiftUI

Expand All @@ -14,8 +15,12 @@ struct DemoMaskingView: View {

var body: some View {
VStack {
SwiftUIBlurryMaskingView(editingStack: editingStack)
.blushSize(brushSize)
ZStack {
ViewHost(instantiated: ImagePreviewView(editingStack: editingStack))
SwiftUIBlurryMaskingView(editingStack: editingStack)
.blushSize(brushSize)
.hideBackdropImageView(true)
}

HStack {
Button(action: {
Expand All @@ -34,6 +39,7 @@ struct DemoMaskingView: View {
Text("50")
})
}

}
}

Expand Down
Expand Up @@ -349,7 +349,7 @@ public final class ClassicImageEditViewController: UIViewController {
previewView.isHidden = true

maskingView.isHidden = true
maskingView.isblurryImageViewHidden = true
maskingView.isBlurryImageViewHidden = true

maskingView.isUserInteractionEnabled = false

Expand All @@ -361,7 +361,7 @@ public final class ClassicImageEditViewController: UIViewController {
cropView.isHidden = true
previewView.isHidden = false
maskingView.isHidden = false
maskingView.isblurryImageViewHidden = false
maskingView.isBlurryImageViewHidden = false

maskingView.isUserInteractionEnabled = true

Expand All @@ -373,7 +373,7 @@ public final class ClassicImageEditViewController: UIViewController {
cropView.isHidden = true
previewView.isHidden = false
maskingView.isHidden = true
maskingView.isblurryImageViewHidden = true
maskingView.isBlurryImageViewHidden = true

maskingView.isUserInteractionEnabled = false

Expand All @@ -386,7 +386,7 @@ public final class ClassicImageEditViewController: UIViewController {
previewView.isHidden = false
cropView.isHidden = true
maskingView.isHidden = false
maskingView.isblurryImageViewHidden = false
maskingView.isBlurryImageViewHidden = false

maskingView.isUserInteractionEnabled = false
}
Expand Down
Expand Up @@ -74,7 +74,7 @@ public final class BlurryMaskingView: PixelEditorCodeBasedView, UIScrollViewDele
}
}

public var isblurryImageViewHidden: Bool {
public var isBlurryImageViewHidden: Bool {
get {
blurryImageView.isHidden
}
Expand Down Expand Up @@ -285,6 +285,9 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable {

private var _brushSize: CanvasView.BrushSize?

private var _isBackdropImageViewHidden: Bool?
private var _isBlurryImageViewHidden: Bool?

public init(
editingStack: EditingStack
) {
Expand All @@ -305,14 +308,33 @@ public struct SwiftUIBlurryMaskingView: UIViewControllerRepresentable {
if let _brushSize {
uiViewController.bodyView.setBrushSize(_brushSize)
}
if let _isBackdropImageViewHidden {
uiViewController.bodyView.isBackdropImageViewHidden = _isBackdropImageViewHidden
}
if let _isBlurryImageViewHidden {
uiViewController.bodyView.isBlurryImageViewHidden = _isBlurryImageViewHidden
}
}

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

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

public func hideBackdropImageView(_ isBackdropImageViewHidden: Bool) -> Self {

var modified = self
modified._isBackdropImageViewHidden = isBackdropImageViewHidden
return modified
}

public func hideBlurryImageView(_ isBlurryImageViewHidden: Bool) -> Self {

var modified = self
modified._isBlurryImageViewHidden = isBlurryImageViewHidden
return modified
}

}

0 comments on commit 13ed48a

Please sign in to comment.