scenee / FloatingPanel

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

SWIFTUI - scroll issue #632

Open KishoreZuper opened 6 months ago

KishoreZuper commented 6 months ago

Description

I'm using a floating panel to show a list of details in an overlay view format in SwiftUI. I change the view based on progress changes. I'm using a scroll view to show the list of details in the overlay view. Because of this, I'm unable to scroll through the full content. The inner scroll view is overlapping with the outer content. Is there any way to fix this issue?

Expected behavior

The scroll should work as expected, and the inner scroll view should not overlap with the outer scroll view.

Actual behavior

https://github.com/scenee/FloatingPanel/assets/118449128/2a029942-a454-4675-8fac-dd965920346b

Steps to reproduce

`struct FloatingPanelContentView: View { var proxy: FloatingPanelProxy @Binding var progressValue: Double

@State var scrollViewEnable: Bool = true

var body: some View {
    VStack {
        OverlayViewControllerRepresentable(onScrollViewCreated: proxy.track(scrollView:), listView: MyScrollView(progressValue: $progressValue), enableScrollInParentView: $scrollViewEnable)
    }
    .ignoresSafeArea()
    .onAppear {
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
            proxy.move(to: .tip, animated: true)
        }
    }
}

var resultsList: some View {
    OverlayViewControllerRepresentable(onScrollViewCreated: proxy.track(scrollView:), listView: MyScrollView(progressValue: $progressValue), enableScrollInParentView: $scrollViewEnable)
}

struct MyScrollView: View {
    @Binding var progressValue: Double
    var body: some View {
        VStack {
            headerView
            ScrollView {
                if progressValue <= 0.3 {
                    compactView
                } else {
                    fullView
                }
            }
        }
    }

    var compactView: some View {
        VStack(spacing: 10) {
            ForEach(1...2, id: \.self) { index in
                Text("Item \(index)")
                    .frame(maxWidth: .infinity, minHeight: 30)
                    .background(Color.blue)
                    .cornerRadius(8)
                    .foregroundColor(.white)
            }
        }
    }

    var fullView: some View {
        VStack(spacing: 20) {
            ForEach(1...20, id: \.self) { index in
                Text("Item \(index)")
                    .frame(maxWidth: .infinity, minHeight: 50)
                    .background(Color.blue)
                    .cornerRadius(8)
                    .foregroundColor(.white)
            }
        }
    }

    fileprivate var headerView: some View {
        HStack(spacing: 0) {

            Spacer()
            Text("title")
            Spacer()
        }
        .padding(.horizontal, 10)
    }
}

}`

How do you display panel(s)?

How many panels do you displays?

Environment

Library version 2.8.2

Installation method

iOS version(s) 17

Xcode version

15