Use lazy var for touchIDSwitch to simplify code

This commit is contained in:
Bob Sun 2017-03-02 16:51:46 +08:00
parent 90c468acef
commit 2d50a40370
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -14,7 +14,12 @@ import PasscodeLock
class SettingsTableViewController: UITableViewController {
let touchIDSwitch = UISwitch(frame: CGRect.zero)
lazy var touchIDSwitch: UISwitch = {
let uiSwitch = UISwitch(frame: CGRect.zero)
uiSwitch.onTintColor = Globals.blue
uiSwitch.addTarget(self, action: #selector(touchIDSwitchAction), for: UIControlEvents.valueChanged)
return uiSwitch
}()
@IBOutlet weak var pgpKeyTableViewCell: UITableViewCell!
@IBOutlet weak var touchIDTableViewCell: UITableViewCell!
@ -170,9 +175,7 @@ class SettingsTableViewController: UITableViewController {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(SettingsTableViewController.actOnPasswordStoreErasedNotification), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil)
self.passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults[.gitRepositoryURL]?.host
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)
setPGPKeyTableViewCellDetailText()
setPasswordRepositoryTableViewCellDetailText()
setTouchIDSwitch()