From 4c83427a013cbe82b751e9c049756332aaf43943 Mon Sep 17 00:00:00 2001 From: Mingshen Sun Date: Sun, 29 Sep 2019 23:34:11 -0700 Subject: [PATCH] Tweak UI of PasswordsView --- .../Controllers/PasswordsViewController.swift | 56 ++++++++----------- .../PasswordDetailTitleTableViewCell.xib | 18 +++--- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index cf52c0c..353a887 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -291,42 +291,34 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction(_:))) - longPressGestureRecognizer.minimumPressDuration = 0.6 - if SharedDefaults[.isShowFolderOn] && searchController.searchBar.selectedScopeButtonIndex == 0{ - let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath) + let longPressGestureRecognizer: UILongPressGestureRecognizer = { + let recognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction)) + recognizer.minimumPressDuration = 0.6 + return recognizer + }() + let entry = getPasswordEntry(by: indexPath) + let passwordEntity = entry.passwordEntity! + let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath) - let entry = getPasswordEntry(by: indexPath) - if entry.passwordEntity!.synced { - cell.textLabel?.text = entry.title - } else { - cell.textLabel?.text = "↻ \(entry.title)" - } - if !entry.isDir { - cell.addGestureRecognizer(longPressGestureRecognizer) - cell.accessoryType = .none - cell.detailTextLabel?.text = "" - } else { - cell.accessoryType = .disclosureIndicator - cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body) - cell.detailTextLabel?.text = "\(entry.passwordEntity?.children?.count ?? 0)" - } - return cell + 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.systemFontSize, weight: .semibold) + cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body) + cell.detailTextLabel?.text = "\(passwordEntity.children?.count ?? 0)" + cell.removeGestureRecognizer(longPressGestureRecognizer) } else { - let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath) - let entry = getPasswordEntry(by: indexPath) - if entry.passwordEntity!.synced { - cell.textLabel?.text = entry.title - } else { - cell.textLabel?.text = "↻ \(entry.title)" - } - cell.accessoryType = .none - cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote) - cell.detailTextLabel?.text = entry.passwordEntity?.getCategoryText() - cell.addGestureRecognizer(longPressGestureRecognizer) - return cell + cell.detailTextLabel?.text = passwordEntity.getCategoryText() } + return cell } private func getPasswordEntry(by indexPath: IndexPath) -> PasswordsTableEntry { diff --git a/pass/Views/PasswordDetailTitleTableViewCell.xib b/pass/Views/PasswordDetailTitleTableViewCell.xib index 9d66765..775034c 100644 --- a/pass/Views/PasswordDetailTitleTableViewCell.xib +++ b/pass/Views/PasswordDetailTitleTableViewCell.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -15,26 +13,26 @@ - + - +