diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 0595126..f882276 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -10,7 +10,9 @@ 94BA784B85E071D25EE89B59 /* libPods-pass.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */; }; DC1208561E35D0BA0042942E /* PasswordsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */; }; DC1208581E35EBE60042942E /* ObjectiveGit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC1208571E35EBE60042942E /* ObjectiveGit.framework */; }; - DC3DC8391E2F63240062A988 /* PasswordDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */; }; + DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914941E434301007FF592 /* LabelTableViewCell.swift */; }; + DC4914971E434301007FF592 /* LabelTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DC4914951E434301007FF592 /* LabelTableViewCell.xib */; }; + DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */; }; DC7E6EEA1E432E48006C2443 /* Password.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC7E6EE91E432E48006C2443 /* Password.swift */; }; DC8963BE1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BD1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift */; }; DC8963C01E38EEB900828B09 /* SSHKeySettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8963BF1E38EEB900828B09 /* SSHKeySettingTableViewController.swift */; }; @@ -36,7 +38,9 @@ AEAD6B31EAF5D061447A68CC /* Pods-pass.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.release.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.release.xcconfig"; sourceTree = ""; }; DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordsTableViewController.swift; sourceTree = ""; }; DC1208571E35EBE60042942E /* ObjectiveGit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjectiveGit.framework; path = Carthage/Build/iOS/ObjectiveGit.framework; sourceTree = ""; }; - DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailViewController.swift; sourceTree = ""; }; + DC4914941E434301007FF592 /* LabelTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelTableViewCell.swift; sourceTree = ""; }; + DC4914951E434301007FF592 /* LabelTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelTableViewCell.xib; 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 = ""; }; DC7E6EE91E432E48006C2443 /* Password.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Password.swift; sourceTree = ""; }; DC8963BD1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitRepositoryAuthenticationSettingTableViewController.swift; sourceTree = ""; }; @@ -105,6 +109,7 @@ DC917BD51E2E8231000FDF54 /* pass */ = { isa = PBXGroup; children = ( + DC4914941E434301007FF592 /* LabelTableViewCell.swift */, DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */, DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */, DC917BD61E2E8231000FDF54 /* AppDelegate.swift */, @@ -113,7 +118,7 @@ DCA0499B1E3362F400522E8F /* PGPKeySettingTableViewController.swift */, DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */, DCAAF7441E2FA66800AB94BC /* SettingsTableViewController.swift */, - DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */, + DC4914981E434600007FF592 /* PasswordDetailTableViewController.swift */, DCC408A31E2FCC9E00F29B0E /* PasswordStore.swift */, DC7E6EE91E432E48006C2443 /* Password.swift */, DCA049971E33586A00522E8F /* DefaultKeys.swift */, @@ -121,6 +126,7 @@ DCC408C81E30BA1300F29B0E /* pass.xcdatamodeld */, DC917BDD1E2E8231000FDF54 /* Assets.xcassets */, DC917BDA1E2E8231000FDF54 /* Main.storyboard */, + DC4914951E434301007FF592 /* LabelTableViewCell.xib */, DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */, DC917BE21E2E8231000FDF54 /* Info.plist */, ); @@ -205,6 +211,7 @@ files = ( DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */, DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */, + DC4914971E434301007FF592 /* LabelTableViewCell.xib in Resources */, DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -285,15 +292,16 @@ DC8963C01E38EEB900828B09 /* SSHKeySettingTableViewController.swift in Sources */, DCA0499C1E3362F400522E8F /* PGPKeySettingTableViewController.swift in Sources */, DC7E6EEA1E432E48006C2443 /* Password.swift in Sources */, + DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */, DC1208561E35D0BA0042942E /* PasswordsTableViewController.swift in Sources */, DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */, DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */, DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */, + DC4914991E434600007FF592 /* PasswordDetailTableViewController.swift in Sources */, DC8963BE1E38AD8300828B09 /* GitRepositoryAuthenticationSettingTableViewController.swift in Sources */, DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */, DCA049981E33586A00522E8F /* DefaultKeys.swift in Sources */, DCA0499E1E33BAC100522E8F /* Globals.swift in Sources */, - DC3DC8391E2F63240062A988 /* PasswordDetailViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index 1c2e24d..d20d3ba 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -36,7 +36,7 @@ - + @@ -497,39 +497,22 @@ - - + + - - - - - - + + - - - - - Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/pass/LabelTableViewCell.swift b/pass/LabelTableViewCell.swift new file mode 100644 index 0000000..d6d087b --- /dev/null +++ b/pass/LabelTableViewCell.swift @@ -0,0 +1,24 @@ +// +// LabelTableViewCell.swift +// pass +// +// Created by Mingshen Sun on 2/2/2017. +// Copyright © 2017 Bob Sun. All rights reserved. +// + +import UIKit + +class LabelTableViewCell: UITableViewCell { + + @IBOutlet weak var contentLabel: UILabel! + @IBOutlet weak var titleLabel: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + } + +} diff --git a/pass/LabelTableViewCell.xib b/pass/LabelTableViewCell.xib new file mode 100644 index 0000000..e6c83b6 --- /dev/null +++ b/pass/LabelTableViewCell.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pass/Password.swift b/pass/Password.swift index d06a787..db40da2 100644 --- a/pass/Password.swift +++ b/pass/Password.swift @@ -12,9 +12,9 @@ import SwiftyUserDefaults class Password { var name = "" var password = "" - var additions: [String: String]? + var additions: [String: String] - init(name: String, password: String, additions: [String: String]?) { + init(name: String, password: String, additions: [String: String]) { self.name = name self.password = password self.additions = additions diff --git a/pass/PasswordDetailTableViewController.swift b/pass/PasswordDetailTableViewController.swift new file mode 100644 index 0000000..94194fe --- /dev/null +++ b/pass/PasswordDetailTableViewController.swift @@ -0,0 +1,52 @@ +// +// PasswordDetailTableViewController.swift +// pass +// +// Created by Mingshen Sun on 2/2/2017. +// Copyright © 2017 Bob Sun. All rights reserved. +// + +import UIKit + +class PasswordDetailTableViewController: UITableViewController { + var passwordEntity: PasswordEntity? + + struct FormCell { + var title: String + var content: String + } + + var formData = [[FormCell]]() + + override func viewDidLoad() { + super.viewDidLoad() + tableView.register(UINib(nibName: "LabelTableViewCell", bundle: nil), forCellReuseIdentifier: "labelCell") + let password = passwordEntity!.decrypt()! + formData.append([]) + if let username = password.additions["Username"] { + formData[0].append(FormCell(title: "username", content: username)) + } + formData[0].append(FormCell(title: "password", content: password.password)) + } + + + override func numberOfSections(in tableView: UITableView) -> Int { + return formData.count + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return formData[section].count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "labelCell", for: indexPath) as! LabelTableViewCell + cell.titleLabel.text = formData[indexPath.section][indexPath.row].title + cell.contentLabel.text = formData[indexPath.section][indexPath.row].content + return cell + } + + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 52 + } + +} diff --git a/pass/PasswordDetailViewController.swift b/pass/PasswordDetailViewController.swift deleted file mode 100644 index 0b038d0..0000000 --- a/pass/PasswordDetailViewController.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// PasswordDetailViewController.swift -// pass -// -// Created by Mingshen Sun on 18/1/2017. -// Copyright © 2017 Bob Sun. All rights reserved. -// - -import UIKit -import SwiftyUserDefaults - -class PasswordDetailViewController: UIViewController { - - @IBOutlet weak var passwordTextView: UITextView! - var passwordEntity: PasswordEntity? - - override func viewDidLoad() { - super.viewDidLoad() - let password = passwordEntity!.decrypt()! - passwordTextView.text = password.password - } -} diff --git a/pass/PasswordsTableViewController.swift b/pass/PasswordsTableViewController.swift index 31650e5..618b913 100644 --- a/pass/PasswordsTableViewController.swift +++ b/pass/PasswordsTableViewController.swift @@ -134,7 +134,7 @@ class PasswordsTableViewController: UITableViewController { override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "showPasswordDetail" { - if let viewController = segue.destination as? PasswordDetailViewController { + if let viewController = segue.destination as? PasswordDetailTableViewController { let selectedIndexPath = self.tableView.indexPath(for: sender as! UITableViewCell)! let index = sections[selectedIndexPath.section].index + selectedIndexPath.row let password: PasswordEntity