Disable Feedbin add account button until fields are filled

This commit is contained in:
Maurice Parker
2019-10-22 09:06:35 -05:00
parent 1cefea6f29
commit baa9070016
3 changed files with 16 additions and 18 deletions

View File

@@ -36,6 +36,9 @@ class FeedbinAccountViewController: UITableViewController {
} else {
actionButton.setTitle(NSLocalizedString("Add Account", comment: "Update Credentials"), for: .normal)
}
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: emailTextField)
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: passwordTextField)
}
@IBAction func cancel(_ sender: Any) {
@@ -113,6 +116,10 @@ class FeedbinAccountViewController: UITableViewController {
}
}
@objc func textDidChange(_ note: Notification) {
actionButton.isEnabled = !(emailTextField.text?.isEmpty ?? false) && !(passwordTextField.text?.isEmpty ?? false)
}
private func showError(_ message: String) {
presentError(title: "Error", message: message)
}