show password as dots by default, and "reveal" and "conceal" menu

This commit is contained in:
Bob Sun 2017-02-06 11:55:27 +08:00
parent a7bd92c61f
commit ea6bc0a7bd
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 29 additions and 1 deletions

View file

@ -59,6 +59,9 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
if let tappedCell = self.tableView.cellForRow(at: tapIndexPath) as? LabelTableViewCell {
tappedCell.becomeFirstResponder()
let menuController = UIMenuController.shared
let revealItem = UIMenuItem(title: "Reveal", action: #selector(LabelTableViewCell.revealPassword(_:)))
let concealItem = UIMenuItem(title: "Conceal", action: #selector(LabelTableViewCell.concealPassword(_:)))
menuController.menuItems = [revealItem, concealItem]
menuController.setTargetRect(tappedCell.contentLabel.frame, in: tappedCell.contentLabel.superview!)
menuController.setMenuVisible(true, animated: true)
}
@ -79,6 +82,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
let titleData = tableData[indexPath.section].item[indexPath.row].title
let contentData = tableData[indexPath.section].item[indexPath.row].content
cell.isPasswordCell = (titleData == "password" ? true : false)
cell.cellData = LabelTableViewCellData(title: titleData, content: contentData)
return cell
}