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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isAutoApplyEditingStackEnabled to SwiftUICropView #236

Merged
merged 3 commits into from
Apr 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading