Show last commit time of each entry

This commit is contained in:
yishilin14 2017-02-27 08:54:51 +08:00
parent 44f148c7ea
commit c2db4d4641
3 changed files with 32 additions and 3 deletions

View file

@ -250,6 +250,21 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
return tableData[section].title
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == tableData.count - 1 {
let view = UIView()
let footerLabel = UILabel(frame: CGRect(x: 8, y: 15, width: tableView.frame.width, height: 60))
footerLabel.numberOfLines = 0
footerLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
footerLabel.textColor = UIColor.lightGray
let dateString = DateFormatter.localizedString(from: passwordEntity?.commitDate as! Date, dateStyle: DateFormatter.Style.long, timeStyle: DateFormatter.Style.long)
footerLabel.text = "Latest commit: \(dateString)"
view.addSubview(footerLabel)
return view
}
return nil
}
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
if action == #selector(copy(_:)) {
Utils.copyToPasteboard(textToCopy: tableData[indexPath.section].item[indexPath.row].content)