Merge pull request #530 from clayellis/feature/auto-update-send

Add boolean flag to disable auto updating send button enabled state
This commit is contained in:
Steven Deutsch
2018-02-23 23:25:25 -06:00
committed by GitHub
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -6,7 +6,12 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
## Upcoming release
### [[Prerelease] 0.13.1](https://github.com/MessageKit/MessageKit/releases/tag/0.13.1)
### Added
- Added `shouldManageSendButtonEnabledState` to `MessageInputBar` to disable automatically managing `MessageInputBar.sendButton`'s `isEnabled` state when text changes. (Default value is `true`).
[#530](https://github.com/MessageKit/MessageKit/pull/530) by [@clayellis](https://github.com/clayellis).
## [[Prerelease] 0.13.1](https://github.com/MessageKit/MessageKit/releases/tag/0.13.1)
### Fixed
+6 -1
View File
@@ -136,6 +136,9 @@ open class MessageInputBar: UIView {
$0.messageInputBar?.didSelectSendButton()
}
}()
/// A boolean that determines whether the sendButton's `isEnabled` state should be managed automatically.
open var shouldManageSendButtonEnabledState = true
/**
The anchor constants that inset the contentView
@@ -670,7 +673,9 @@ open class MessageInputBar: UIView {
open func textViewDidChange() {
let trimmedText = inputTextView.text.trimmingCharacters(in: .whitespacesAndNewlines)
sendButton.isEnabled = !trimmedText.isEmpty || inputTextView.images.count > 0
if shouldManageSendButtonEnabledState {
sendButton.isEnabled = !trimmedText.isEmpty || inputTextView.images.count > 0
}
inputTextView.placeholderLabel.isHidden = !inputTextView.text.isEmpty
items.forEach { $0.textViewDidChangeAction(with: inputTextView) }