Messagekit: Changes for MessageLayoutDelegate methods `cellTopLabelAlignment(for:at:in:)` and `cellBottomLabelAlignment(for:at:in)` not documented in release 1.0.

Created on 25 Apr 2019  路  6Comments  路  Source: MessageKit/MessageKit

These methods were deprecated in 1.0, but I don't know what the replacements are. I can't find the documentation in the release notes (https://github.com/MessageKit/MessageKit/releases/tag/1.0.0-beta.1).

The change is here: https://github.com/MessageKit/MessageKit/commit/56418d2c70f9921df2f7cac342219e34a3ed0726#diff-8512f3490316f9bdb61bee0179f73971

but I can't find the discussion of it.

I'm also trying to update avatarPosition(for:at:in:), avatarSize(for:at:in), messagePadding(for:at:in:), heightForLocation(_:at:with:in:), heightForMedia(_:at:with:in:), and widthForMedia(_:at:with:in:).

I can't find anything in the changelog for those, either. Can someone point me in the right direction? I'm trying to upgrade to 2.0

API breaking discussion documentation question

Most helpful comment

I really liked the old API too 馃槀 It was nice when you know what you're doing. Maybe we can do something about this

All 6 comments

It's a property of the layout, please see the example where we show many cases of changing the layout.

Sent with GitHawk

Just in case someone is looking for something similar to a solution this is my implementation, to be honest i really enjoyed the avatarSize(for:at:in), messagePadding(for:at:in:), heightForLocation(:at:with:in:), heightForMedia(:at:with:in:), and widthForMedia(_:at:with:in:) methods.
Anyway:
class PhotoMediaMessageCalculator:MediaMessageSizeCalculator { override init(layout: MessagesCollectionViewFlowLayout?) { super.init(layout: layout) } override func messageContainerSize(for message: MessageType) -> CGSize { switch message.kind { case .photo(_): return CGSize(width: 120, height: 120) default: return super.messageContainerSize(for: message) } } }

And on your didload

let layout = messageKit.messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout layout?.photoMessageSizeCalculator = PhotoMediaMessageCalculator(layout: layout)

I really liked the old API too 馃槀 It was nice when you know what you're doing. Maybe we can do something about this

Hey @Wilsonilo @SD10, the above code works but my image stays at the center of the screen, it doesn't align with other messages. Any idea why?

Update guys I figured it out, since I was hiding my outgoing avatars I had to call layout?.photoMessageSizeCalculator.outgoingAvatarSize = .zero after layout?.photoMessageSizeCalculator = PhotoMediaMessageCalculator(layout: layout). I was calling it before and it wasn't working. Thanks guys.

I believe everything is as expected and there is currently no plan on bringing this back. Example project is also up-to-date. I'll close this then. :)

Was this page helpful?
0 / 5 - 0 ratings