Enable/Disable New issue submit button based on title text (#519)

* Enable/Disable New issue submit button based on title text (#518)

* Remove target when deinit

* Adds check for title field empty text

* Uses IBAction instead of adding target
This commit is contained in:
Rizwan Mohamed Ibrahim
2017-10-11 23:13:01 +05:30
committed by Ryan Nystrom
parent 8c0bcc7d6f
commit 5b195e931b
2 changed files with 12 additions and 1 deletions

View File

@@ -34,6 +34,9 @@
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<connections>
<action selector="titleFieldEditingChanged:" destination="dCJ-7J-GVo" eventType="editingChanged" id="vFb-te-qq8"/>
</connections>
</textField>
</subviews>
<constraints>

View File

@@ -123,6 +123,7 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg
target: self,
action: #selector(onSend)
)
navigationItem.rightBarButtonItem?.isEnabled = false
}
/// Attempts to sends the current forms information to GitHub, on success will redirect the user to the new issue
@@ -189,5 +190,12 @@ final class NewIssueTableViewController: UITableViewController, UITextFieldDeleg
bodyField.becomeFirstResponder()
return false
}
// MARK: Actions
/// Called when editing changed on the title field, enable/disable submit button based on title text
@IBAction func titleFieldEditingChanged(_ sender: Any) {
navigationItem.rightBarButtonItem?.isEnabled = titleText != nil
}
}