Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWIFTUI - scroll issue #632

Open
KishoreZuper opened this issue May 21, 2024 · 0 comments
Open

SWIFTUI - scroll issue #632

KishoreZuper opened this issue May 21, 2024 · 0 comments

Comments

@KishoreZuper
Copy link

KishoreZuper commented May 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant