From 1afef16fa1955113b29adb090c736b26288b90af Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Thu, 12 Apr 2018 01:07:19 +0800 Subject: [PATCH] Support swipe back when viewing folder #141 --- pass/Controllers/PasswordsViewController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 34a208d..2129d8c 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -229,6 +229,11 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV // reset the data table if the disaply settings have been changed NotificationCenter.default.addObserver(self, selector: #selector(actOnReloadTableViewRelatedNotification), name: .passwordDisplaySettingChanged, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(actOnSearchNotification), name: .passwordSearch, object: nil) + + // listen to the swipe back guesture + let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture)) + swipeRight.direction = UISwipeGestureRecognizerDirection.right + self.view.addGestureRecognizer(swipeRight) } override func viewWillAppear(_ animated: Bool) { @@ -314,6 +319,15 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } } + @objc func respondToSwipeGesture(gesture: UIGestureRecognizer) { + if let swipeGesture = gesture as? UISwipeGestureRecognizer { + // swipe right -> swipe back + if swipeGesture.direction == .right && parentPasswordEntity != nil { + self.backAction(nil) + } + } + } + @objc func backAction(_ sender: Any?) { guard SharedDefaults[.isShowFolderOn] else { return } var anim: CATransition? = transitionFromLeft