Skip to content

Commit

Permalink
Add isAutoApplyEditingStackEnabled to SwiftUICropView (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
shima11 committed Apr 8, 2024
1 parent 1b8f2d4 commit 189f94e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
2 changes: 0 additions & 2 deletions Dev/Sources/SwiftUIDemo/DemoCropView2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ struct DemoCropView2: View {

HStack {
Slider(value: $angle.degrees, in: -45.0...45.0, step: 1)
.disabled(isDragging)
Button(action: {
baselineAngle -= .degrees(90)
}, label: {
Text("Rotate")
})
.disabled(isDragging)
}
.disabled(isDragging)
.padding(24)
Expand Down
11 changes: 0 additions & 11 deletions Sources/BrightroomUI/Shared/Components/Crop/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,6 @@ public final class CropView: UIView, UIScrollViewDelegate {
guideView.willChange = { [weak self] in
guard let self = self else { return }
self.willChangeGuideView()
store.commit {
$0.adjustmentKind = .guide
}
}

guideView.updating = { [weak self] in
guard let self else { return }
guard let currentProposedCrop = store.state.proposedCrop else {
return
}
// updateScrollViewInset(crop: currentProposedCrop)
}

guideView.didChange = { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,21 @@ public struct SwiftUICropView: UIViewControllerRepresentable {

private let stateHandler: @MainActor (Verge.Changes<CropView.State>) -> Void
private let isGuideInteractionEnabled: Bool
private let isAutoApplyEditingStackEnabled: Bool
private let contentInset: UIEdgeInsets?

public init<InsideOverlay: View, OutsideOverlay: View>(
editingStack: EditingStack,
isGuideInteractionEnabled: Bool = true,
isAutoApplyEditingStackEnabled: Bool = false,
contentInset: UIEdgeInsets? = nil,
@ViewBuilder cropInsideOverlay: @escaping (CropView.State.AdjustmentKind?) -> InsideOverlay,
@ViewBuilder cropOutsideOverlay: @escaping (CropView.State.AdjustmentKind?) -> OutsideOverlay,
stateHandler: @escaping @MainActor (Verge.Changes<CropView.State>) -> Void = { _ in }
) {
self.editingStack = editingStack
self.isGuideInteractionEnabled = isGuideInteractionEnabled
self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled
self.contentInset = contentInset
self.cropInsideOverlay = { AnyView(cropInsideOverlay($0)) }
self.cropOutsideOverlay = { AnyView(cropOutsideOverlay($0)) }
Expand All @@ -102,13 +105,15 @@ public struct SwiftUICropView: UIViewControllerRepresentable {
public init(
editingStack: EditingStack,
isGuideInteractionEnabled: Bool = true,
isAutoApplyEditingStackEnabled: Bool = false,
contentInset: UIEdgeInsets? = nil,
stateHandler: @escaping @MainActor (Verge.Changes<CropView.State>) -> Void = { _ in }
) {
self.cropInsideOverlay = nil
self.cropOutsideOverlay = nil
self.editingStack = editingStack
self.isGuideInteractionEnabled = isGuideInteractionEnabled
self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled
self.contentInset = contentInset
self.stateHandler = stateHandler
}
Expand All @@ -122,7 +127,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable {
view = .init(editingStack: editingStack)
}

view.isAutoApplyEditingStackEnabled = true
view.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled
view.isGuideInteractionEnabled = isGuideInteractionEnabled

if let cropInsideOverlay {
Expand Down

0 comments on commit 189f94e

Please sign in to comment.