scenee / FloatingPanel

A clean and easy-to-use floating panel UI component for iOS
MIT License
5.61k stars 510 forks source link

Dynamic resizing #650

Open DolganovAnton13 opened 1 month ago

DolganovAnton13 commented 1 month ago

Description

I support dynamic font resizing. And I want the panel to be able to dynamically resize, too.

Expected behavior

When changing the settings (increasing or decreasing the font), the panel changes its size.

Actual behavior

The panel does not change its size.

Steps to reproduce

Show the panel on the screen ![Simulator Screenshot - new iPhone 15 - 2024-10-16 at 23 11 12](https://github.com/user-attachments/assets/1eb1b8af-5cb6-43a3-b84b-be87527b4848)
Minimize the application. Open the settings (Large Text) and change the size. ![image](https://github.com/user-attachments/assets/cdbfd463-8620-4154-bb29-1e7c503dc1ef)
Deploy the application. The size of the content should change, but the panel does not. ![image](https://github.com/user-attachments/assets/c04ea1f7-326a-41dc-abd9-bce95045125b)

Code example that reproduces the issue

I tried calling the invalidateLayout and invalidateIntrinsicContentSize methods, but it didn't help

class MyFPC: FloatingPanelController {
  override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    invalidateLayout()
    surfaceView.invalidateIntrinsicContentSize()
  }
}

How do you display panel(s)?

How many panels do you displays?

Environment

Library version

Installation method

iOS version(s)

Xcode version

scenee commented 1 month ago

Thank you for your report. I'll take a look later.

scenee commented 2 weeks ago

I recommend to use FloatingPanelAdaptiveLayoutAnchor or FloatingPanelIntrinsicLayoutAnchor. I confirmed they are working perfectly for dynamic resizing.

SinghSukhreet commented 2 days ago

If you are looking to change the size of panel after change in your content size, in your FloatingPanelLayout use a variable to provide panel height like this: .half: FloatingPanelLayoutAnchor( absoluteInset: kSPviewHeight, edge: .bottom, referenceGuide: .safeArea ),

once the content height is adjusted, set the panel layout once again and move it to the desired state: fpc?.layout = SPSelectionLayout() fpc?.move(to: .half, animated: false)