scenee / FloatingPanel

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

Grabber Handle is above the content for top positioned floating panels in SwiftUI #593

Closed ifarooqqdigilynx closed 1 year ago

ifarooqqdigilynx commented 1 year ago

Description

Using SwiftUI i created floating panels for both bottom and top but Grabber Handle is showing above the content for Top Positioned Floating Panels.

Expected behavior

Garbber Handle should stick to bottom area of panel

Actual behaviour

Grabber Handle is showing above the content

Steps to reproduce

Code example that reproduces the issue

.floatingPanel(delegate: topMapPanelDelegate) { proxy in SignInTopPanelView(proxy: proxy, isSignup: $isSignnup, getProxyCallback: { proxyCall in proxyNavigationTop = proxyCall }, panelType: $panelType) }

            .floatingPanelSurfaceAppearance(phone5())
            .floatingPanelContentMode(.static)
            .floatingPanelContentInsetAdjustmentBehavior(.never)

How do you display panel(s)?

How many panels do you displays? I have 3 panels attached to SwiftUI View

Simulator Screen Shot - iPhone 14 Pro - 2023-06-04 at 11 38 51

Environment

Xcode 14.0+

Library version Latest by today

Installation method

iOS version(s) iOS 14.0+

Xcode version Xcode 14.2

scenee commented 1 year ago

Do you have a FloatingPanelLayout object for the top positioned panel?

For example: https://github.com/scenee/FloatingPanel/blob/a0ba3af01207d21bb4800dda9f900470e1921613/Examples/Samples/Sources/PanelLayouts.swift#L23-L31

If not, just try to prepare it and assigned it to fpc.layout in FloatingPanelView.

ifarooqqdigilynx commented 1 year ago

Yes, i did the same

` import Foundation

class SKFloatingPanelLayout: FloatingPanelLayout { var positionHalf: CGFloat = 480.0 var positionFull: CGFloat = 480.0 var position: FloatingPanelPosition = .bottom var initialState: FloatingPanelState = .tip var edgePosition: FloatingPanelReferenceEdge = .bottom var showBackdrop: Bool = true var tipValue: CGFloat = -1

init(positionHalf: CGFloat, positionFull: CGFloat, position: FloatingPanelPosition, initialState: FloatingPanelState, edgePosition: FloatingPanelReferenceEdge, tipValue: CGFloat, showbakDrop: Bool) {
    self.positionHalf = positionHalf
    self.positionFull = positionFull
    self.position = position
    self.initialState = initialState
    self.edgePosition = edgePosition
    self.tipValue = tipValue
    self.showBackdrop = showbakDrop
}

var anchors: [FloatingPanelState: FloatingPanelLayoutAnchoring] {
    return [
        .full: FloatingPanelLayoutAnchor(absoluteInset: positionFull, edge: edgePosition, referenceGuide: .superview),
        .half: FloatingPanelLayoutAnchor(absoluteInset: positionHalf, edge: edgePosition, referenceGuide: .superview),
        .tip: FloatingPanelLayoutAnchor(absoluteInset: tipValue, edge: edgePosition, referenceGuide: .superview),
        // .hidden: FloatingPanelLayoutAnchor(absoluteInset: 0, edge: edgePosition, referenceGuide: .superview),
    ]
}

func backdropAlpha(for state: FloatingPanelState) -> CGFloat {
    print("ALERT \(state)")
    if state == .tip || !showBackdrop {
        return 0.0
    }

    return 0.04
}

} `

ifarooqqdigilynx commented 1 year ago

`func floatingPanel(_ fpc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout { switch postionFPC { case let .top(pHalf, pFull): return SKFloatingPanelLayout(positionHalf: CGFloat(pHalf), positionFull: CGFloat(pFull), position: .top, initialState: .tip, edgePosition: .top, tipValue: 0, showbakDrop: showBackdrop) case let .bottomMapUsers(pHalf, pFull): return SKFloatingPanelLayout(positionHalf: CGFloat(pHalf), positionFull: CGFloat(pFull), position: .bottom, initialState: .tip, edgePosition: .bottom, tipValue: 166, showbakDrop: showBackdrop)

    case let .bottomFilter(pHalf, pFull):
        return SKFloatingPanelLayout(positionHalf: CGFloat(pHalf), positionFull: CGFloat(pFull), position: .bottom, initialState: .tip, edgePosition: .bottom, tipValue: 0, showbakDrop: showBackdrop)
    }
}`
ifarooqqdigilynx commented 1 year ago

Thankyou i had to replace sample code, now its working.

Can you please guide how can i invalidatelayout with animation?

withAnimation(.hero) { proxy.fpc?.invalidateLayout() }

above code is not animating.

scenee commented 1 year ago

Can you please guide how can i invalidatelayout with animation?

invalidateLayout() api can be use with UIKit animation. So please use UIView.animate API.

Thankyou i had to replace sample code, now its working.

Sounds good! I'll close this issue. Thank you.