Skip to main content

Chatroom View

Overview

The LMChatHomeFeedChatroomView is designed to display chatroom information in a home feed or list context. It provides a comprehensive view of a chatroom, including its name, last message, timestamp, unread count, and various status indicators such as mute, secret, and announcement statuses.

UI Components

  • chatroomImageView: Displays the chatroom's image or a placeholder.
  • chatroomNameLabel: Shows the name of the chatroom.
  • customTitle: Displays additional title information if available.
  • lastMessageLabel: Shows the last message in the chatroom.
  • timestampLabel: Displays the timestamp of the last message.
  • lockIconImageView: Indicates if the chatroom is secret.
  • announcementIconImageView: Indicates if the chatroom is for announcements.
  • muteIconImageView: Shows if the chatroom is muted.
  • tagIconImageView: Reserved for future use (currently hidden).
  • chatroomCountBadgeLabel: Displays the unread message count.

Methods

  • setData(_:): Configures the view with chatroom data.
  • lastMessageLabelSet(_:): Sets up the last message label with appropriate icons for different file types.
  • chatroomName(_:): Formats and sets the chatroom name and custom title.

Customization

CustomHomeFeedChatroomView.swift
class CustomHomeFeedChatroomView: LMChatHomeFeedChatroomView {
override func setupViews() {
super.setupViews()
// Add custom views or modify existing ones
}

override func setupAppearance() {
super.setupAppearance()
// Customize the view's appearance
chatroomNameLabel.font = UIFont.boldSystemFont(ofSize: 16)
lastMessageLabel.textColor = .darkGray
}

override func setData(_ data: ContentModel) {
super.setData(data)
// Add custom data presentation logic
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.homeFeedChatroomView = CustomHomeFeedChatroomView.self
// ...
return true
}