Add show recent commit logs in the about repository page

This commit is contained in:
Bob Sun 2017-02-28 17:10:27 +08:00
parent dde194ad3d
commit 48d1ab34d2
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 91 additions and 2 deletions

View file

@ -55,7 +55,8 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
[[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords", .detailText: numberOfPasswords],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepository], [.style: CellDataStyle.value1, .accessoryType: type, .title: "Unsynced", .detailText: String(PasswordStore.shared.getNumberOfUnsyncedPasswords())],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Last Synced", .detailText: Utils.getLastUpdatedTimeString()],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString]
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString],
[.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"],
],
]
indicator.stopAnimating()

View file

@ -0,0 +1,36 @@
//
// CommitLogsTableViewController.swift
// pass
//
// Created by Mingshen Sun on 28/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
import ObjectiveGit
class CommitLogsTableViewController: UITableViewController {
var commits: [GTCommit] = []
override func viewDidLoad() {
super.viewDidLoad()
commits = PasswordStore.shared.getRecentCommits(count: 20)
navigationItem.title = "Recent Commit Logs"
navigationItem.leftBarButtonItem?.title = "About"
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return commits.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "commitLogCell", for: indexPath)
let formatter = DateFormatter()
formatter.dateStyle = DateFormatter.Style.medium
formatter.timeStyle = .medium
let dateString = formatter.string(from: commits[indexPath.row].commitDate)
cell.textLabel?.text = dateString
cell.detailTextLabel?.text = commits[indexPath.row].message
return cell
}
}