From 8bb411de60a00b8c4f18dfada534416e5c10fea9 Mon Sep 17 00:00:00 2001 From: Clay Ellis Date: Tue, 20 Feb 2018 08:54:53 -0700 Subject: [PATCH 1/4] Add boolean flag to disabled auto updating send button enabled state on text did change --- Sources/Views/MessageInputBar.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Views/MessageInputBar.swift b/Sources/Views/MessageInputBar.swift index cbc1dbb4..2b467655 100644 --- a/Sources/Views/MessageInputBar.swift +++ b/Sources/Views/MessageInputBar.swift @@ -136,6 +136,9 @@ open class MessageInputBar: UIView { $0.messageInputBar?.didSelectSendButton() } }() + + /// A boolean that determines if the sendButton's `isEnabled` state should be auto updated on text changes. + open var shouldAutoUpdateSendButtonEnabledStateOnTextDidChange = 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 shouldAutoUpdateSendButtonEnabledStateOnTextDidChange { + sendButton.isEnabled = !trimmedText.isEmpty || inputTextView.images.count > 0 + } inputTextView.placeholderLabel.isHidden = !inputTextView.text.isEmpty items.forEach { $0.textViewDidChangeAction(with: inputTextView) } From edc71e2f91f2a0cfb51a48c4ec24af2fa437c314 Mon Sep 17 00:00:00 2001 From: Clay Ellis Date: Wed, 21 Feb 2018 22:32:27 -0700 Subject: [PATCH 2/4] Rename shouldAutoUpdateSendButtonEnabledStateOnTextDidChange > shouldManageSendButtonEnabledState and update documentation comment. --- Sources/Views/MessageInputBar.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Views/MessageInputBar.swift b/Sources/Views/MessageInputBar.swift index 2b467655..a75f3480 100644 --- a/Sources/Views/MessageInputBar.swift +++ b/Sources/Views/MessageInputBar.swift @@ -137,8 +137,8 @@ open class MessageInputBar: UIView { } }() - /// A boolean that determines if the sendButton's `isEnabled` state should be auto updated on text changes. - open var shouldAutoUpdateSendButtonEnabledStateOnTextDidChange = true + /// 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 @@ -673,7 +673,7 @@ open class MessageInputBar: UIView { open func textViewDidChange() { let trimmedText = inputTextView.text.trimmingCharacters(in: .whitespacesAndNewlines) - if shouldAutoUpdateSendButtonEnabledStateOnTextDidChange { + if shouldManageSendButtonEnabledState { sendButton.isEnabled = !trimmedText.isEmpty || inputTextView.images.count > 0 } inputTextView.placeholderLabel.isHidden = !inputTextView.text.isEmpty From b625b8a4afb51341cf564e7fc75f9d8f73c121e3 Mon Sep 17 00:00:00 2001 From: Clay Ellis Date: Wed, 21 Feb 2018 22:37:08 -0700 Subject: [PATCH 3/4] Add entry to CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc95c3c6..b80a0121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa See the example project for an updated use case. [#423](https://github.com/MessageKit/MessageKit/pull/423) by [@nathantannar4](https://github.com/nathantannar4). +- Added `shouldManageSendButtonEnabledState` to `MessageInputBar` to disable automatically managing `MessageInputBar.sendButton`'s `isEnabled` state when text changes. +This addition does not current default behavior (the default value is `true`). +[#530](https://github.com/MessageKit/MessageKit/pull/530) by [@clayellis](https://github.com/clayellis). + ### Removed - **Breaking Change** Removed `avatar(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)` method of `MessagesDataSource`, use `configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)` instead. From b65c99db33b226a8f8ba62cbbdf82a64fd7ebd1d Mon Sep 17 00:00:00 2001 From: Steven Deutsch Date: Wed, 21 Feb 2018 23:56:58 -0600 Subject: [PATCH 4/4] Move CHANGELOG entry --- CHANGELOG.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b80a0121..7539df15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -44,10 +49,6 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa See the example project for an updated use case. [#423](https://github.com/MessageKit/MessageKit/pull/423) by [@nathantannar4](https://github.com/nathantannar4). -- Added `shouldManageSendButtonEnabledState` to `MessageInputBar` to disable automatically managing `MessageInputBar.sendButton`'s `isEnabled` state when text changes. -This addition does not current default behavior (the default value is `true`). -[#530](https://github.com/MessageKit/MessageKit/pull/530) by [@clayellis](https://github.com/clayellis). - ### Removed - **Breaking Change** Removed `avatar(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)` method of `MessagesDataSource`, use `configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)` instead.