Add animation to folder selection and backward
This commit is contained in:
parent
0507c7cdd7
commit
f1c07f358e
1 changed files with 29 additions and 4 deletions
|
|
@ -55,6 +55,26 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
return backUIBarButtonItem
|
return backUIBarButtonItem
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
lazy var transitionFromRight: CATransition = {
|
||||||
|
let transition = CATransition()
|
||||||
|
transition.type = kCATransitionPush
|
||||||
|
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
|
||||||
|
transition.fillMode = kCAFillModeForwards
|
||||||
|
transition.duration = 0.25
|
||||||
|
transition.subtype = kCATransitionFromRight
|
||||||
|
return transition
|
||||||
|
}()
|
||||||
|
|
||||||
|
lazy var transitionFromLeft: CATransition = {
|
||||||
|
let transition = CATransition()
|
||||||
|
transition.type = kCATransitionPush
|
||||||
|
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
|
||||||
|
transition.fillMode = kCAFillModeForwards
|
||||||
|
transition.duration = 0.25
|
||||||
|
transition.subtype = kCATransitionFromLeft
|
||||||
|
return transition
|
||||||
|
}()
|
||||||
|
|
||||||
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var tableView: UITableView!
|
||||||
|
|
||||||
private func initPasswordsTableEntries(parent: PasswordEntity?) {
|
private func initPasswordsTableEntries(parent: PasswordEntity?) {
|
||||||
|
|
@ -244,14 +264,14 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
searchController.isActive = false
|
searchController.isActive = false
|
||||||
initPasswordsTableEntries(parent: entry.passwordEntity)
|
initPasswordsTableEntries(parent: entry.passwordEntity)
|
||||||
reloadTableView(data: passwordsTableEntries)
|
reloadTableView(data: passwordsTableEntries, anim: transitionFromRight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func backAction(_ sender: Any?) {
|
func backAction(_ sender: Any?) {
|
||||||
guard Defaults[.isShowFolderOn] else { return }
|
guard Defaults[.isShowFolderOn] else { return }
|
||||||
initPasswordsTableEntries(parent: parentPasswordEntity?.parent)
|
initPasswordsTableEntries(parent: parentPasswordEntity?.parent)
|
||||||
reloadTableView(data: passwordsTableEntries)
|
reloadTableView(data: passwordsTableEntries, anim: transitionFromLeft)
|
||||||
}
|
}
|
||||||
|
|
||||||
func longPressAction(_ gesture: UILongPressGestureRecognizer) {
|
func longPressAction(_ gesture: UILongPressGestureRecognizer) {
|
||||||
|
|
@ -416,16 +436,21 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
refreshControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
refreshControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadTableView(data: [PasswordsTableEntry]) {
|
func reloadTableView(data: [PasswordsTableEntry], anim: CAAnimation? = nil) {
|
||||||
setNavigationItemTitle()
|
|
||||||
if parentPasswordEntity != nil {
|
if parentPasswordEntity != nil {
|
||||||
navigationItem.leftBarButtonItem = backUIBarButtonItem
|
navigationItem.leftBarButtonItem = backUIBarButtonItem
|
||||||
} else {
|
} else {
|
||||||
navigationItem.leftBarButtonItem = nil
|
navigationItem.leftBarButtonItem = nil
|
||||||
}
|
}
|
||||||
generateSections(item: data)
|
generateSections(item: data)
|
||||||
|
if anim != nil {
|
||||||
|
self.tableView.layer.add(anim!, forKey: "UITableViewReloadDataAnimationKey")
|
||||||
|
}
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
|
self.tableView.layer.removeAnimation(forKey: "UITableViewReloadDataAnimationKey")
|
||||||
updateRefreshControlTitle()
|
updateRefreshControlTitle()
|
||||||
|
setNavigationItemTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleRefresh(_ refreshControl: UIRefreshControl) {
|
func handleRefresh(_ refreshControl: UIRefreshControl) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue