Skip to content

SWIFTUI - scroll issue #632

@KishoreZuper

Description

@KishoreZuper

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

Simulator.Screen.Recording.-.iPad.Pro.11-inch.4th.generation.-.2024-05-21.at.08.46.47.mp4

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)?

  • Add as child view controllers

How many panels do you displays?

  • 1

Environment

Library version
2.8.2

Installation method

  • Swift Package Manager

iOS version(s)
17

Xcode version

15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions