SwiftUI Swipe to pop navigation

I want to hide the navigationbar in my swiftUI View and i can do that using the .navigationbarhiddent(true) but i still want to have the swipe to back functionality, i added my own button to dismiss the view but i couldn’t know how to add the swipe to back functionality. i stumbled upon this answer but it was not perfect because it applied to all the Views in my app, I want to be able to add it to only a the views of my choosing.

extension UINavigationController: UIGestureRecognizerDelegate {    override open func viewDidLoad() {        super.viewDidLoad()        interactivePopGestureRecognizer?.delegate = self    }    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {        return viewControllers.count > 1    }}
SwiftUI Swipe to pop navigation
 
 
Q