From 48d1ab34d207a3d52611085466232f2cf9e6f27b Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Tue, 28 Feb 2017 17:10:27 +0800 Subject: [PATCH] Add show recent commit logs in the about repository page --- pass.xcodeproj/project.pbxproj | 4 ++ pass/Base.lproj/Main.storyboard | 50 ++++++++++++++++++- .../AboutRepositoryTableViewController.swift | 3 +- .../CommitLogsTableViewController.swift | 36 +++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 pass/Controllers/CommitLogsTableViewController.swift diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 390fc1f..a3ac717 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ DC193FFE1E49E0760077E0A3 /* PasscodeLockRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC193FFD1E49E0760077E0A3 /* PasscodeLockRepository.swift */; }; DC1940001E49E1A60077E0A3 /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC193FFF1E49E1A60077E0A3 /* PasscodeLockConfiguration.swift */; }; DC19400B1E4B36B60077E0A3 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC19400A1E4B36B60077E0A3 /* Utils.swift */; }; + DC3E64E61E656F11009A83DE /* CommitLogsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3E64E51E656F11009A83DE /* CommitLogsTableViewController.swift */; }; DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; }; DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; }; DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC5734AD1E439AD400D09270 /* PasswordsViewController.swift */; }; @@ -80,6 +81,7 @@ DC193FFD1E49E0760077E0A3 /* PasscodeLockRepository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockRepository.swift; sourceTree = ""; }; DC193FFF1E49E1A60077E0A3 /* PasscodeLockConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockConfiguration.swift; sourceTree = ""; }; DC19400A1E4B36B60077E0A3 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; + DC3E64E51E656F11009A83DE /* CommitLogsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommitLogsTableViewController.swift; sourceTree = ""; }; DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = ""; }; DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailTableViewController.swift; sourceTree = ""; }; DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Objective-CBridgingHeader.h"; sourceTree = ""; }; @@ -147,6 +149,7 @@ DC19400C1E4B39400077E0A3 /* Controllers */ = { isa = PBXGroup; children = ( + DC3E64E51E656F11009A83DE /* CommitLogsTableViewController.swift */, DC5F385A1E56AADB00C69ACA /* PGPKeyArmorSettingTableViewController.swift */, DC037CB11E4CAB1700609409 /* AboutRepositoryTableViewController.swift */, DC962CDE1E4B62C10033B5D8 /* AboutTableViewController.swift */, @@ -428,6 +431,7 @@ DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */, DC962CDF1E4B62C10033B5D8 /* AboutTableViewController.swift in Sources */, DC5734AE1E439AD400D09270 /* PasswordsViewController.swift in Sources */, + DC3E64E61E656F11009A83DE /* CommitLogsTableViewController.swift in Sources */, DC037CAA1E4B8EAE00609409 /* SpecialThanksTableViewController.swift in Sources */, DC037CA61E4B883900609409 /* OpenSourceComponentsTableViewController.swift in Sources */, DC037CA81E4B898100609409 /* BasicStaticTableViewController.swift in Sources */, diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index 2db1511..9040cfa 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -239,6 +239,7 @@ + @@ -269,6 +270,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -688,6 +733,9 @@ + + + diff --git a/pass/Controllers/AboutRepositoryTableViewController.swift b/pass/Controllers/AboutRepositoryTableViewController.swift index d135c31..42ca754 100644 --- a/pass/Controllers/AboutRepositoryTableViewController.swift +++ b/pass/Controllers/AboutRepositoryTableViewController.swift @@ -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() diff --git a/pass/Controllers/CommitLogsTableViewController.swift b/pass/Controllers/CommitLogsTableViewController.swift new file mode 100644 index 0000000..1113097 --- /dev/null +++ b/pass/Controllers/CommitLogsTableViewController.swift @@ -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 + } +}