From cfbcdb6900c0a95d6a97f232616d86d1d19d8390 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Thu, 9 Feb 2017 11:31:49 +0800 Subject: [PATCH] act on erase data on Settings controller --- .../SettingsTableViewController.swift | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index 559c389..678e38f 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -111,9 +111,15 @@ class SettingsTableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() + NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil) touchIDSwitch.onTintColor = UIColor(displayP3Red: 0, green: 122.0/255, blue: 1, alpha: 1) touchIDTableViewCell.accessoryView = touchIDSwitch touchIDSwitch.addTarget(self, action: #selector(touchIDSwitchAction), for: UIControlEvents.valueChanged) + if Defaults[.pgpKeyID] == "" { + pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" + } else { + pgpKeyTableViewCell.detailTextLabel?.text = Defaults[.pgpKeyID] + } if Defaults[.isTouchIDOn] { touchIDSwitch.isOn = true } else { @@ -127,6 +133,16 @@ class SettingsTableViewController: UITableViewController { } } + func actOnPasswordStoreErasedNotification() { + pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" + touchIDSwitch.isOn = false + self.passcodeTableViewCell.detailTextLabel?.text = "Off" + Globals.passcodeConfiguration.isTouchIDAllowed = false + + let appDelegate = UIApplication.shared.delegate as! AppDelegate + appDelegate.passcodeLockPresenter = PasscodeLockPresenter(mainWindow: appDelegate.window, configuration: Globals.passcodeConfiguration) + } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if tableView.cellForRow(at: indexPath) == passcodeTableViewCell { if Defaults[.passcodeKey] != nil{ @@ -140,11 +156,6 @@ class SettingsTableViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - if Defaults[.pgpKeyID] == "" { - pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" - } else { - pgpKeyTableViewCell.detailTextLabel?.text = Defaults[.pgpKeyID] - } } func touchIDSwitchAction(uiSwitch: UISwitch) {