Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open up CropViewController for inhertiance. #274

Merged
merged 4 commits into from
Feb 5, 2023

Conversation

vanniktech
Copy link
Collaborator

References #270

My main goal is to have my own version of CropViewController which behaves a bit different as the actions are in the navigation bar. So all of the set up code can go into its own Controller. Also in my own ViewController I'd also link my features together and implement other interfaces that belong to the image editing section.

@guoyingtao
Copy link
Owner

guoyingtao commented Feb 4, 2023

If you want that Mantis creates an instance of a subclass CropViewController, maybe we can add an API like below

public func cropViewController<T: CropViewController>(image: UIImage,
                               config: Mantis.Config = Mantis.Config(),
                               cropToolbar: CropToolbarProtocol = CropToolbar(frame: .zero)) -> T {
    let cropViewController = T(config: config)
    cropViewController.cropView = buildCropView(with: image, and: config.cropViewConfig)
    cropViewController.cropToolbar = cropToolbar
    return cropViewController
}

@vanniktech
Copy link
Collaborator Author

Do you want it like this?

Copy link
Owner

@guoyingtao guoyingtao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
I added a couple of more comments.

Sources/Mantis/Mantis.swift Outdated Show resolved Hide resolved
Example/EmbeddedCropViewController.swift Outdated Show resolved Hide resolved
@guoyingtao
Copy link
Owner

@vanniktech
Would you mind also updating README and add an example to show how to create a subclass of CropViewController since we add a new API for it.

@vanniktech
Copy link
Collaborator Author

Like this?

```swift
let cropViewController: CustomViewController = Mantis.cropViewController(image: image, config: config)
```

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!
Thanks for adding this 👍

@vanniktech
Copy link
Collaborator Author

Pulled this already into my project and it has everything I need!

Screen Shot 2023-02-04 at 17 57 33

@guoyingtao
Copy link
Owner

guoyingtao commented Feb 4, 2023

Hi @vanniktech
Can you also address this issue , then I will approve the PR.

@vanniktech
Copy link
Collaborator Author

Oh yes! I didn't see that comment.

@guoyingtao guoyingtao merged commit cdeafcd into master Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants