FloatingPanel icon indicating copy to clipboard operation
FloatingPanel copied to clipboard

Update panel height programmatically when panel is already presented

Open AndrexOfficial opened this issue 3 years ago • 1 comments

Hello, I'm trying to change panel's height in order to adapt it to content, the content arrives later because of API but panel is already presented and shown. I tried to make a func in order to update it but without success, it updates only after changing scroll position with my finger.

Here's my code:

func updatePanelViewHeight() {
        guard isViewLoaded else { return }
        floatingPanelController?.invalidateLayout()
        let productTitleLines = productTitleLabel.numberOfVisibleLines
        let productPriceLines = productPriceLabel.numberOfVisibleLines
        appFloatingPanelLayout?.heightToAdd = CGFloat(productTitleLines + productPriceLines) + 20
        floatingPanelController?.layout = tezenisFloatingPanelLayout!
        floatingPanelController?.updateViewConstraints()
        floatingPanelController?.viewDidLayoutSubviews()
        floatingPanelController?.notifyDidMove()
    }

What am I doing wrong? Thanks

AndrexOfficial avatar Sep 29 '21 14:09 AndrexOfficial

FloatingPanelController expects invalidateLayout() is called after a new layout is assigned into it. Please see also README - Update your panel layout. If you call invalidateLayout() in an animation block. The layout changes with the animation.

scenee avatar Oct 05 '21 14:10 scenee