@@ -44,6 +44,11 @@ public typealias CropViewCroppingStyle = TOCropViewCroppingStyle
4444// ------------------------------------------------
4545
4646@MainActor @objc public protocol CropViewControllerDelegate : NSObjectProtocol {
47+ /**
48+ Called when the user hits the Done button.
49+ */
50+ @objc optional func cropViewControllerDidTapDone( _ cropViewController: CropViewController )
51+
4752 /**
4853 Called when the user has committed the crop action, and provides
4954 just the cropping rectangle.
@@ -319,7 +324,15 @@ open class CropViewController: UIViewController, TOCropViewControllerDelegate {
319324 set { toCropViewController. allowedAspectRatios = newValue }
320325 get { return toCropViewController. allowedAspectRatios }
321326 }
322-
327+
328+ /**
329+ Called when the user hits the Done button.
330+ */
331+ public var onDidTapDone : ( ( ) -> Void ) ? {
332+ set { toCropViewController. onDidTapDone = newValue }
333+ get { return toCropViewController. onDidTapDone }
334+ }
335+
323336 /**
324337 When the user hits cancel, or completes a
325338 UIActivityViewController operation, this block will be called,
@@ -650,13 +663,21 @@ extension CropViewController {
650663
651664 fileprivate func setUpDelegateHandlers( ) {
652665 guard let delegate = self . delegate else {
666+ onDidTapDone = nil
653667 onDidCropToRect = nil
654668 onDidCropImageToRect = nil
655669 onDidCropToCircleImage = nil
656670 onDidFinishCancelled = nil
657671 return
658672 }
659-
673+
674+ if delegate. responds ( to: #selector( ( any CropViewControllerDelegate ) . cropViewControllerDidTapDone ( _: ) ) ) {
675+ self . onDidTapDone = { [ weak self] in
676+ guard let self else { return }
677+ delegate. cropViewControllerDidTapDone ? ( self )
678+ }
679+ }
680+
660681 if delegate. responds ( to: #selector( ( any CropViewControllerDelegate ) . cropViewController ( _: didCropImageToRect: angle: ) ) ) {
661682 self . onDidCropImageToRect = { [ weak self] rect, angle in
662683 guard let strongSelf = self else { return }
0 commit comments