ivanvorobei / SPLarkController

Custom transition between controllers. Settings controller for your iOS app.
https://opensource.ivanvorobei.io
MIT License
988 stars 47 forks source link

Any way to change height after presenting? #5

Closed danielVebman closed 5 years ago

danielVebman commented 5 years ago

Although this is not part of the current implementation, would you have any suggestions on how to change the view controller's height after it has been presented?

An example use case for this behavior would be a settings view controller with a textfield which moves up when the keyboard appears.

ivanvorobei commented 5 years ago

For now no way change height after presentation. But I am try do it in next version. Many users ask about it.

danielVebman commented 5 years ago

Do you expect to add it sometime soon, or is might there be some kind of maybe imperfect workaround for the meantime? I would love to use your beautifully done framework in the app I’m currently developing.

ivanvorobei commented 5 years ago

Now I am develop it for my app Debt: https://itunes.apple.com/app/id1446635818

For start I am added dynamic height in app.

danielVebman commented 5 years ago

That looks very good! When do you expect to merge your enhancement with the main SPLarkController branch?

ivanvorobei commented 5 years ago

I am try do it in ‘June’.

danielVebman commented 5 years ago

Awesome I’ll keep an eye out!

danielVebman commented 5 years ago

Hi! Do you have any estimate as to when the enhancement might be ready?

danielVebman commented 5 years ago

I did the enhancement myself and published it in my repository, here. The change is actually quite simple. In SPLarkPresentationController, I added:

/// update the current height of the controller
public func updateHeight(_ newHeight: CGFloat) {
    guard let containerView = containerView else { return }

    UIView.animate(
        withDuration: 0.45,
        delay: 0,
        usingSpringWithDamping: 1,
        initialSpringVelocity: 1,
        options: [.curveEaseOut, .allowUserInteraction],
        animations: {
            self.presentedView?.frame.origin.y = containerView.frame.height - newHeight
            self.presentedView?.frame.size.height = newHeight
            self.snapshotViewContainer.transform = CGAffineTransform(translationX: 0, y: -newHeight)
        }
    ) { _ in
        // I simplified `self.height` into a { get set } variable that basically keeps track of state
        self.height = newHeight 
    }
}

The version in my repository also contains some other simplifications (although the access control is nonexistent).

ivanvorobei commented 5 years ago

@danielVebman you can create simple project with changeable height and send me for test?

danielVebman commented 5 years ago

@ivanvorobei, I added a very simple sample project here.

ivanvorobei commented 5 years ago

@danielVebman thanks for your research and time! You do cool job! I am added changeable height in new version 1.1. Also I am added example project.

I now seem to understand what I had to offer to make you a PR, sorry if this was important to you.

Many thanks!