Allow animated FloatingPanelController relayout
Hello,
This PR introduces two new methods on FloatingPanelController: beginUpdateLayout(), and endUpdateLayout(). They extend the existing updateLayout() method, and allow applications to transition from one set of constraints to another without facing undesired "Unable to simultaneously satisfy constraints" errors.
My understanding is that those errors happen when the parent controller of the panel wants to change height, because of conflicts with the hard FloatingPanelLayoutAdapter.heightConstraint.
For example, this happens when the panel is embedded in a view controller which is not always fullscreen.
This PR lets the host application play a three-steps game:
- Remove the hard FloatingPanelLayoutAdapter.heightConstraint constraint.
- Perform custom relayout, without error.
- Reset the floating panel layout with an updated FloatingPanelLayoutAdapter.heightConstraint.
Usage:
func updateLayoutOfPanelParent() {
// 1. Begin panel update
self.panel.beginUpdateLayout()
UIView.animate(withDuration: 0.25, animations: {
// 2. Update layout of panel's parent
...
// 3. End panel update
self.panel.endUpdateLayout()
})
}
This PR may also address #160, but I'm not sure.
They extend the existing updateLayout() method, and allow applications to transition from one set of constraints to another without facing undesired "Unable to simultaneously satisfy constraints" errors.
Sounds great! I will check this more detail later.
Hello @SCENEE. The pull request has been updated with the most recent changes from version 1.6.0.
Please tell me if you'd like some tests to be added, or if you wonder how to trigger the constraint issues that this PR is solving.
you wonder how to trigger the constraint issues that this PR is solving.
Yes, I would! And could you please check we're able to use the new APIs like this?
func updateLayoutOfPanelParent() {
UIView.animate(withDuration: 0.25, animations: {
// 1. Begin panel update
self.panel.beginUpdateLayout()
// 2. Update layout of panel’s parent
…
// 3. End panel update
self.panel.endUpdateLayout()
})
}
Sure, @SCENEE, I will 👍