Merge pull request #29 from andreaantonioni/v0.3.0

Change send button UI and implemented disabled logic.
This commit is contained in:
Steven Deutsch
2017-08-05 14:39:09 -05:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -47,7 +47,12 @@ open class MessageInputBar: UIView, UITextViewDelegate {
let sendButton = UIButton()
sendButton.setTitle("Send", for: .normal)
sendButton.setTitleColor(.lightGray, for: .normal)
sendButton.setTitleColor(.sendButtonBlue, for: .normal)
sendButton.setTitleColor(UIColor.sendButtonBlue.withAlphaComponent(0.3), for: .highlighted)
sendButton.setTitleColor(.lightGray, for: .disabled)
sendButton.titleLabel?.font = UIFont.preferredFont(forTextStyle: .headline)
sendButton.isEnabled = false
return sendButton
}()
@@ -91,6 +96,8 @@ open class MessageInputBar: UIView, UITextViewDelegate {
}
public func textViewDidChange(_ textView: UITextView) {
let trimmedText = textView.text.trimmingCharacters(in: .whitespacesAndNewlines)
sendButton.isEnabled = !trimmedText.isEmpty && textView.text != "New Message"
invalidateIntrinsicContentSize()
}
+2
View File
@@ -32,4 +32,6 @@ extension UIColor {
static let inputBarGray = UIColor(colorLiteralRed: 247/255, green: 247/255, blue: 247/255, alpha: 1.0)
static let sendButtonBlue = UIColor(colorLiteralRed: 15/255, green: 135/255, blue: 255/255, alpha: 1.0)
}