From ddaf92300a92e0ec2a0a3eea1b2c7bfc74e8c435 Mon Sep 17 00:00:00 2001 From: shima11 Date: Mon, 8 Apr 2024 18:25:59 +0900 Subject: [PATCH 1/3] update --- Dev/Sources/SwiftUIDemo/DemoCropView2.swift | 4 +--- .../Shared/Components/Crop/CropView.swift | 14 ++------------ .../Shared/Components/Crop/SwiftUICropView.swift | 7 ++++++- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Dev/Sources/SwiftUIDemo/DemoCropView2.swift b/Dev/Sources/SwiftUIDemo/DemoCropView2.swift index 535d1c59..cab206cd 100644 --- a/Dev/Sources/SwiftUIDemo/DemoCropView2.swift +++ b/Dev/Sources/SwiftUIDemo/DemoCropView2.swift @@ -80,15 +80,13 @@ 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) +// .disabled(isDragging) .padding(24) } diff --git a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift index 070e3e16..dd45c9ea 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift @@ -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 @@ -946,7 +935,8 @@ extension CropView { } } - private func record() { + private func record(_ line: String = #function) { + print("### record:", line) store.commit { state in guard let crop = state.proposedCrop else { diff --git a/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift index 4c938005..7577a53a 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift @@ -81,11 +81,13 @@ public struct SwiftUICropView: UIViewControllerRepresentable { private let stateHandler: @MainActor (Verge.Changes) -> Void private let isGuideInteractionEnabled: Bool + private let isAutoApplyEditingStackEnabled: Bool private let contentInset: UIEdgeInsets? public init( 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, @@ -93,6 +95,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { ) { self.editingStack = editingStack self.isGuideInteractionEnabled = isGuideInteractionEnabled + self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled self.contentInset = contentInset self.cropInsideOverlay = { AnyView(cropInsideOverlay($0)) } self.cropOutsideOverlay = { AnyView(cropOutsideOverlay($0)) } @@ -102,6 +105,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { public init( editingStack: EditingStack, isGuideInteractionEnabled: Bool = true, + isAutoApplyEditingStackEnabled: Bool = false, contentInset: UIEdgeInsets? = nil, stateHandler: @escaping @MainActor (Verge.Changes) -> Void = { _ in } ) { @@ -109,6 +113,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { self.cropOutsideOverlay = nil self.editingStack = editingStack self.isGuideInteractionEnabled = isGuideInteractionEnabled + self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled self.contentInset = contentInset self.stateHandler = stateHandler } @@ -122,7 +127,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { view = .init(editingStack: editingStack) } - view.isAutoApplyEditingStackEnabled = true + view.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled view.isGuideInteractionEnabled = isGuideInteractionEnabled if let cropInsideOverlay { From a1fbd2ba39f038a870880970a7254cd67bd76107 Mon Sep 17 00:00:00 2001 From: shima11 Date: Mon, 8 Apr 2024 18:49:33 +0900 Subject: [PATCH 2/3] update --- Sources/BrightroomUI/Shared/Components/Crop/CropView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift index dd45c9ea..f26d1102 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift @@ -935,8 +935,7 @@ extension CropView { } } - private func record(_ line: String = #function) { - print("### record:", line) + private func record() { store.commit { state in guard let crop = state.proposedCrop else { From a002e5b356e5c081aedc353511d66884850aac85 Mon Sep 17 00:00:00 2001 From: shima11 Date: Mon, 8 Apr 2024 18:50:19 +0900 Subject: [PATCH 3/3] update --- Dev/Sources/SwiftUIDemo/DemoCropView2.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dev/Sources/SwiftUIDemo/DemoCropView2.swift b/Dev/Sources/SwiftUIDemo/DemoCropView2.swift index cab206cd..1bff43f9 100644 --- a/Dev/Sources/SwiftUIDemo/DemoCropView2.swift +++ b/Dev/Sources/SwiftUIDemo/DemoCropView2.swift @@ -86,7 +86,7 @@ struct DemoCropView2: View { Text("Rotate") }) } -// .disabled(isDragging) + .disabled(isDragging) .padding(24) }