MessagesDisplayDelegate
public protocol MessagesDisplayDelegate: AnyObject
A protocol used by the MessagesViewController
to customize the appearance of a MessageContentCell
.
-
messageStyle(for:at:in:)
Default implementationSpecifies the
MessageStyle
to be used for aMessageContainerView
.Note
The default value returned by this method is
MessageStyle.bubble
.Default Implementation
Declaration
Swift
func messageStyle(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageStyle
Parameters
message
The
MessageType
that will be displayed by this cell.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed. -
backgroundColor(for:at:in:)
Default implementationSpecifies the background color of the
MessageContainerView
.Note
The default value is
UIColor.clear
for emoji messages. For all otherMessageKind
cases, the color depends on theSender
.Current sender: Green
All other senders: Gray
Default Implementation
Declaration
Swift
func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor
Parameters
message
The
MessageType
that will be displayed by this cell.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed. -
messageHeaderView(for:in:)
Default implementationThe section header to use for a given
IndexPath
.Default Implementation
Declaration
Swift
func messageHeaderView(for indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageReusableView
Parameters
message
The
MessageType
that will be displayed for this header.indexPath
The
IndexPath
of the header.messagesCollectionView
The
MessagesCollectionView
in which this header will be displayed. -
messageFooterView(for:in:)
Default implementationThe section footer to use for a given
IndexPath
.Default Implementation
Declaration
Swift
func messageFooterView(for indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageReusableView
Parameters
indexPath
The
IndexPath
of the footer.messagesCollectionView
The
MessagesCollectionView
in which this footer will be displayed. -
configureAvatarView(_:for:at:in:)
Default implementationUsed to configure the
AvatarView
‘s image in aMessageContentCell
class.Note
The default image configured by this method is
?
.Default Implementation
Declaration
Swift
func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)
Parameters
avatarView
The
AvatarView
of the cell.message
The
MessageType
that will be displayed by this cell.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed.
-
textColor(for:at:in:)
Default implementationSpecifies the color of the text for a
TextMessageCell
.Note
The default value returned by this method is determined by the messages
Sender
.Current sender: UIColor.white
All other senders: UIColor.darkText
Default Implementation
Declaration
Swift
func textColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor
Parameters
message
A
MessageType
with aMessageKind
case of.text
to which the color will apply.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed. -
enabledDetectors(for:at:in:)
Default implementationSpecifies the
DetectorType
s to check for theMessageType
‘s text against.Note
This method returns an empty array by default.
Default Implementation
Declaration
Swift
func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType]
Parameters
message
A
MessageType
with aMessageKind
case of.text
or.attributedText
to which the detectors will apply.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed. -
detectorAttributes(for:and:at:)
Default implementationSpecifies the attributes for a given
DetectorType
Default Implementation
Declaration
Swift
func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedStringKey: Any]
Parameters
detector
The
DetectorType
for the applied attributes.message
A
MessageType
with aMessageKind
case of.text
or.attributedText
to which the detectors will apply.indexPath
The
IndexPath
of the cell.
-
snapshotOptionsForLocation(message:at:in:)
Default implementationUsed to configure a
LocationMessageSnapshotOptions
instance to customize the map image on the given location message.Default Implementation
Declaration
Swift
func snapshotOptionsForLocation(message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> LocationMessageSnapshotOptions
Parameters
message
A
MessageType
with aMessageKind
case of.location
.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
requesting the information.Return Value
The LocationMessageSnapshotOptions instance with the options to customize map style.
-
annotationViewForLocation(message:at:in:)
Default implementationUsed to configure the annoation view of the map image on the given location message.
Default Implementation
Declaration
Swift
func annotationViewForLocation(message: MessageType, at indexPath: IndexPath, in messageCollectionView: MessagesCollectionView) -> MKAnnotationView?
Parameters
message
A
MessageType
with aMessageKind
case of.location
.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
requesting the information.Return Value
The
MKAnnotationView
to use as the annotation view. -
animationBlockForLocation(message:at:in:)
Default implementationAsk the delegate for a custom animation block to run when whe map screenshot is ready to be displaied in the given location message. The animation block is called with the
UIImageView
to be animated.Default Implementation
Declaration
Swift
func animationBlockForLocation(message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> ((UIImageView) -> Void)?
Parameters
message
A
MessageType
with aMessageKind
case of.location
.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
requesting the information.Return Value
The animation block to use to apply the location image.
-
configureMediaMessageImageView(_:for:at:in:)
Default implementationUsed to configure the
UIImageView
of a `MediaMessageCell.Default Implementation
Declaration
Swift
func configureMediaMessageImageView(_ imageView: UIImageView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)
Parameters
imageView
The
UIImageView
of the cell.message
The
MessageType
that will be displayed by this cell.indexPath
The
IndexPath
of the cell.messagesCollectionView
The
MessagesCollectionView
in which this cell will be displayed.