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

Push to other viewcontroller from BSImagePicker #260

Closed
cliff357 opened this issue Apr 29, 2020 · 12 comments
Closed

Push to other viewcontroller from BSImagePicker #260

cliff357 opened this issue Apr 29, 2020 · 12 comments

Comments

@cliff357
Copy link

Sorry, still have some question on #259,

How can i push to other viewcontroller from BSImagePicker

@mikaoj
Copy link
Owner

mikaoj commented Apr 29, 2020

It was supposed to work like that, if it doesn't it's a bug that will have to be looked into.
Feel free to do so :)

@mikaoj
Copy link
Owner

mikaoj commented Apr 29, 2020

The problem can likely be fixed in ZoomTransitionDelegate.swift by adding a check that to/from view controllers are the expected AssetsViewController/PreviewViewController. If not don't try to apply the expand/shrink animation.

@cliff357
Copy link
Author

Thanks for quick reply, but how can I fix it?
Would you mind to help update?

@cliff357
Copy link
Author

Nah, I am now watching ZoomTransitionDelegate, hope I can do something on this issue :D

@mikaoj
Copy link
Owner

mikaoj commented Apr 29, 2020

  1. Fork this repo.
  2. Clone your fork to your computer.
  3. Open BSImagePicker.xcworkspace.
  4. Do what I said in my previous message.
  5. Test that it works as expected.
  6. Commit.
  7. Push.
  8. Create a pull-request from your fork to this repo.

Have a look at ZoomTransitionDelegate.swift
Specifically this part:

extension ZoomTransitionDelegate: UINavigationControllerDelegate {
    public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        switch operation {
        case .none:
            return nil
        case .push:
            return expandAnimator
        case .pop:
            return shrinkAnimator
        @unknown default:
            return nil
        }
    }
    
    public func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        if animationController === expandAnimator {
            return interactionController
        } else {
            return nil
        }
    }
}

I can probably fix it sometime during the week - but if you or anyone else want some easy open-source karma this is up for grabs until then :)

@cliff357
Copy link
Author

woooooooooow, thank you very much

@cliff357
Copy link
Author

I will try your suggestion, but I do not really trust my understanding of Transition, I think i better wait for your fix haha

@mikaoj
Copy link
Owner

mikaoj commented Apr 29, 2020

Something like this might work. With reservation for syntax errors and typos. Just need to make sure that that expand/shrink animation still work with images, videos and live images. And also that what you want to do - push another view controller when pressing done works.

extension ZoomTransitionDelegate: UINavigationControllerDelegate {
    public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        if operation == .push, toVC is PreviewViewController {
            return expandAnimator
        } else if operation == .pop, fromVC is PreviewViewController {
            return shrinkAnimator
        } else {
            return nil
        }
    }
    
    public func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        if animationController === expandAnimator {
            return interactionController
        } else {
            return nil
        }
    }
}

@cliff357
Copy link
Author

Thanks
But may I ask how to make sure the animation still works with images, videos, and live images?

Sorry for my bad English.

@mikaoj
Copy link
Owner

mikaoj commented Apr 29, 2020

Run the example app on your phone.
Long press on an image - is there a nice animation that zooms the image in/out? Great it works!
Do the same for videos and live photos :)

@cliff357
Copy link
Author

cliff357 commented Apr 29, 2020

ohhhhhhhhhhhhhhh, thank you very much
tried this fix, there are some issue,

2020-04-29-35731

@mikaoj
Copy link
Owner

mikaoj commented Apr 30, 2020

Should be fixed in version 3.1.6 - try it out! :)

@mikaoj mikaoj closed this as completed Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants