Message Header
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:
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 |
Usage
Integration
You can add MessageHeader
component directly by setting the user.
// syntax for set(user: User)
messageHeader.set(user: user) // The object which is going to be rendered in the data item
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.
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.
- Swift
// Creating MessageHeaderStyle object
let messageHeaderStyle = MessageHeaderStyle()
.set(typingIndicatorTextColor: .orange)
let messageHeaderConfiguration = MessageHeaderConfiguration()
.set(messageHeaderStyle: messageHeaderStyle)
let cometChatMessages = CometChatMessages()
.set(user: user)
.set(messageHeaderConfiguration: messageHeaderConfiguration)
The properties exposed by MessageHeaderStyle
are as follows:
Property | Description | Method |
---|---|---|
Set BorderWidth | Used to set border | .set(borderWidth: CGFloat) |
Set BorderColor | Used to set border color | .set(borderColor: UIColor) |
Set CornerRadius | Used to set corner radius | .set(cornerRadius: CometChatCornerStyle) |
Set Background | Used to set background colour | .set(background: UIColor) |
Set BackIconTint | Used to set back button icon tint | .set(backIconTint: UIColor) |
Set TypingIndicatorTextAppearance | Used to set typing indicator textStyle | .set(typingIndicatorTextFont: UIFont) |
Set TypingIndicatorTextColor | Used to set typing indicator text color | .set(typingIndicatorTextColor: UIColor) |
Set SubtitleTextAppearance | Used to set subtitle text style | .set(subtitleTextFont: UIFont) |
Set SubtitleTextColor | Used to set subtitle text color | .set(subtitleTextColor: UIColor) |
Set DetailIconTint | Sets the tint color for detail icon for message header | .set(detailIconTint: UIColor) |
Set OnlineStatusColor | Sets the online status color for message header | .set(onlineStatusColor: UIColor) |
Set PrivateGroupIconBackgroundColor | Sets the private group background color for message header | .set(privateGroupIconBackgroundColor: UIColor) |
Set ProtectedGroupIconBackgroundColor | Sets the protected group background color for message header | .set(protectedGroupIconBackgroundColor: UIColor) |
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.
- Swift
// Creating AvatarStyle object
let avatarStyle = AvatarStyle()
// Creating Modifying the propeties of avatar
avatarStyle.set(background: .red)
.set(textFont: .systemFont(ofSize: 18))
.set(textColor: .white)
.set(cornerRadius: CometChatCornerStyle(cornerRadius: 8.0))
.set(borderColor: .white)
.set(borderWidth: 5)
.set(outerViewWidth: 3)
.set(outerViewSpacing: 3)
// Creating MessageHeaderStyle object
let messageHeaderStyle = MessageHeaderStyle()
.set(typingIndicatorTextColor: .orange)
let messageHeaderConfiguration = MessageHeaderConfiguration()
.set(messageHeaderStyle: messageHeaderStyle)
let cometChatMessages = CometChatMessages()
.set(user: user)
.set(messageHeaderConfiguration: messageHeaderConfiguration)