MessageHeader
is a Component that showcases the User or Group details in the toolbar. Furthermore, it also presents a typing indicator and a back navigation button for ease of use.
MessageHeader
is comprised of the following components:
Components | Description |
---|---|
ListItem Component | This component’s view consists of avatar, status indicator , title, and subtitle. The fields are then mapped with the SDK’s user, group class. |
Back Button | BackButton that allows users to navigate back from the current activity or screen to the previous one |
MessageHeader
component directly by setting the user.
MessageHeader
component does not have any exposed actions.
set(onBack:)
method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatMessageHeader.
Component
. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders
of Chat SDK.
The MessageHeader
component does not have any exposed filters.
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 MessageHeader
component does not produce any events.
MessageHeaderStyle
object to the MessageHeader
component.
Global level styling
MessageHeaderStyle
are as follows:
Property | Description | Code |
---|---|---|
Title Text Color | Used to set the text color of the header title. | CometChatMessageHeader.style.titleTextColor = UIColor.black |
Title Text Font | Used to set the font style of the header title. | CometChatMessageHeader.style.titleTextFont = UIFont.boldSystemFont(ofSize: 18) |
Subtitle Text Color | Used to set the text color of the subtitle in the header. | CometChatMessageHeader.style.subtitleTextColor = UIColor.gray |
Subtitle Text Font | Used to set the font style of the subtitle in the header. | CometChatMessageHeader.style.subtitleTextFont = UIFont.systemFont(ofSize: 14) |
Back Button Image Tint Color | Used to set the tint color of the back button image in the header. | CometChatMessageHeader.style.backButtonImageTintColor = UIColor.blue |
Private Group Badge Tint Color | Used to set the tint color of the private group badge in the header. | CometChatMessageHeader.style.privateGroupBadgeImageTintColor = UIColor.green |
Password-Protected Badge Tint Color | Used to set the tint color of the password-protected group badge in the header. | CometChatMessageHeader.style.passwordProtectedGroupBadgeImageTintColor = UIColor.orange |
Private Group Background Color | Used to set the background color of the private group badge. | CometChatMessageHeader.style.privateGroupImageBackgroundColor = UIColor.lightGray |
Password-Protected Background Color | Used to set the background color of the password-protected group badge. | CometChatMessageHeader.style.passwordGroupImageBackgroundColor = UIColor.red |
Group Image Background Color | Used to set the background color for group icons in the header. | CometChatMessageHeader.style.groupImageBackgroundColor = UIColor.clear |
Avatar Style | Used to customize the appearance of the avatar in the header. | CometChatMessageHeader.style.avatarStyle = customAvatarStyle |
Background Color | Used to set the background color of the header. | CometChatMessageHeader.style.backgroundColor = UIColor.white |
Corner Radius | Used to set the corner radius of the header. | CometChatMessageHeader.style.cornerRadius = CometChatCornerStyle(cornerRadius: 8) |
Border Width | Used to set the border width of the header. | CometChatMessageHeader.style.borderWidth = 2 |
Border Color | Used to set the border color of the header. | CometChatMessageHeader.style.borderColor = UIColor.gray |
Back Button Icon | Used to set a custom icon for the back button. | CometChatMessageHeader.style.backButtonIcon = UIImage(named: "customBackIcon") |
Private Group Icon | Used to set a custom icon for private groups. | CometChatMessageHeader.style.privateGroupIcon = UIImage(named: "privateIcon") |
Protected Group Icon | Used to set a custom icon for password-protected groups. | CometChatMessageHeader.style.protectedGroupIcon = UIImage(named: "protectedIcon") |
Background Image | Used to set a background image for the header. | CometChatMessageHeader.style.backgroundImage = UIImage(named: "headerBackground") |
Avatar
component within the MessageHeader
Component, you can use the following code snippet. For more information you can refer Avatar Styles.
Global level styling
Method | Description | Code |
---|---|---|
set(user:User) | Sets message header for CometChat user. | .set(user:User) |
set(group:Group) | Sets message header for CometChat group. | .set(group:Group) |
hideBackButton | Hides the back button of message header. | hideBackButton = true |
hideUserStatus | Hides or shows the user status of user(online/offline/last active at). | hideUserStatus = true |
hideVideoCallButton | Hides the video call button. | hideVideoCallButton = true |
hideVoiceCallButton | Hides the voice call button. | hideVoiceCallButton = true |
Property | Description | Code |
---|---|---|
time | Called to format a timestamp as a standard time (e.g., “12:30 PM”). | CometChatMessageHeader.dateTimeFormatter.time = { ... } |
today | Called when rendering messages sent today. | CometChatMessageHeader.dateTimeFormatter.today = { ... } |
yesterday | Called for yesterday’s messages. | CometChatMessageHeader.dateTimeFormatter.yesterday = { ... } |
lastweek | Called for messages within the last week. | CometChatMessageHeader.dateTimeFormatter.lastweek = { ... } |
otherDay | Called for dates older than last week. | CometChatMessageHeader.dateTimeFormatter.otherDay = { ... } |
minute | Called when referring to “a minute ago”. | CometChatMessageHeader.dateTimeFormatter.minute = { ... } |
minutes | Called for “x minutes ago”. | CometChatMessageHeader.dateTimeFormatter.minutes = { ... } |
hour | Called for “an hour ago”. | CometChatMessageHeader.dateTimeFormatter.hour = { ... } |
hours | Called for “x hours ago”. | CometChatMessageHeader.dateTimeFormatter.hours = { ... } |
CustomListItemView
as a custom UIView
. Which we will inflate in setListItemView()
CustomLeadingView
as a custom UIView
. Which we will inflate in setLeadingView()
CustomTitleView
as a custom UIView
. Which we will inflate in setTitleView()
CustomTrailView
as a custom UIView
. Which we will inflate in setTrailView()
CustomSubtitleView
UIView file into the .set(subtitleView:)
method within CometChatMessageHeader.
MessageHeader
is properly configured, passing the controller is mandatory.