Message Content
Overview:
LMChatMessageContentView
is a core UI component responsible for rendering the content within individual chat message cells. This view handles the layout, display, and interaction of message content such as text, images, or other media types in chat threads.
Functionality
Protocols:
LMChatMessageContentViewDelegate
:
clickedOnReaction(_ reaction: String)
: Triggered when a user clicks on a reaction emoji.clickedOnAttachment(_ url: String)
: Fired when an attachment within a message is clicked, providing the attachment URL.didTapOnProfileLink(route: String)
: Handles profile link taps, enabling navigation to user profiles.didTapOnReplyPreview()
: Triggered when the user taps on a reply preview in the message.
UI Components:
messageLabel
: Displays the main body of the message (text).mediaView
: Handles the display of media content like images or videos, if any.timestampLabel
: Shows the time when the message was sent.senderLabel
: Displays the sender’s name or identifier.statusView
: Indicates the delivery status of the message (sent, delivered, or read).
Methods:
configure(with message: LMChatMessage)
: Configures the content view with the details of a chat message, such as text, media, or status.updateMessageStatus()
: Updates the delivery status of the message (e.g., seen, delivered) within the chat cell.layoutSubviews()
: Handles the layout of subviews (text, media, timestamp) within the content view, ensuring proper arrangement and spacing.setMessageFont()
: Applies the appropriate font style and size to the message label based on the message type.
Customization
CustomMessageContentView.swift
class CustomMessageContentView: LMChatMessageContentView {
override func setupViews() {
super.setupViews()
// Add custom views here
}
override func setupAppearance() {
super.setupAppearance()
// Customize cell appearance here
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.messageContentView = CustomMessageContentView.self
// ...
return true
}