UI improvements

This commit is contained in:
Mingshen Sun 2023-03-13 21:33:54 -07:00
parent 01a29333ae
commit 4904b81da0
4 changed files with 139 additions and 139 deletions

View file

@ -62,7 +62,6 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
tableView.addGestureRecognizer(tapGesture)
tapGesture.delegate = self
tableView.contentInset = UIEdgeInsets(top: -36, left: 0, bottom: 44, right: 0)
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 52
@ -489,6 +488,14 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
tableData[section].header
}
override func tableView(_: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if tableData[section].header != nil {
return 30
} else {
return UITableView.automaticDimension
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == tableData.count - 1 {
let view = UIView()

View file

@ -39,8 +39,8 @@ class PasswordEditorTableViewController: UITableViewController {
private var navigationItemTitle: String?
private var sectionHeaderTitles = ["Name".localize(), "Password".localize(), "Additions".localize(), ""].map { $0.uppercased() }
private var sectionFooterTitles = ["", "", "UseKeyValueFormat.".localize(), ""]
private var sectionHeaderTitles: [String?] = ["Name".localize(), "Password".localize(), "Additions".localize(), nil]
private var sectionFooterTitles: [String?] = [nil, nil, "UseKeyValueFormat.".localize(), nil]
private let nameSection = 0
private let passwordSection = 1
private let additionsSection = 2
@ -71,8 +71,9 @@ class PasswordEditorTableViewController: UITableViewController {
super.loadView()
deletePasswordCell = UITableViewCell(style: .default, reuseIdentifier: "default")
deletePasswordCell!.textLabel?.text = "DeletePassword".localize()
deletePasswordCell!.textLabel?.textColor = Colors.systemRed
deletePasswordCell?.textLabel?.text = "DeletePassword".localize()
deletePasswordCell?.textLabel?.textAlignment = .center
deletePasswordCell?.textLabel?.textColor = Colors.systemRed
deletePasswordCell?.selectionStyle = .default
scanQRCodeCell = UITableViewCell(style: .default, reuseIdentifier: "default")
@ -104,11 +105,6 @@ class PasswordEditorTableViewController: UITableViewController {
tableView.register(UINib(nibName: "SliderTableViewCell", bundle: nil), forCellReuseIdentifier: "sliderCell")
tableView.register(UINib(nibName: "SwitchTableViewCell", bundle: nil), forCellReuseIdentifier: "switchCell")
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 48
tableView.sectionFooterHeight = UITableView.automaticDimension
tableView.estimatedSectionFooterHeight = 0
tableData = [
[
[.type: PasswordEditorCellType.nameCell, .title: "Name".localize(), .content: password?.namePath ?? ""],
@ -130,7 +126,9 @@ class PasswordEditorTableViewController: UITableViewController {
]
if password != nil {
tableData[additionsSection + 1].append([.type: PasswordEditorCellType.deletePasswordCell])
tableData.append([[.type: PasswordEditorCellType.deletePasswordCell]])
sectionFooterTitles.append(nil)
sectionHeaderTitles.append(nil)
}
updateTableData(withRespectTo: passwordGenerator.flavor)
}
@ -207,8 +205,16 @@ class PasswordEditorTableViewController: UITableViewController {
}
}
override func tableView(_: UITableView, heightForHeaderInSection _: Int) -> CGFloat {
44
override func tableView(_: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if sectionHeaderTitles[section] != nil {
return 30
} else {
return UITableView.automaticDimension
}
}
override func tableView(_: UITableView, heightForFooterInSection _: Int) -> CGFloat {
UITableView.automaticDimension
}
override func tableView(_: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

View file

@ -116,6 +116,7 @@ class PasswordNavigationViewController: UIViewController {
DispatchQueue.main.async {
self.searchBar.text = self.searchText
self.searchController.isActive = true
self.searchBar.becomeFirstResponder()
}
}
}
@ -132,6 +133,7 @@ class PasswordNavigationViewController: UIViewController {
configureTableViewDataSource(in: dir, isShowFolder: Defaults.isShowFolderOn)
tableView.addGestureRecognizer(gestureRecognizer)
tableView.delegate = self
tableView.contentInset.top = 32
let atribbutedTitle = "LastSynced".localize() + ": \(PasswordStore.shared.lastSyncedTimeString)"
refreshControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
tableView.refreshControl = refreshControl
@ -312,6 +314,14 @@ extension PasswordNavigationViewController: UITableViewDelegate {
func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
UITableView.automaticDimension
}
func tableView(_: UITableView, heightForHeaderInSection _: Int) -> CGFloat {
UITableView.automaticDimension
}
func tableView(_: UITableView, estimatedHeightForHeaderInSection _: Int) -> CGFloat {
UITableView.automaticDimension
}
}
extension PasswordNavigationViewController {