LeoNatan / LNPopupUI

A SwiftUI library for presenting views as popups, much like the Apple Music and Podcasts apps.
MIT License
320 stars 29 forks source link

Inconsistent Scrolling in PopupView #6

Closed rrphenix closed 3 years ago

rrphenix commented 3 years ago

Hi, Quick question regarding some inconsistent scrolling I'm running into using the LNPopUp UI.

Goal: Add a horizontally paging view in the popup view What I've Tried: I've made the following changes to the demo project to accomplish this:


//SafeAreaDemoView(colorSeed: "Popup", offset: true, isPopupOpen: isPopupOpen)
      ScrollView {
      TabView {
        SafeAreaDemoView(colorSeed:  "tab_0" )
        SafeAreaDemoView(colorSeed:  "tab_1" )
        SafeAreaDemoView(colorSeed:  "tab_2" )
        SafeAreaDemoView(colorSeed:  "tab_3" )
      }
      .frame(
          width: UIScreen.main.bounds.width ,
          height: UIScreen.main.bounds.height
      )
      .tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
      .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
      }.edgesIgnoringSafeArea(.all)
        .popupTitle(demoContent.title, subtitle: demoContent.subtitle)
        .popupImage(Image("genre\(demoContent.imageNumber)"))

What I expect to happen:

What happens: Swiping horizonatally works occasionally, however about 30% of touches get lost. Also, the PopUpUI sporadically closes following some of the swipes. It seems like the gesture recognizer might be a bit too sensitive in the vertical direction. Horizontal swiping works most consistently when you swipe diagonally up+left or up+right

Visual of changes:

Screen Shot 2021-05-01 at 7 47 24 PM
LeoNatan commented 3 years ago

Thanks, I will take a look.

LeoNatan commented 3 years ago

Looking at your code, it seems you are embedding a scroll view inside a scroll view, which is not a good idea. In general, it seems a tab view with PageTabViewStyle behaves very oddly.

I will try to tweak the scroll view gesture handling to work better, but keep in mind that PageTabViewStyle will be buggy regardless.