act on erase data on Settings controller

This commit is contained in:
Bob Sun 2017-02-09 11:31:49 +08:00
parent 11613b2059
commit cfbcdb6900
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -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) {