Skip to content

Commit

Permalink
fix: use optional CropToolbarProtocol for CropToolbarDelegate (#255)
Browse files Browse the repository at this point in the history
Normally if a user want a custom crop tool bar, the tool bar need to delegate operations to CropViewController. For some users who do not want the attached tool bar but still want to use these delegate functions, there is no need to pass a CropToolbarProtocol instance. So I change it to optional
  • Loading branch information
guoyingtao committed Jan 28, 2023
1 parent 63911f8 commit 46a3af0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions Sources/Mantis/CropViewController/CropViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,47 +376,47 @@ extension CropViewController: CropViewDelegate {
}

extension CropViewController: CropToolbarDelegate {
public func didSelectHorizontallyFlip(_ cropToolbar: CropToolbarProtocol) {
public func didSelectHorizontallyFlip(_ cropToolbar: CropToolbarProtocol? = nil) {
handleHorizontallyFlip()
}

public func didSelectVerticallyFlip(_ cropToolbar: CropToolbarProtocol) {
public func didSelectVerticallyFlip(_ cropToolbar: CropToolbarProtocol? = nil) {
handleVerticallyFlip()
}

public func didSelectCancel(_ cropToolbar: CropToolbarProtocol) {
public func didSelectCancel(_ cropToolbar: CropToolbarProtocol? = nil) {
handleCancel()
}

public func didSelectCrop(_ cropToolbar: CropToolbarProtocol) {
public func didSelectCrop(_ cropToolbar: CropToolbarProtocol? = nil) {
handleCrop()
}

public func didSelectCounterClockwiseRotate(_ cropToolbar: CropToolbarProtocol) {
public func didSelectCounterClockwiseRotate(_ cropToolbar: CropToolbarProtocol? = nil) {
handleRotate(withRotateType: .counterClockwise)
}

public func didSelectClockwiseRotate(_ cropToolbar: CropToolbarProtocol) {
public func didSelectClockwiseRotate(_ cropToolbar: CropToolbarProtocol? = nil) {
handleRotate(withRotateType: .clockwise)
}

public func didSelectReset(_ cropToolbar: CropToolbarProtocol) {
public func didSelectReset(_ cropToolbar: CropToolbarProtocol? = nil) {
handleReset()
}

public func didSelectSetRatio(_ cropToolbar: CropToolbarProtocol) {
public func didSelectSetRatio(_ cropToolbar: CropToolbarProtocol? = nil) {
handleSetRatio()
}

public func didSelectRatio(_ cropToolbar: CropToolbarProtocol, ratio: Double) {
public func didSelectRatio(_ cropToolbar: CropToolbarProtocol? = nil, ratio: Double) {
setFixedRatio(ratio)
}

public func didSelectFreeRatio(_ cropToolbar: CropToolbarProtocol) {
public func didSelectFreeRatio(_ cropToolbar: CropToolbarProtocol? = nil) {
setFreeRatio()
}

public func didSelectAlterCropper90Degree(_ cropToolbar: CropToolbarProtocol) {
public func didSelectAlterCropper90Degree(_ cropToolbar: CropToolbarProtocol? = nil) {
handleAlterCropper90Degree()
}
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/Mantis/Protocols/CropToolbarProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import UIKit
Inside Mantis, CropViewController implements all delegate methods
*/
public protocol CropToolbarDelegate: AnyObject {
func didSelectCancel(_ cropToolbar: CropToolbarProtocol)
func didSelectCrop(_ cropToolbar: CropToolbarProtocol)
func didSelectCounterClockwiseRotate(_ cropToolbar: CropToolbarProtocol)
func didSelectClockwiseRotate(_ cropToolbar: CropToolbarProtocol)
func didSelectReset(_ cropToolbar: CropToolbarProtocol)
func didSelectSetRatio(_ cropToolbar: CropToolbarProtocol)
func didSelectRatio(_ cropToolbar: CropToolbarProtocol, ratio: Double)
func didSelectFreeRatio(_ cropToolbar: CropToolbarProtocol)
func didSelectAlterCropper90Degree(_ cropToolbar: CropToolbarProtocol)
func didSelectHorizontallyFlip(_ cropToolbar: CropToolbarProtocol)
func didSelectVerticallyFlip(_ cropToolbar: CropToolbarProtocol)
func didSelectCancel(_ cropToolbar: CropToolbarProtocol?)
func didSelectCrop(_ cropToolbar: CropToolbarProtocol?)
func didSelectCounterClockwiseRotate(_ cropToolbar: CropToolbarProtocol?)
func didSelectClockwiseRotate(_ cropToolbar: CropToolbarProtocol?)
func didSelectReset(_ cropToolbar: CropToolbarProtocol?)
func didSelectSetRatio(_ cropToolbar: CropToolbarProtocol?)
func didSelectRatio(_ cropToolbar: CropToolbarProtocol?, ratio: Double)
func didSelectFreeRatio(_ cropToolbar: CropToolbarProtocol?)
func didSelectAlterCropper90Degree(_ cropToolbar: CropToolbarProtocol?)
func didSelectHorizontallyFlip(_ cropToolbar: CropToolbarProtocol?)
func didSelectVerticallyFlip(_ cropToolbar: CropToolbarProtocol?)
}

public protocol CropToolbarIconProvider: AnyObject {
Expand Down

0 comments on commit 46a3af0

Please sign in to comment.