diff --git a/pass/Controllers/PasswordNavigationViewController.swift b/pass/Controllers/PasswordNavigationViewController.swift index e7353a6..75a08ad 100644 --- a/pass/Controllers/PasswordNavigationViewController.swift +++ b/pass/Controllers/PasswordNavigationViewController.swift @@ -70,6 +70,7 @@ class PasswordNavigationViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + tabBarController?.delegate = self configureNavigationItem() configureTabBarItem() configureNavigationBar() @@ -378,6 +379,21 @@ extension PasswordNavigationViewController: UISearchBarDelegate { } } +extension PasswordNavigationViewController: UITabBarControllerDelegate { + func tabBarController(_: UITabBarController, didSelect viewController: UIViewController) { + if viewController == navigationController { + let currentTime = Date().timeIntervalSince1970 + let duration = currentTime - tapTabBarTime + tapTabBarTime = currentTime + if duration < 0.35, tableView.numberOfSections > 0 { + let topIndexPath = IndexPath(row: 0, section: 0) + tableView.scrollToRow(at: topIndexPath, at: .bottom, animated: true) + tapTabBarTime = 0 + } + } + } +} + extension PasswordNavigationViewController: PasswordAlertPresenter { private func syncPasswords() { guard PasswordStore.shared.repositoryExists() else {