Skip to content

Conversation

@groue
Copy link

@groue groue commented May 21, 2019

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:

  1. Remove the hard FloatingPanelLayoutAdapter.heightConstraint constraint.
  2. Perform custom relayout, without error.
  3. 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.

@scenee
Copy link
Owner

scenee commented Jun 1, 2019

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.

# Conflicts:
#	Framework/Sources/FloatingPanelLayout.swift
@groue
Copy link
Author

groue commented Jun 6, 2019

Hello @scenee. The pull request has been updated with the most recent changes from version 1.6.0.

@groue
Copy link
Author

groue commented Jun 6, 2019

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.

@scenee
Copy link
Owner

scenee commented Jun 6, 2019

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()
    })
}

@groue
Copy link
Author

groue commented Jun 7, 2019

Sure, @scenee, I will 👍

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.

3 participants