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

Transition to layout with a single anchor breaks panel behavior #611

Closed
nikita-bor opened this issue Oct 20, 2023 · 2 comments
Closed

Transition to layout with a single anchor breaks panel behavior #611

nikita-bor opened this issue Oct 20, 2023 · 2 comments

Comments

@nikita-bor
Copy link

nikita-bor commented Oct 20, 2023

Description

I'm working on a scenario that requires a transition between two layouts:

class FirstLayout: FloatingPanelLayout {
    let position: FloatingPanelPosition = .bottom
    let initialState: FloatingPanelState = .half
    let anchors: [FloatingPanelState : FloatingPanelLayoutAnchoring] = [
        .full: FloatingPanelLayoutAnchor(absoluteInset: 16.0, edge: .top, referenceGuide: .safeArea),
        .half: FloatingPanelLayoutAnchor(absoluteInset: 262, edge: .top, referenceGuide: .safeArea),
        .tip: FloatingPanelLayoutAnchor(absoluteInset: 44.0, edge: .bottom, referenceGuide: .safeArea)
    ]
}

class SecondLayout: FloatingPanelLayout {
    let position: FloatingPanelPosition = .bottom
    let initialState: FloatingPanelState = .half
    let anchors: [FloatingPanelState : FloatingPanelLayoutAnchoring] = [
        .half: FloatingPanelLayoutAnchor(absoluteInset: 262, edge: .top, referenceGuide: .safeArea)
    ]
 }

Expected behavior

  1. FirstLayout is active and current state is .tip
  2. Set SecondLayout and call fpc.invalidateLayout()
  3. State is .half and despite any attempts to drag the panel, the panel remains in a half state, since it's the only state that's allowed by the currently active SecondLayout

Actual behavior

  1. FirstLayout is active and current state is .tip
  2. Set SecondLayout and call fpc.invalidateLayout()
  3. State is .half. Dragging the panel to the top or to the bottom makes it disappear, almost like it's transitioning to the .tip state from FirstLayout

Steps to reproduce

Code example that reproduces the issue

https://github.com/swasta/FloatingPanelLayoutTransitioning

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-10-20.at.17.11.48.mp4

How do you display panel(s)?

Present modally

How many panels do you displays?

1

Environment

2.8.0

Installation method

CocoaPods

iOS version(s)

iOS 17.0.1

Xcode version

15.0.1

@scenee
Copy link
Owner

scenee commented Nov 4, 2023

Thanks for your report. It looks a bug. I will dive deep this issue later.

scenee added a commit that referenced this issue Nov 4, 2023
* Added a test for the use case, ControllerTests.test_switching_layout()
@scenee
Copy link
Owner

scenee commented Nov 4, 2023

Thanks to your example code, I found the cause of the problem easily. I have fixed it in dbef6a6 commit and then it will be released in v2.8.1 shortly.

Thank you.

@scenee scenee closed this as completed Nov 18, 2023
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

No branches or pull requests

2 participants