Chat Bottom Message Composer View
Overview
The LMChatBottomMessageComposerView is a customizable message composer view for LikeMinds Chat, providing text input, attachments, audio recording, GIFs, reply previews, and more. It is designed to be integrated at the bottom of a chat screen and supports a wide range of chat interactions.
File Location:
LMChatBottomMessageComposerView.swift
Functionality
Protocols
LMChatBottomMessageComposerDelegate
Defines methods for handling user actions and events:
func composeMessage(message: String, composeLink: String?)— Called when the user sends a text message (optionally with a detected link).func composeAttachment()— Called when the user taps the attachment button.func composeAudio()— Called when the user sends an audio message.func composeGif()— Called when the user selects a GIF to send.func linkDetected(_ link: String)— Called when a link is detected in the message input.func audioRecordingStarted()— Called when audio recording starts.func audioRecordingEnded()— Called when audio recording ends.func playRecording()— Called to play the recorded audio.func stopRecording(_ onStop: (() -> Void))— Called to stop audio playback or recording.func deleteRecording()— Called to delete the current audio recording.func askForMicrophoneAccess()— Called to request microphone permissions from the user.func cancelReply()— Called when the user cancels a reply preview.func cancelReplyPrivatelyView()— Called when the user cancels a private reply preview.func cancelLinkPreview()— Called when the user cancels a link preview.func showToastMessage(message: String?)— Called to display a toast message to the user.func isOtherUserAIChatbotInChatroom() -> Bool— Returns true if the other user in the chatroom is an AI chatbot.
UI Components
containerView: A LMView the main container for the composer.inputTextView: LMChatTaggingTextView — Text input for composing messages.sendButton: A LMButton for sending messages or audio.attachmentButton: A LMButton for adding attachments.gifButton: A LMButton for adding GIFs.replyMessageView:A LMChatMessageReplyPreview to shows reply preview.replyPrivatelyView: A LMChatMessageReplyPrivatelyPreview to shows private reply preview.linkPreviewView: LMChatBottomMessageLinkPreview — Shows link preview.audioContainerView: A LMView container for audio recording controls.restrictionLabel:A LMLabel to displays restriction messages.
Properties
delegate: The delegate for handling composer actions.replyMessageViewContainer: Container for reply preview.replyPrivatelyMessageViewContainer: Container for private reply preview.isShowSendMessageButtonOnly: Controls if only the send button is shown.
Customization
You can subclass LMChatBottomMessageComposerView to customize its appearance or behavior.
CustomMessageComposerView.swift
class CustomMessageComposerView: LMChatBottomMessageComposerView {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .lightGray
}
// You can override other methods for further customization
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.bottomMessageComposerView = CustomMessageComposerView.self
// ...
return true
}