Add support for emoji-only messages#222
Conversation
|
I do have a question, though. Should I force the "text" MessageData to use this "emoji" MessageData or should I leave it up to the user? I know the issue talks about parsing, but was unsure if I should parse the message at all. |
|
@SirArkimedes This is a good start!! 👍 I was hoping we didn't have to create another subclass of I'll be able to review this a little more in-depth later. About parsing, nothing to do there. It should be the user's responsibility to determine if a message contains only emojis or not. cc @cwalo for some extra eyes |
|
Re: parsing, you could add a utility method that trivially detects emoji (minus spaces), and add an example in documentation of how to use wire this together to return the right message type. |
Adds a new message type that handles text that doubles the font size and removes the message background to model how iMessage displays emoji-only messages.
|
If you don't want to embed emoji detection code, I'd suggest a comment pointing users at: Using these two extensions, the appropriate logic is: |
Removes EmojiTextCell and takes what it used to doand adds it to TextMessageCell.
|
I can understand that adding a comment to make it clear how to use the emoji type, but where would I put that comment? |
|
@SirArkimedes This would be reflected in external docs. Don't worry about merging |
| // MARK: - Properties | ||
|
|
||
| open var messageLabelFont: UIFont | ||
| open var emojiLabelFont: UIFont |
There was a problem hiding this comment.
I think this should be private if we're going to override it by doubling messageLabelFont
| @@ -30,6 +30,8 @@ open class MessagesCollectionViewFlowLayout: UICollectionViewFlowLayout { | |||
| // MARK: - Properties | |||
|
|
|||
| open var messageLabelFont: UIFont | |||
There was a problem hiding this comment.
This probably needs a didSet to reflect the changes in emojiLabelFont
| case .text, .attributedText: | ||
| let cell = messagesCollectionView.dequeueReusableCell(TextMessageCell.self, for: indexPath) | ||
| case .text, .attributedText, .emoji: | ||
| let cell = collectionView.dequeueReusableCell(TextMessageCell.self, for: indexPath) |
There was a problem hiding this comment.
this should be messagesCollectionView but maybe its because this branch is not current with v0.9.0
| case .attributedText(let text): | ||
| messageContentView.attributedText = text | ||
| case .emoji(let text): | ||
| messageContainerView.backgroundColor = .clear |
There was a problem hiding this comment.
Yeah, I was thinking how to handle the style. Maybe we shouldn't set the color to .clear here and expect the user to apply a style of .none to the .emoji case.
There was a problem hiding this comment.
I was originally thinking the same thing, by just setting the style to .none here. But the MessageCollectionViewCell sets the background color from the delegate, which creates just a colored rectangle behind the message.
There was a problem hiding this comment.
Tough one. Can we just do this in the delegate then? You'll have to do an if case let or switch on the MessageType. If it is emoji return a .clear background color. Until we find a better way to handle it.
There was a problem hiding this comment.
Moved to the delegate.
Also adds a didSet to the main font, to set the emoji’s font to double the set font.
|
@SirArkimedes This looks good to me! We need to add a CHANGELOG entry under Please take care to follow the existing CHANGELOG in v0.9.0. We also have a CHANGELOG_GUIDELINES file in that PR |
Adds .emoji(String) breaking change to CHANGELONG.md.
|
Done! |
SD10
left a comment
There was a problem hiding this comment.
@SirArkimedes Thank you for your contribution to MessageKit 💯 🎉 I've invited you to join the MessageKit organization. No pressure if you aren't feeling up to it 😎
Adds a new message type that handles text that doubles the font size and removes the message background to model how iMessage displays emoji-only messages.
Issue: #182
Previews of how they look: