Messagekit: Remove MessagesLayoutDelegate methods that size cell contents

Created on 18 Mar 2018  路  2Comments  路  Source: MessageKit/MessageKit

We have to remove the MessagesLayoutDelegate methods that are responsible for sizing cell content and replace it with properties on MessagesCollectionViewFlowLayout.

Example from:

func avatarSize(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGSize

Example to:

var incomingAvatarSize: CGSize 
var outgoingAvatarSize: CGSize 

This is a non-backward compatible change but it's pretty much necessary to move forwards.

Reasoning

The delegate methods don't maintain any state so we can't cache any information related to the layout. If we make this change we can start caching the size of already seen text for scrolling.

Related: #504 #519 #555

enhancement

Most helpful comment

We can solve point 1 by adding a property for every MessageType... that's a bit much though...

var textIncomingAvatarSize: CGSize
var photoIncomingAvatarSize: CGSize
// ... etc

I guess it would be a really good idea to ping @MessageKit/contributors in this situation. This is a pretty big change

All 2 comments

This will introduce 2 limitations:

  1. You can't give different MessageTypes different layouts
  2. You can't make a layout dynamic over the IndexPath (this is a good thing IMO)

You can see this being worked on in #555

I know progress has been really slow, we're basically just rolling back to how JSQ handles things.
cc @zhongwuzw @nathantannar4 @cwalo

We can solve point 1 by adding a property for every MessageType... that's a bit much though...

var textIncomingAvatarSize: CGSize
var photoIncomingAvatarSize: CGSize
// ... etc

I guess it would be a really good idea to ping @MessageKit/contributors in this situation. This is a pretty big change

Was this page helpful?
0 / 5 - 0 ratings