Typing Indicator Support#776
Conversation
|
When the indicator is animating, the same time I post a message, indicator cell would scroll to the bottom, this scroll animation is what we want? |
|
I think that's how other messaging apps handle it Sent with GitHawk |
|
I'll have to check this animation you guys are talking about. This is a feature that MessageKit will support, but personally I will never use it |
| setTypingIndicatorHidden(!isTyping, animated: true, completion: { _ in | ||
| self.messagesCollectionView.scrollToBottom(animated: true) | ||
| }) | ||
| // defer { |
There was a problem hiding this comment.
This code is commented out, you planning on doing something with it?
There was a problem hiding this comment.
Once this gets merged I will be updating the entire example app with more detailed examples for the TypingIndicator and custom cells.
| /// - updates: A block of code that will be executed during `performBatchUpdates` | ||
| /// when `animated` is `TRUE` or before the `completion` block executes | ||
| /// when `animated` is `FALSE` | ||
| /// - completion: A completion block to execute after the insertion/deletion |
|
|
||
| ### Added | ||
|
|
||
| - **Breaking Change** Added typing indicator support to MessageKit by adding an extra section to `MessagesCollectionView` when needed. This included adding the following views: `BubbleCircle`, `TypingBubble`, `TypingIndicator`, `TypingBubbleCell`. Determine if the section is reserved for the typing indicator with `isSectionReservedForTypingIndicator(_ section: Int) -> Bool`, and set the typing indicators visiability with `setTypingIndicatorHidden(_ isHidden: Bool, animated: Bool, whilePerforming updates: (() -> Void)? = nil, completion: ((Bool) -> Void)?=nil)` |
There was a problem hiding this comment.
This is more a reminder to myself to improve this CHANGELOG entry before merging
There was a problem hiding this comment.
I don't know how we can tell the user that numberOfSections(in collectionView: UICollectionView) would not only return the data source the user provide.
There was a problem hiding this comment.
Yes, this is a valid concern that I have as well. I like the general idea but I haven't gone deep into how this will affect MessageKit
|
Hi guys, are you planning to merge it to dev, and release? We really need this feature in our project |
|
@stasian23 That's the plan but this is lower priority right now. I like the general idea but I haven't thoroughly reviewed the code to see what impact this PR would have |
b978857 to
df05cda
Compare
|
@stasian23 I just rebased the |
| /// when `animated` is `TRUE` or before the `completion` block executes | ||
| /// when `animated` is `FALSE` | ||
| /// - completion: A completion block to execute after the insertion/deletion | ||
| open func setTypingIndicatorHidden(_ isHidden: Bool, animated: Bool, whilePerforming updates: (() -> Void)? = nil, completion: ((Bool) -> Void)?=nil) { |
There was a problem hiding this comment.
completion: ((Bool) -> Void)?=nil,please keep indention between nil.
| let section = messagesCollectionView.numberOfSections | ||
|
|
||
| isTypingIndicatorHidden = isHidden | ||
| if let messagesFlowLayout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout { |
There was a problem hiding this comment.
Maybe guard return would be better, if layout is not MessagesCollectionViewFlowLayout, nothing we can do.
|
|
||
| ### Added | ||
|
|
||
| - **Breaking Change** Added typing indicator support to MessageKit by adding an extra section to `MessagesCollectionView` when needed. This included adding the following views: `BubbleCircle`, `TypingBubble`, `TypingIndicator`, `TypingBubbleCell`. Determine if the section is reserved for the typing indicator with `isSectionReservedForTypingIndicator(_ section: Int) -> Bool`, and set the typing indicators visiability with `setTypingIndicatorHidden(_ isHidden: Bool, animated: Bool, whilePerforming updates: (() -> Void)? = nil, completion: ((Bool) -> Void)?=nil)` |
There was a problem hiding this comment.
I don't know how we can tell the user that numberOfSections(in collectionView: UICollectionView) would not only return the data source the user provide.
| cell.typingBubble.typingIndicator.dotColor = typingBubbleDotColor | ||
| cell.typingBubble.startAnimating() | ||
| return cell | ||
| } |
There was a problem hiding this comment.
Just a suggestion, can we move these things to a separate function? collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) becomes the big function.
There was a problem hiding this comment.
Yeah, it should be a function on the cell
| } | ||
|
|
||
| open func setupSubviews() { | ||
| contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] |
There was a problem hiding this comment.
Thats how other MessageContentCell are set up so I added this for consistency
There was a problem hiding this comment.
Don't copy my code if it's bad (it usually is) 😆
| super.prepareForReuse() | ||
| if typingBubble.isAnimating { | ||
| typingBubble.stopAnimating() | ||
| typingBubble.startAnimating() |
There was a problem hiding this comment.
startAnimating() is not necessary IMO.
There was a problem hiding this comment.
The animations stop when they move off screen, so they need to be restarted when they are about to appear again
There was a problem hiding this comment.
@nathantannar4 May I miss something? you already start it in cellForItemAt. 🤔
There was a problem hiding this comment.
Its required for the cell reusability. If its not initially started in cellForItem then isAnimating will be false
|
Recommendations added |
7c6a567 to
3bc014f
Compare
|
Hey, Is there any progress on this PR ? I hope it can be merged soon :D |
|
2.0 release 😄 Sent with GitHawk |
|
😱😱😱😱😱 |
`dequeuedTypingCell(for indexPath: IndexPath) ` can be used for easily overriding the typing cell and keeps `collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)` clean
5f30df7 to
f5bbd1a
Compare
|
Re-evaluating this PR so that is does not reserve a section |
0ad7c25 to
f5bbd1a
Compare
|
@SD10 @zhongwuzw I am revisiting this so we can get it merged. Are there still hesitations to adding an additional section? I tried using supplementary views but it becomes much more challenging to manage since the indicator ends up needing to be tied to a specific section. There are just many more edge cases that route. |
It's been so long I'll have to re-evaluate reserving the last section for the typing indicator but I do think the highly dynamic nature of a typing indicator would cause a lot of Probably not a good candidate for 3.0 |
|
I agree with @SD10 , can we put the indicator view as a subview of |
This PR adds TypingIndicator support by reserving the last section of the MessageCollectionView as needed. MessageKit will support the iMessage style typing bubble out of the box but you can also implement your own typing indicator cells!