Skip to main content

Overview

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.
The MessageHeader is comprised of the following components:

Usage

Integration

You can add MessageHeader component directly by setting the user.
Swift

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. The MessageHeader component does not have any exposed actions.
1. set(onBack:)
This set(onBack:) method becomes valuable when a user needs to override the action triggered upon pressing the back button in CometChatMessageHeader.

2. set(onError:)
This method proves helpful when a user needs to customize the action taken upon encountering an error in CometChatMessageHeader.

Filters

Filters allow you to customize the data displayed in a list within a 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.

Events

Events are emitted by a 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.

Customization

To fit your app’s design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
1. MessageHeader Style
To customize the appearance, you can assign a MessageHeaderStyle object to the MessageHeader component. Global level styling
Instance level styling
The properties exposed by MessageHeaderStyle are as follows:
2. Avatar Style
If you want to apply customized styles to the Avatar component within the MessageHeader Component, you can use the following code snippet. For more information you can refer Avatar Styles. Global level styling
Instance level styling

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements. Below is a list of customizations along with corresponding code snippets

Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

Date Time Formatter

The CometChatMessageHeader component supports full customization of how date and time are displayed using the CometChatDateTimeFormatter. This enables developers to localize, format, or personalize the date and time strings shown next to the message header such as “Today”, “Yesterday”, “12:45 PM”, etc.
  1. Component-Level (Global)
  1. Instance-Level (Local)
Available closures
Each closure receives a timestamp (Int, representing UNIX time) and must return a String representing the formatted time.

SetListItemView

With this function, you can assign a custom ListItem to the message header Component.
Demonstration
You can create a CustomListItemView as a custom UIView. Which we will inflate in setListItemView()
swift

SetLeadingView

You can modify the leading view of a group cell using .set(leadingView:).
Demonstration
You can create a CustomLeadingView as a custom UIView. Which we will inflate in setLeadingView()

SetTitleView

You can customize the title view of a group cell using .set(titleView:).
Demonstration
You can create a CustomTitleView as a custom UIView. Which we will inflate in setTitleView()

SetTrailView

You can modify the trailing view of a message header using .set(trailView:).
Demonstration
You can create a CustomTrailView as a custom UIView. Which we will inflate in setTrailView()

SetSubTitleView

You can customize the subtitle view for each group item to meet your requirements
Example Demonstration
You can seamlessly integrate this CustomSubtitleView UIView file into the .set(subtitleView:) method within CometChatMessageHeader.

To ensure that the MessageHeader is properly configured, passing the controller is mandatory.
  • Swift