Tap tab bar to go back previous folder, double tap will scroll to top
This commit is contained in:
parent
cbbd7e08b6
commit
faf1ece5c3
1 changed files with 20 additions and 2 deletions
|
|
@ -21,11 +21,13 @@ struct PasswordsTableEntry {
|
||||||
var passwordEntity: PasswordEntity?
|
var passwordEntity: PasswordEntity?
|
||||||
}
|
}
|
||||||
|
|
||||||
class PasswordsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
|
class PasswordsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UITabBarControllerDelegate {
|
||||||
private var passwordsTableEntries: [PasswordsTableEntry] = []
|
private var passwordsTableEntries: [PasswordsTableEntry] = []
|
||||||
private var filteredPasswordsTableEntries: [PasswordsTableEntry] = []
|
private var filteredPasswordsTableEntries: [PasswordsTableEntry] = []
|
||||||
private var parentPasswordEntity: PasswordEntity? = nil
|
private var parentPasswordEntity: PasswordEntity? = nil
|
||||||
|
|
||||||
|
private var tapTabBarTime: TimeInterval = 0
|
||||||
|
|
||||||
var sections : [(index: Int, length :Int, title: String)] = Array()
|
var sections : [(index: Int, length :Int, title: String)] = Array()
|
||||||
var searchActive : Bool = false
|
var searchActive : Bool = false
|
||||||
lazy var searchController: UISearchController = {
|
lazy var searchController: UISearchController = {
|
||||||
|
|
@ -151,8 +153,8 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
setNavigationItemTitle()
|
setNavigationItemTitle()
|
||||||
initPasswordsTableEntries(parent: nil)
|
initPasswordsTableEntries(parent: nil)
|
||||||
addNotificationObservers()
|
addNotificationObservers()
|
||||||
|
|
||||||
generateSections(item: passwordsTableEntries)
|
generateSections(item: passwordsTableEntries)
|
||||||
|
tabBarController!.delegate = self
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
tableView.dataSource = self
|
tableView.dataSource = self
|
||||||
definesPresentationContext = true
|
definesPresentationContext = true
|
||||||
|
|
@ -230,6 +232,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
}
|
}
|
||||||
|
|
||||||
func backAction(_ sender: Any?) {
|
func backAction(_ sender: Any?) {
|
||||||
|
guard Defaults[.isShowFolderOn] else { return }
|
||||||
initPasswordsTableEntries(parent: parentPasswordEntity?.parent)
|
initPasswordsTableEntries(parent: parentPasswordEntity?.parent)
|
||||||
reloadTableView(data: passwordsTableEntries)
|
reloadTableView(data: passwordsTableEntries)
|
||||||
}
|
}
|
||||||
|
|
@ -419,6 +422,21 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
syncPasswords()
|
syncPasswords()
|
||||||
refreshControl.endRefreshing()
|
refreshControl.endRefreshing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
|
||||||
|
if viewController == self.navigationController {
|
||||||
|
let currentTime = Date().timeIntervalSince1970
|
||||||
|
let duration = currentTime - self.tapTabBarTime
|
||||||
|
self.tapTabBarTime = currentTime
|
||||||
|
if duration < 0.35 {
|
||||||
|
let topIndexPath = IndexPath(row: 0, section: 0)
|
||||||
|
tableView.scrollToRow(at: topIndexPath, at: .bottom, animated: true)
|
||||||
|
self.tapTabBarTime = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
backAction(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension PasswordsViewController: UISearchResultsUpdating {
|
extension PasswordsViewController: UISearchResultsUpdating {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue