Use PasswordTableViewCell for all password entries

This commit is contained in:
Mingshen Sun 2021-01-05 20:54:51 -08:00
parent 3e3aca1c3c
commit 3ecb35e701
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
7 changed files with 164 additions and 168 deletions

View file

@ -262,6 +262,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
SVProgressHUD.setDefaultMaskType(.black)
tableView.register(UINib(nibName: "PasswordWithFolderTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordWithFolderTableViewCell")
tableView.register(PasswordTableViewCell.self, forCellReuseIdentifier: "passwordTableViewCell")
// initialize the password table
reloadTableView(parent: nil)
@ -356,25 +357,10 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
return recognizer
}()
let entry = getPasswordEntry(by: indexPath)
let passwordEntity = entry.passwordEntity
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
cell.textLabel?.text = passwordEntity.synced ? entry.title : "\(entry.title)"
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body)
cell.textLabel?.adjustsFontForContentSizeCategory = true
cell.accessoryType = .none
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
cell.detailTextLabel?.adjustsFontForContentSizeCategory = true
cell.addGestureRecognizer(longPressGestureRecognizer)
if entry.isDir {
cell.accessoryType = .disclosureIndicator
cell.textLabel?.font = UIFont.systemFont(ofSize: UIFont.preferredFont(forTextStyle: .body).pointSize, weight: .medium)
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body)
cell.detailTextLabel?.text = "\(passwordEntity.children?.count ?? 0)"
cell.removeGestureRecognizer(longPressGestureRecognizer)
} else {
cell.detailTextLabel?.text = passwordEntity.getCategoryText()
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath) as! PasswordTableViewCell
cell.configure(with: entry)
if !entry.isDir {
cell.addGestureRecognizer(longPressGestureRecognizer)
}
return cell