diff --git a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift index e4ca4d02..4d1b5bf9 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift @@ -75,6 +75,13 @@ public final class CropView: UIView, UIScrollViewDelegate { public let store: UIStateStore + public var isPreviewMode: Bool = false { + didSet { + guideView.isHidden = isPreviewMode + scrollView.isUserInteractionEnabled = !isPreviewMode + } + } + /** A Boolean value that indicates whether the guide is interactive. If false, cropping adjustment is available only way from scrolling image-view. @@ -1086,7 +1093,7 @@ extension CropView { var remainingScroll: UIEdgeInsets { - guard let crop = store.state.proposedCrop else { + guard let crop = store.state.proposedCrop else { return .zero } diff --git a/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift index 0b71237a..803c98dc 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/SwiftUICropView.swift @@ -84,9 +84,12 @@ public struct SwiftUICropView: UIViewControllerRepresentable { private let isAutoApplyEditingStackEnabled: Bool private let areAnimationsEnabled: Bool private let contentInset: UIEdgeInsets? + + @Binding var isPreviewMode: Bool public init( editingStack: EditingStack, + isPreviewMode: Binding = .constant(false), isGuideInteractionEnabled: Bool = true, isAutoApplyEditingStackEnabled: Bool = false, areAnimationsEnabled: Bool = true, @@ -96,6 +99,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { stateHandler: @escaping @MainActor (Verge.Changes) -> Void = { _ in } ) { self.editingStack = editingStack + self._isPreviewMode = isPreviewMode self.isGuideInteractionEnabled = isGuideInteractionEnabled self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled self.areAnimationsEnabled = areAnimationsEnabled @@ -107,6 +111,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { public init( editingStack: EditingStack, + isPreviewMode: Binding = .constant(false), isGuideInteractionEnabled: Bool = true, isAutoApplyEditingStackEnabled: Bool = false, areAnimationsEnabled: Bool = true, @@ -116,6 +121,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { self.cropInsideOverlay = nil self.cropOutsideOverlay = nil self.editingStack = editingStack + self._isPreviewMode = isPreviewMode self.isGuideInteractionEnabled = isGuideInteractionEnabled self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled self.areAnimationsEnabled = areAnimationsEnabled @@ -135,6 +141,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable { view.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled view.isGuideInteractionEnabled = isGuideInteractionEnabled view.areAnimationsEnabled = areAnimationsEnabled + view.isPreviewMode = isPreviewMode if let cropInsideOverlay { view.setCropInsideOverlay(CropView.SwiftUICropInsideOverlay(content: cropInsideOverlay)) @@ -151,6 +158,8 @@ public struct SwiftUICropView: UIViewControllerRepresentable { public func updateUIViewController(_ uiViewController: _PixelEditor_WrapperViewController, context: Context) { + uiViewController.bodyView.isPreviewMode = isPreviewMode + if let _rotation { uiViewController.bodyView.setRotation(_rotation) } diff --git a/Sources/BrightroomUI/builtin/PhotosCrop/PhotosCropAspectRatioControl.swift b/Sources/BrightroomUI/builtin/PhotosCrop/PhotosCropAspectRatioControl.swift index aa5ebdce..6ed8dca7 100644 --- a/Sources/BrightroomUI/builtin/PhotosCrop/PhotosCropAspectRatioControl.swift +++ b/Sources/BrightroomUI/builtin/PhotosCrop/PhotosCropAspectRatioControl.swift @@ -28,7 +28,7 @@ import Verge import BrightroomEngine #endif -final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView { +public final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView { struct State: Equatable { enum Direction { /** @@ -110,14 +110,14 @@ final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView { } } - struct Handlers { + public struct Handlers { - var didSelectAspectRatio: (PixelAspectRatio) -> Void = { _ in } - var didSelectFreeform: () -> Void = {} + public var didSelectAspectRatio: (PixelAspectRatio) -> Void = { _ in } + public var didSelectFreeform: () -> Void = {} } - var handlers: Handlers = .init() + public var handlers: Handlers = .init() private let horizontalButton = AspectRatioDirectionButton(direction: .horizontal) private let verticalButton = AspectRatioDirectionButton(direction: .vertical) @@ -134,7 +134,7 @@ final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView { private var isSupressingHandlers = false private let localizedStrings: PhotosCropViewController.LocalizedStrings - init( + public init( originalAspectRatio: PixelAspectRatio, localizedStrings: PhotosCropViewController.LocalizedStrings ) { diff --git a/Sources/BrightroomUIPhotosCrop/PhotosCropRotating/PhotosCropRotating.swift b/Sources/BrightroomUIPhotosCrop/PhotosCropRotating/PhotosCropRotating.swift index ab341102..ac913ab0 100644 --- a/Sources/BrightroomUIPhotosCrop/PhotosCropRotating/PhotosCropRotating.swift +++ b/Sources/BrightroomUIPhotosCrop/PhotosCropRotating/PhotosCropRotating.swift @@ -51,7 +51,7 @@ public struct PhotosCropRotating: View { } } - @StateObject var editingStack: EditingStack + var editingStack: EditingStack @State private var rotation: EditingCrop.Rotation? @State private var adjustmentAngle: EditingCrop.AdjustmentAngle? @@ -67,7 +67,7 @@ public struct PhotosCropRotating: View { public init( editingStack: @escaping () -> EditingStack ) { - self._editingStack = .init(wrappedValue: editingStack()) + self.editingStack = editingStack() } private var isLoading: Bool {