iOS Swipe from the left edge to previous screen

I’m an iOS dev and noticed in the Companion App that you have a custom back button (triangle pointing left). Because of that, you lose the IOS default behaviour of being able to swipe right from the left edge to pop back to the previous screen.

Please give this code to you devs so they can add back the default iOS behaviour to the Companion app. This way, we are not forced to always use the back button, which is not easily accessible with just one hand holding the device.

Thanks

 class SwipableNavigationController: UINavigationController {
     var animationInProgress = false
     override init(rootViewController: UIViewController) {
         super.init(rootViewController: rootViewController)
         delegate = self
     }
     override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
         super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
         delegate = self
     }
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         delegate = self
     }
     deinit {
         interactivePopGestureRecognizer?.delegate = nil
         delegate = nil
     }
     override func viewDidLoad() {
         super.viewDidLoad()
         interactivePopGestureRecognizer?.delegate = self
         interactivePopGestureRecognizer?.isEnabled = true
     }
     override func pushViewController(_ viewController: UIViewController, animated: Bool) {
         animationInProgress = true
         super.pushViewController(viewController, animated: animated)
     }
 }
 extension SwipableNavigationController: UINavigationControllerDelegate {
     func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
         guard let navController = navigationController as? SwipableNavigationController else { return }
         navController.animationInProgress = false
     }
 }
 extension SwipableNavigationController: UIGestureRecognizerDelegate {
     func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
         guard gestureRecognizer == interactivePopGestureRecognizer else {
             return true
         }
         return viewControllers.count > 1 && animationInProgress == false
     }
 }

good work or just give you a job, the whole companion app is long overdue a refresh starting with being able to search for events would be the most basic of basic feature to start with.

1 Like