Skip to main content

Chat Message Reply Privately Preview

Overview

The LMChatMessageReplyPrivatelyPreview is a custom view component designed to display a preview of a message when replying privately to a conversation. It extends LMChatMessageReplyPreview and provides additional context for private replies, such as the source chatroom and sender.

File Location:
LMChatMessageReplyPrivatelyPreview.swift

Functionality

Protocols

LMBottomMessageReplyPreviewDelegate

  • func clearReplyPreview(): method for clearing the reply preview.

UI Components

  • containerView: LMView the main container for the reply preview.
  • sidePannelColorView: LMView a colored view indicating the reply status.
  • userNameLabel: LMLabel to displays the name of the original message sender.
  • messageLabel: LMLabel to shows the content of the original message.
  • messageAttachmentImageView: LMImageView to displays a thumbnail of any attached media.
  • closeReplyButton: LMButton to allows users to dismiss the reply preview.
  • horizontalReplyStackView: LMStackView to organizes the reply content horizontally.
  • verticleUsernameAndMessageContainerStackView: LMStackView to arranges the username and message vertically.

Properties

  • delegate: A weak reference to an object conforming to LMBottomMessageReplyPreviewDelegate.
  • viewData: Stores the ContentModel for the current reply preview.
  • onClickReplyPreview: A closure that can be set to handle taps on the reply preview.
  • onClickCancelReplyPreview: A closure that can be set to handle cancellation of the reply.

Methods

  • setData(_:): Populates the view with the sender, chatroom, and message details for a private reply preview.
  • setDataForEdit(_:): Configures the view for editing an existing message.
  • createAttributedString(_:): Creates an attributed string for the message content, including icons for different attachment types.
  • cancelReply(_:): Handles the cancellation of the reply preview.
  • onReplyPreviewClicked(_:): Handles taps on the reply preview.

Data Model

ContentModel

A struct used to provide data to the reply privately preview. Contains:

Customization

CustomChatMessageReplyPrivatelyPreview.swift
class CustomChatMessageReplyPrivatelyPreview: LMChatMessageReplyPrivatelyPreview {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .yellow
}

// You can override setData or other methods for further customization
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.messageReplyPrivatelyView = CustomChatMessageReplyPrivatelyPreview.self
// ...
return true
}