guoyingtao / Mantis

An iOS Image cropping library, which mimics the Photo App written in Swift.
MIT License
921 stars 183 forks source link

Add delegate methods to notify that CropView became resettable #316

Closed xinatanil closed 1 year ago

xinatanil commented 1 year ago

I'm building an embedded version of the CropViewController with my own overlay UI. To my surprise, there was no easy way for me to activate/deactivate "reset" button. While CropViewDelegate provides the necessary methods, accessing it is impossible (or I didn't figure it out). The most simple solution, like subclassing CropViewController and overriding "didBecomeResettable" is impossible because "extension CropViewController: CropViewDelegate" is not public.

The only solution I see right now is to fork the repo and manually add necessary methods to CropViewControllerDelegate. Is there a simpler and more elegant way?

guoyingtao commented 1 year ago

@xinatanil Do you mean you want to provide two status active/deactivate for reset button? The current logic is to hide/show reset button when checking if it is resettable.

xinatanil commented 1 year ago

Yes, something like that via KVO or delegate method. For my custom UI I'd like to hide the reset button when it's not needed.

guoyingtao commented 1 year ago

@xinatanil So do you mean you want to set your own icon for reset button?

xinatanil commented 1 year ago

No, I want a way for me to know that reset button has been activated/deactivated, so that I could disable my own custom UI elements. Currently, I see no easy way for that.

guoyingtao commented 1 year ago

@xinatanil For activated status, you can use delegate function cropViewControllerDidImageTransformed. For deactivated status, I can add a new delegate function for it.

xinatanil commented 1 year ago

That'd be great! Something like func cropViewController(_ cropViewController: CropViewController, didBecomeResettable resettable: Bool) would be amazing

guoyingtao commented 1 year ago

@xinatanil Please check #317 to see if it works for you, then I can make a new release later.

xinatanil commented 1 year ago

Looks fantastic! Thank you for a quick response!

guoyingtao commented 1 year ago

@xinatanil Just released Mantis 2.12.0 for this feature. Please have a try.