nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

Issue with pop gesture in iOS 17.4 #38

Closed jacksonh closed 5 months ago

jacksonh commented 6 months ago

Since upgrading to iOS 17.4 I've had an issue with using the swipe to go back gesture on a WKWebView. I think i have a minimal example now that shows the difference between NavigationLink and PresentationLink. In the attached example code, if you push the DetailView with a NavigationLink it can be popped with a back swipe (from the edge). But if you use the PresentationLink version, neither swipe will work.

The key part is the WKWebView needs to be large enough to start scrolling, if you load just a small page with no scrolling you wont see this issue.

I suspect this has something to do with the SwipeTransition maybe not recognizing a new type of gesture in the WKWebView in iOS 17.4 but am still debugging.

I'll attach a zip of the project, but here's the main bit:


import SwiftUI
import WebKit
import Transmission

struct ContentView: View {
  @State var isPresented: Bool = false
    var body: some View {
      NavigationView {
        VStack(spacing: 20) {
          PresentationLink(
            transition: PresentationLinkTransition.slide(
              options: PresentationLinkTransition.SlideTransitionOptions(
                edge: .trailing,
                options:
                  PresentationLinkTransition.Options(
                    modalPresentationCapturesStatusBarAppearance: true))),
            destination: {
              DetailView()
            }, label: {
              Text("Presentation Link")
            })

          NavigationLink("Navigation link", destination: {
            DetailView()
          })
        }
      }
    }
}

struct DetailView: View {

  var body: some View {
    InternalWebView()
  }
}

struct InternalWebView: UIViewRepresentable {
    func makeUIView(context: Context) -> WKWebView  {
      let wkwebView = WKWebView()
      // This is a webview big enough that it causes some scrolling
      wkwebView.loadHTMLString("<html><body style='background-color:aquamarine;height:2000px'>test</body></html>", baseURL: nil)
        return wkwebView
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {
    }
}

#Preview {
    ContentView()
}
jacksonh commented 6 months ago

NavigationView.zip

nathantannar4 commented 5 months ago

This will be fixed in next release