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

Any way to change height after presenting? #5

Closed
danielVebman opened this issue May 29, 2019 · 11 comments
Closed

Any way to change height after presenting? #5

danielVebman opened this issue May 29, 2019 · 11 comments
Labels
enhancement New feature or request

Comments

@danielVebman
Copy link

danielVebman commented May 29, 2019

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
Copy link
Owner

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

@ivanvorobei ivanvorobei added the enhancement New feature or request label May 29, 2019
@danielVebman
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@ivanvorobei
Copy link
Owner

I am try do it in ‘June’.

@danielVebman
Copy link
Author

Awesome I’ll keep an eye out!

@danielVebman
Copy link
Author

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

@danielVebman
Copy link
Author

danielVebman commented Jul 4, 2019

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
Copy link
Owner

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

@danielVebman
Copy link
Author

danielVebman commented Jul 5, 2019

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

@ivanvorobei
Copy link
Owner

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants