remove passphrase cell and add passphrase alert dialog

This commit is contained in:
Bob Sun 2017-02-17 14:58:27 +08:00
parent 7598c81da8
commit a3a09beebf
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 153 additions and 132 deletions

View file

@ -11,14 +11,27 @@ import SwiftyUserDefaults
class PGPKeyArmorSettingTableViewController: UITableViewController {
@IBOutlet weak var armorPublicKeyTextView: UITextView!
@IBOutlet weak var passphraseTextField: UITextField!
@IBOutlet weak var armorPrivateKeyTextView: UITextView!
var pgpPassphrase: String?
override func viewDidLoad() {
super.viewDidLoad()
armorPublicKeyTextView.text = Defaults[.pgpPublicKeyArmor]
armorPrivateKeyTextView.text = Defaults[.pgpPrivateKeyArmor]
passphraseTextField.text = Defaults[.pgpKeyPassphrase]
pgpPassphrase = Defaults[.pgpKeyPassphrase]
}
@IBAction func save(_ sender: Any) {
let alert = UIAlertController(title: "Phassphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in
self.pgpPassphrase = alert.textFields?.first?.text
self.performSegue(withIdentifier: "savePGPKeySegue", sender: self)
}))
alert.addTextField(configurationHandler: {(textField: UITextField!) in
textField.text = self.pgpPassphrase
textField.isSecureTextEntry = true
})
self.present(alert, animated: true, completion: nil)
}
}