Move get category text logic to model
This commit is contained in:
parent
d82396a322
commit
ff947f8e17
2 changed files with 12 additions and 12 deletions
|
|
@ -63,23 +63,12 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
||||||
|
|
||||||
var tableData = Array<TableSection>()
|
var tableData = Array<TableSection>()
|
||||||
|
|
||||||
private func generateCategoryText() -> String {
|
|
||||||
var passwordCategoryArray: [String] = []
|
|
||||||
var parent = passwordEntity?.parent
|
|
||||||
while parent != nil {
|
|
||||||
passwordCategoryArray.append(parent!.name!)
|
|
||||||
parent = parent!.parent
|
|
||||||
}
|
|
||||||
passwordCategoryArray.reverse()
|
|
||||||
return passwordCategoryArray.joined(separator: " > ")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell")
|
tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell")
|
||||||
tableView.register(UINib(nibName: "PasswordDetailTitleTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordDetailTitleTableViewCell")
|
tableView.register(UINib(nibName: "PasswordDetailTitleTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordDetailTitleTableViewCell")
|
||||||
|
|
||||||
passwordCategoryText = generateCategoryText()
|
passwordCategoryText = passwordEntity!.getCategoryText()
|
||||||
|
|
||||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:)))
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PasswordDetailTableViewController.tapMenu(recognizer:)))
|
||||||
tableView.addGestureRecognizer(tapGesture)
|
tableView.addGestureRecognizer(tapGesture)
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,15 @@ extension PasswordEntity {
|
||||||
let encryptedData = try pgp.encryptData(plainData, usingPublicKey: pgp.getKeysOf(.public)[0], armored: false)
|
let encryptedData = try pgp.encryptData(plainData, usingPublicKey: pgp.getKeysOf(.public)[0], armored: false)
|
||||||
return encryptedData
|
return encryptedData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCategoryText() -> String {
|
||||||
|
var parentEntity = parent
|
||||||
|
var passwordCategoryArray: [String] = []
|
||||||
|
while parentEntity != nil {
|
||||||
|
passwordCategoryArray.append(parentEntity!.name!)
|
||||||
|
parentEntity = parentEntity!.parent
|
||||||
|
}
|
||||||
|
passwordCategoryArray.reverse()
|
||||||
|
return passwordCategoryArray.joined(separator: " > ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue