change a lot, the structure will be stable this time
This commit is contained in:
parent
8e997cc868
commit
36bf40741c
14 changed files with 579 additions and 208 deletions
|
|
@ -12,53 +12,12 @@ import Result
|
|||
import SVProgressHUD
|
||||
|
||||
class PasswordTableViewController: UITableViewController {
|
||||
private var passwordNameArray = [String]()
|
||||
private var passwordEntities: [PasswordEntity]?
|
||||
|
||||
func temporaryURL(forPurpose purpose: String) -> URL {
|
||||
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
|
||||
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
|
||||
print("\(NSHomeDirectory())/vault")
|
||||
return URL(fileURLWithPath: path)
|
||||
}
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(PasswordTableViewController.actOnPasswordUpdatedNotification), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
|
||||
|
||||
// SVProgressHUD.setDefaultMaskType(SVProgressHUDMaskType.black)
|
||||
// SVProgressHUD.show(withStatus: "Cloning Password Repository")
|
||||
//
|
||||
// let remoteRepoURL = URL(string: "https://github.com/mssun/public-password-store.git")
|
||||
// let localURL = self.temporaryURL(forPurpose: "public-remote-clone")
|
||||
// DispatchQueue.global(qos: .userInitiated).async {
|
||||
// let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL)
|
||||
// if case .success(let clonedRepo) = cloneResult {
|
||||
// let latestCommit: Result<Commit, NSError> = clonedRepo
|
||||
// .HEAD()
|
||||
// .flatMap { clonedRepo.commit($0.oid) }
|
||||
// print("localURL \(localURL.path)")
|
||||
// if let commit = latestCommit.value {
|
||||
// print("Latest Commit: \(commit.message) by \(commit.author.name)")
|
||||
// } else {
|
||||
// print("Could not get commit: \(latestCommit.error)")
|
||||
// }
|
||||
// let fd = FileManager.default
|
||||
// fd.enumerator(atPath: localURL.path)?.forEach({ (e) in
|
||||
// if let e = e as? String, let url = URL(string: e) {
|
||||
// if url.pathExtension == "gpg" {
|
||||
// self.passwordNameArray.append(url.lastPathComponent);
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// DispatchQueue.main.async {
|
||||
// SVProgressHUD.dismiss()
|
||||
// self.tableView.reloadData()
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
func actOnPasswordUpdatedNotification() {
|
||||
|
|
@ -71,11 +30,19 @@ class PasswordTableViewController: UITableViewController {
|
|||
return passwordEntities!.count
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "passwordTableViewCell", for: indexPath)
|
||||
cell.textLabel?.text = passwordEntities![indexPath.row].name
|
||||
return cell
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if segue.identifier == "showPasswordDetail" {
|
||||
if let viewController = segue.destination as? PasswordDetailViewController {
|
||||
let selectedRow = tableView.indexPathForSelectedRow!.row
|
||||
viewController.passwordEntity = passwordEntities![selectedRow]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue