Skip to content
Open
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
9 changes: 8 additions & 1 deletion Sources/BrightroomUI/Shared/Components/Crop/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public final class CropView: UIView, UIScrollViewDelegate {

public let store: UIStateStore<State, Never>

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.
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InsideOverlay: View, OutsideOverlay: View>(
editingStack: EditingStack,
isPreviewMode: Binding<Bool> = .constant(false),
isGuideInteractionEnabled: Bool = true,
isAutoApplyEditingStackEnabled: Bool = false,
areAnimationsEnabled: Bool = true,
Expand All @@ -96,6 +99,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable {
stateHandler: @escaping @MainActor (Verge.Changes<CropView.State>) -> Void = { _ in }
) {
self.editingStack = editingStack
self._isPreviewMode = isPreviewMode
self.isGuideInteractionEnabled = isGuideInteractionEnabled
self.isAutoApplyEditingStackEnabled = isAutoApplyEditingStackEnabled
self.areAnimationsEnabled = areAnimationsEnabled
Expand All @@ -107,6 +111,7 @@ public struct SwiftUICropView: UIViewControllerRepresentable {

public init(
editingStack: EditingStack,
isPreviewMode: Binding<Bool> = .constant(false),
isGuideInteractionEnabled: Bool = true,
isAutoApplyEditingStackEnabled: Bool = false,
areAnimationsEnabled: Bool = true,
Expand All @@ -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
Expand All @@ -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))
Expand All @@ -151,6 +158,8 @@ public struct SwiftUICropView: UIViewControllerRepresentable {

public func updateUIViewController(_ uiViewController: _PixelEditor_WrapperViewController<CropView>, context: Context) {

uiViewController.bodyView.isPreviewMode = isPreviewMode

if let _rotation {
uiViewController.bodyView.setRotation(_rotation)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Verge
import BrightroomEngine
#endif

final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView {
public final class PhotosCropAspectRatioControl: PixelEditorCodeBasedView {
struct State: Equatable {
enum Direction {
/**
Expand Down Expand Up @@ -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)
Expand All @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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 {
Expand Down