Skip to main content

Chatroom Screen

Overview

The LMChatMessageListViewController is responsible for displaying and managing a list of chat messages. It utilizes various UI components to present message data, handle user interactions, and manage the chat input functionality.

Functionality

Protocols Implemented

  • LMChatMessageListViewDelegate: Manages user interactions with the message list.
  • LMChatInputBarDelegate: Handles events related to the chat input bar.
  • LMChatMessageCellDelegate: Manages interactions with individual message cells.
  • LMMessageReactionDelegate: Handles message reaction events.
  • LMChatTypingIndicatorDelegate: Manages typing indicator functionality.

UI Components

  • containerView: An instance of LMChatMessageListView that displays the list of messages.
  • inputBarView: An instance of LMChatInputBarView for message input functionality.
  • typingIndicatorView: An instance of LMChatTypingIndicatorView to show typing status.

Properties

  • messageActionHandler: Handles various message-related actions.
  • chatroomDetailManager: Manages chatroom details.

Methods

  • setupBindings(): Establishes data bindings between the view model and UI components.
  • setupKeyboardHandling(): Configures keyboard event handling.
  • loadMessages(showLoader:): Loads messages, optionally displaying a loader.
  • scrollToBottom(animated:): Scrolls the message list to the bottom.
  • handleLongPress(_:): Manages long press gestures on messages.

Customization

CustomMessageListViewController.swift
class CustomMessageListViewController: LMChatMessageListViewController {
override func setupAppearance() {
super.setupAppearance()
view.backgroundColor = .lightGray
}

override func setupViews() {
super.setupViews()
inputBarView.backgroundColor = .systemBlue
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.messageListScreen = CustomMessageListViewController.self
// ...
return true
}