Maybe I missed something, but it seems to me that making the avatar completely disappear (with its space in order for the bubbles to start at the edges as in Whatsapp) is not possible. Especially in non-group chats I think this is nice to have, as it removes visual redundancy and allows better use of the available space.
@Jeyhey You just have to return a size of .zero from the avatarSize(for: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGSize method 馃槈
Wow, this project impresses me more every day. Nice implementation!
How do we do it with 1.0 since "avatarSize(for:at:in) has been removed in MessageKit 1.0."
@mypark
func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)
You can set it to hidden in this method 鈽濓笍
still seems to take up space however... ok I see the other github thread about setting the size to zero as well. Seems to work except for the bug about it still pushing the bottom labels out. I'll follow https://github.com/MessageKit/MessageKit/pull/699
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
layout.attributedTextMessageSizeCalculator.outgoingAvatarSize = .zero
layout.attributedTextMessageSizeCalculator.incomingAvatarSize = .zero
layout.textMessageSizeCalculator.outgoingAvatarSize = .zero
layout.textMessageSizeCalculator.incomingAvatarSize = .zero
layout.photoMessageSizeCalculator.outgoingAvatarSize = .zero
layout.photoMessageSizeCalculator.incomingAvatarSize = .zero
layout.videoMessageSizeCalculator.outgoingAvatarSize = .zero
layout.videoMessageSizeCalculator.incomingAvatarSize = .zero
layout.locationMessageSizeCalculator.outgoingAvatarSize = .zero
layout.locationMessageSizeCalculator.incomingAvatarSize = .zero
layout.emojiMessageSizeCalculator.incomingAvatarSize = .zero
layout.emojiMessageSizeCalculator.outgoingAvatarSize = .zero
}
@mypark How did you end up with bottom label positioning. Setting all sizes to zero like you showed didn't work for me
Update for in version 3.1.0
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
//
// set avatar size zero
//
layout.setMessageIncomingAvatarSize(.zero)
layout.setMessageOutgoingAvatarSize(.zero)
//
// set top\bottom label position
//
layout.setMessageOutgoingMessageTopLabelAlignment(LabelAlignment(textAlignment: .right, textInsets: UIEdgeInsets(top: 0, left:0, bottom: 0, right: 10)))
layout.setMessageIncomingMessageTopLabelAlignment(LabelAlignment(textAlignment: .left, textInsets: UIEdgeInsets(top: 0, left:10, bottom: 0, right: 0)))
layout.setMessageOutgoingMessageBottomLabelAlignment(LabelAlignment(textAlignment: .right, textInsets: UIEdgeInsets(top: 0, left:0, bottom: 0, right: 10)))
layout.setMessageIncomingCellBottomLabelAlignment(LabelAlignment(textAlignment: .left, textInsets: UIEdgeInsets(top: 0, left:10, bottom: 0, right: 0)))
}
Most helpful comment
@Jeyhey You just have to return a size of
.zerofrom theavatarSize(for: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGSizemethod 馃槈