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

DestinationLink prevents back gesture from work with Map #25

Closed PhilipDukhov closed 8 months ago

PhilipDukhov commented 8 months ago

With NavigationLink the back gesture works fine, but with .destination it doesn't - the map scrolls when I try to pop with the screen edge gesture.

struct ContentView: View {
    @State var pushed = false

    var body: some View {
        NavigationContainer {
            Button("Push DestinationLink") {
                pushed = true
            }
            .destination(isPresented: $pushed) {
                Map()
            }
            NavigationLink("Push NavigationLink") {
                Map()
            }
        }
    }
}

struct Map: UIViewRepresentable {
    func makeUIView(context: Context) -> MKMapView {
        MKMapView()
    }

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

struct NavigationContainer<Content: View>: UIViewControllerRepresentable {
    @ViewBuilder let content: () -> Content

    func makeUIViewController(context: Context) -> UINavigationController {
        UINavigationController(rootViewController: UIHostingController(rootView: content()))
    }

    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
        (uiViewController.viewControllers.first as? UIHostingController<Content>)?.rootView = content()
    }
}

It starts working if I comment both these lines in DestinationLinkModifier.swift - looks like original delegate handles it.

navigationController.delegate = self
navigationController.interactivePopGestureRecognizer?.delegate = self
nathantannar4 commented 8 months ago

Will be fixed in 1.1.1