- added open var scrollsToBottomOnFirstLayout (#213)

Added open var scrollsToBottomOnFirstLayout
This commit is contained in:
Francesco Deliro
2017-10-03 01:47:48 +02:00
committed by Steven Deutsch
parent ff9669b44a
commit ea00a643ca
3 changed files with 15 additions and 2 deletions
+7 -2
View File
@@ -5,7 +5,9 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
--------------------------------------
## Upcoming release
### Added
- **Breaking Change** `.custom((MessageContainerView)->Void)` case to `MessageStyle` enum.
[#163](https://github.com/MessageKit/MessageKit/pull/163) by [@SD10](https://github.com/SD10).
@@ -21,6 +23,9 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
- `animationBlockForLocation(message:indexPath:messagesCollectionView)` method to `LocationMessageDisplayDelegate` to customize the display animation of the location message's map.
[#210](https://github.com/MessageKit/MessageKit/pull/210) by [@etoledom](https://github.com/etoledom).
- `scrollsToBottomOnFirstLayout` property to automatically scroll to the bottom of `MessagesCollectionView` on first load.
[#213](https://github.com/MessageKit/MessageKit/pull/213) by [@FraDeliro](https://github.com/FraDeliro).
### Fixed
- `MessageInputBar` now correctly sizes itself when breaking its max height or pasting in large amounts of text
@@ -36,6 +41,7 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
[#174](https://github.com/MessageKit/MessageKit/pull/174) by [@etoledom](https://github.com/etoledom).
### Changed
- **Breaking Change** `snapshotOptionsForLocation` method is now part of `LocationMessageDisplayDelegate`.
[#150](https://github.com/MessageKit/MessageKit/pull/150) by [@etoledom](https://github.com/etoledom).
@@ -62,11 +68,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
[#177](https://github.com/MessageKit/MessageKit/pull/177) by [@cwalo](https://github.com/cwalo).
### Removed
- **Breaking Change** `cellTopLabelInsets` and `cellBottomLabelInsets` from `MessagesCollectionViewFlowLayout`.
[#166](https://github.com/MessageKit/MessageKit/pull/166) by [@SD10](https://github.com/SD10).
----------------
## [[Prerelease] 0.8.2](https://github.com/MessageKit/MessageKit/releases/tag/0.8.2)
### Added
- Support for Swift 4
@@ -39,6 +39,7 @@ class ConversationViewController: MessagesViewController {
messagesCollectionView.messagesDisplayDelegate = self
messagesCollectionView.messageCellDelegate = self
messageInputBar.delegate = self
scrollsToBottomOnFirstLayout = true //default false
navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "ic_keyboard"),
style: .plain,
+7
View File
@@ -31,6 +31,8 @@ open class MessagesViewController: UIViewController {
open var messagesCollectionView = MessagesCollectionView(frame: .zero, collectionViewLayout: MessagesCollectionViewFlowLayout())
open var messageInputBar = MessageInputBar()
open var scrollsToBottomOnFirstLayout: Bool = false
private var isFirstLayout: Bool = true
@@ -70,6 +72,11 @@ open class MessagesViewController: UIViewController {
messagesCollectionView.contentInset.bottom = messageInputBar.frame.height
messagesCollectionView.scrollIndicatorInsets.bottom = messageInputBar.frame.height
isFirstLayout = false
//Scroll to bottom at first load
if scrollsToBottomOnFirstLayout {
messagesCollectionView.scrollToBottom(animated: false)
}
}
}