Show number of hidden fields in password view
This commit is contained in:
parent
68dd60fb8e
commit
5780a439db
2 changed files with 27 additions and 1 deletions
|
|
@ -441,13 +441,31 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
cell.selectionStyle = .none
|
||||
return cell
|
||||
case .misc:
|
||||
let cell = UITableViewCell()
|
||||
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
|
||||
cell.textLabel?.text = tableDataItem.title
|
||||
cell.selectionStyle = .default
|
||||
addHiddenFieldInformation(to: cell)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
private func addHiddenFieldInformation(to cell: UITableViewCell) {
|
||||
guard password != nil, let detailTextLabel = cell.detailTextLabel else {
|
||||
return
|
||||
}
|
||||
|
||||
var numberOfHiddenFields = 0
|
||||
numberOfHiddenFields += SharedDefaults[.isHideUnknownOn] ? password!.numberOfUnknowns : 0
|
||||
numberOfHiddenFields += SharedDefaults[.isHideOTPOn] ? password!.numberOfOtpRelated : 0
|
||||
guard numberOfHiddenFields > 0 else {
|
||||
return
|
||||
}
|
||||
|
||||
detailTextLabel.textAlignment = .center
|
||||
detailTextLabel.textColor = .gray
|
||||
detailTextLabel.text = "\(numberOfHiddenFields) hidden field\(numberOfHiddenFields > 1 ? "s" : "")"
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
return tableData[section].header
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,14 @@ public class Password {
|
|||
return otpToken?.currentPassword
|
||||
}
|
||||
|
||||
public var numberOfUnknowns: Int {
|
||||
return additions.map { $0.title }.filter(Constants.isUnknown).count
|
||||
}
|
||||
|
||||
public var numberOfOtpRelated: Int {
|
||||
return additions.map { $0.title }.filter(Constants.isOtpKeyword).count - (firstLineIsOTPField ? 1 : 0)
|
||||
}
|
||||
|
||||
public init(name: String, url: URL, plainText: String) {
|
||||
self.name = name
|
||||
self.url = url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue