MessageList
is a Composite Component that displays a list of messages and effectively manages real-time operations. It includes various types of messages such as Text Messages, Media Messages, Stickers, and more.
MessageList
is primarily a list of the base component MessageBubble. The MessageBubble Component is utilized to create different types of chat bubbles depending on the message type.
User
or Group
object.onThreadRepliesClick
is triggered when you click on the thread indicator of message bubble. The onThreadRepliesClick
action doesn’t have a predefined behavior. You can override this action using the following code snippet.
onReactionClick
is triggered when you click on a reaction on a message bubble.
onReactionListItemClick
is triggered when you click on the list item of CometChatReactionList on a message bubble.
set(onEmpty:)
method is triggered when the message list is empty in CometChatMessageList.
MessagesRequestBuilder
in the MessageList Component to customize your message list. Numerous options are available to alter the builder to meet your specific needs. For additional details on MessagesRequestBuilder
, please visit MessagesRequestBuilder.
In the example below, we are applying a filter to the messages based on a search substring and for a specific user. This means that only messages that contain the search term and are associated with the specified user will be displayed
uid
and name
of the User in the implementation.Component
. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The MessageList Component does not emit any events of its own.
MessageListStyle
object to the MessageList
component
Global level styling
Property | Description | Code |
---|---|---|
Background Color | Background color with dynamic support for light and dark mode. | CometChatMessageList.style.backgroundColor = UIColor.dynamicColor(lightModeColor: ..., darkModeColor: ...) |
Border Width | Border width for the component. | CometChatMessageList.style.borderWidth = 0 |
Border Color | Border color for the component. | CometChatMessageList.style.borderColor = .clear |
Corner Radius | Corner radius for the component. | CometChatMessageList.style.cornerRadius = CometChatCornerStyle? |
Shimmer Gradient Color 1 | First color of the shimmer gradient. | CometChatMessageList.style.shimmerGradientColor1 = CometChatTheme.backgroundColor04 |
Shimmer Gradient Color 2 | Second color of the shimmer gradient. | CometChatMessageList.style.shimmerGradientColor2 = CometChatTheme.backgroundColor03 |
Empty State Title Color | Text color for the title in the empty state. | CometChatMessageList.style.emptyStateTitleColor = CometChatTheme.textColorPrimary |
Empty State Title Font | Font for the title in the empty state. | CometChatMessageList.style.emptyStateTitleFont = CometChatTypography.Heading3.bold |
Empty State Subtitle Color | Text color for the subtitle in the empty state. | CometChatMessageList.style.emptyStateSubtitleColor = CometChatTheme.textColorSecondary |
Empty State Subtitle Font | Font for the subtitle in the empty state. | CometChatMessageList.style.emptyStateSubtitleFont = CometChatTypography.Body.regular |
Error State Title Color | Text color for the title in the error state. | CometChatMessageList.style.errorStateTitleColor = CometChatTheme.textColorPrimary |
Error State Title Font | Font for the title in the error state. | CometChatMessageList.style.errorStateTitleFont = CometChatTypography.Heading3.bold |
Error State Subtitle Color | Text color for the subtitle in the error state. | CometChatMessageList.style.errorStateSubtitleColor = CometChatTheme.textColorSecondary |
Error State Subtitle Font | Font for the subtitle in the error state. | CometChatMessageList.style.errorStateSubtitleFont = CometChatTypography.Body.regular |
Threaded Message Image | Icon image for threaded messages. | CometChatMessageList.style.threadedMessageImage = UIImage(systemName: "arrow.turn.down.right") |
Error Image | Icon image for error state. | CometChatMessageList.style.errorImage = UIImage(named: "error-icon") |
Empty Image | Icon image for empty state. | CometChatMessageList.style.emptyImage = UIImage(named: "empty-icon") |
New Message Indicator Image | Icon image for new message indicator. | CometChatMessageList.style.newMessageIndicatorImage = UIImage? |
Background Image | Background image for the component. | CometChatMessageList.style.backgroundImage = UIImage? |
Property | Description | Code |
---|---|---|
hideAvatar | Hides the avatar of the sender. | hideAvatar = true |
hideGroupActionMessages | Hides group action messages (like join/leave notifications). | hideGroupActionMessages = true |
hideReplyInThreadOption | Hides the reply in thread option. | hideReplyInThreadOption = true |
hideTranslateMessageOption | Hides the message translation option. | hideTranslateMessageOption = true |
hideEditMessageOption | Hides the edit message option. | hideEditMessageOption = true |
hideDeleteMessageOption | Hides the delete message option. | hideDeleteMessageOption = true |
hideReactionOption | Hides the reaction option on messages. | hideReactionOption = true |
hideMessagePrivatelyOption | Hides the option to message privately. | hideMessagePrivatelyOption = true |
hideCopyMessageOption | Hides the option to copy a message. | hideCopyMessageOption = true |
hideMessageInfoOption | Hides the message info option. | hideMessageInfoOption = true |
hideHeaderView | Hides the header view of the message list. | hideHeaderView = true |
hideFooterView | Hides the footer view of the message list. | hideFooterView = true |
hideDateSeparator | Hides the date separator between messages. | hideDateSeparator = true |
scrollToBottomOnNewMessages | Scrolls to the bottom when new messages arrive. | scrollToBottomOnNewMessages = true |
hideReceipts | Hides the message read receipts (ticks). | hideReceipts = true |
disableSoundForMessages | Disables the sound when a new message arrives. | disableSoundForMessages = true |
hideEmptyView | Hides the empty state view when no messages are available. | hideEmptyView = true |
hideErrorView | Hides the error view when an error occurs. | hideErrorView = true |
hideLoadingView | Hides the loading view when fetching messages. | hideLoadingView = true |
hideNewMessageIndicator | Hides the “new message” indicator. | hideNewMessageIndicator = true |
scrollToBottom(isAnimated:) | Scrolls to the bottom of the message list. | scrollToBottom(isAnimated: true) |
set(messageAlignment:) | Sets the alignment of messages in the list. | set(messageAlignment: .left) |
set(smartRepliesKeywords:) | Sets keywords for smart replies. | set(smartRepliesKeywords: ["Hi", "Bye"]) |
set(smartRepliesDelayDuration:) | Sets the delay duration for smart replies. | set(smartRepliesDelayDuration: 2) |
set(user:parentMessage:) | Sets the user and an optional parent message. | set(user: user, parentMessage: message) |
set(group:parentMessage:) | Sets the group and an optional parent message. | set(group: group, parentMessage: message) |
set(messagesRequestBuilder:) | Sets the message request builder. | set(messagesRequestBuilder: builder) |
set(reactionsRequestBuilder:) | Sets the reactions request builder. | set(reactionsRequestBuilder: builder) |
set(parentMessageId:) | Sets the parent message ID. | set(parentMessageId: 12345) |
Property | Description | Code |
---|---|---|
time | Called to format a timestamp as a standard time (e.g., “12:30 PM”). | CometChatMessageList.dateTimeFormatter.time = { ... } |
today | Called when rendering messages sent today. | CometChatMessageList.dateTimeFormatter.today = { ... } |
yesterday | Called for yesterday’s messages. | CometChatMessageList.dateTimeFormatter.yesterday = { ... } |
lastweek | Called for messages within the last week. | CometChatMessageList.dateTimeFormatter.lastweek = { ... } |
otherDay | Called for dates older than last week. | CometChatMessageList.dateTimeFormatter.otherDay = { ... } |
minute | Called when referring to “a minute ago”. | CometChatMessageList.dateTimeFormatter.minute = { ... } |
minutes | Called for “x minutes ago”. | CometChatMessageList.dateTimeFormatter.minutes = { ... } |
hour | Called for “an hour ago”. | CometChatMessageList.dateTimeFormatter.hour = { ... } |
hours | Called for “x hours ago”. | CometChatMessageList.dateTimeFormatter.hours = { ... } |
setDateSeparatorPattern()
. This method accepts a function with a return type String. Inside the function, you can create your own pattern and return it as a String.
Example
cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller..set(timePattern:)
. This method accepts a function with a return type String. Inside the function, you can create your own pattern and return it as a String.
Example
MessageList
is properly configured, passing the controller is mandatory.cometChatMessages
. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.