Attachment List Screen
Overview
The LMChatAttachmentViewController
is responsible for managing the attachment process in a chat interface. It allows users to view, edit, and send various types of media attachments, including images, videos, GIFs, PDFs, and audio files.
Functionality
Protocols
LMChatAttachmentViewDelegate
func postConversationWithAttchments(message: String?, attachments: [MediaPickerModel])
: allows the delegate to receive the composed message along with an array of MediaPickerModel objects representing the selected attachments.
UI Components
bottomMessageBoxView
: A custom view for composing messages and managing attachments.imageViewCarouselContainer
: A container view for the media carousel.zoomableImageViewContainer
: A container for displaying zoomable images.videoImageViewContainer
: A container for video previews.audioPlayer
: A view for playing audio attachments.mediaCollectionView
: A horizontal collection view displaying attachment thumbnails.mediaDetailLabelContainerStackView
: A stack view containing file details for PDFs and audio files.
Properties
delegate
: A weak reference to an object conforming toLMChatAttachmentViewDelegate
.
Methods
editingImage(_:)
: Handles the editing of an image attachment.deleteMediaData(_:)
: Removes the currently selected media attachment.cancelEditing(_:)
: Cancels the attachment process and dismisses the view controller.addMoreAttachment()
: Presents options to add more attachments based on the current media type.sendAttachment(message:)
: Sends the selected attachments along with an optional message.
Customization
CustomChatAttachmentViewController.swift
class CustomChatAttachmentViewController: LMChatAttachmentViewController {
override func setupAppearance() {
super.setupAppearance()
view.backgroundColor = .lightGray
}
override func addMoreAttachment() {
// Custom logic for adding more attachments
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.chatAttachmentScreen = CustomChatAttachmentViewController.self
// ...
return true
}