Gallery View
Overview
The LMChatMessageGallaryView
is a custom view component responsible for displaying a gallery of images or videos within a chat message. It supports up to four visible items with an overlay for additional items.
Functionality
Protocols
LMChatMessageGallaryViewDelegate
onClickAttachment(_ index: Int)
: Manages user interactions with gallery items.
UI Components
singleImage
: AnImagePreview
instance for displaying a single image.itemSpots
: An array of fourImagePreview
instances for displaying multiple images.moreItemsOverlay
: ALMLabel
to indicate additional items beyond the visible ones.previewsContainerView
: ALMStackView
that contains all preview items.topPreviewsContainerView
: ALMStackView
for the top row of preview items.bottomPreviewsContainerView
: ALMStackView
for the bottom row of preview items.
Methods
setData(_ data: [ContentModel])
: Configures the gallery view with the provided content data.loadImageData(item: ContentModel, imagePreview: ImagePreview)
: Loads image data into anImagePreview
instance.onAttachmentClicked(_ gesture: UITapGestureRecognizer)
: Handles tap gestures on gallery items.
Customization
CustomGalleryView.swift
class CustomGalleryView: LMChatMessageGallaryView {
override func setupAppearance() {
super.setupAppearance()
// Customize appearance here
}
override func setupViews() {
super.setupViews()
// Add or modify subviews here
}
override func setupLayouts() {
super.setupLayouts()
// Adjust layouts here
}
}
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LMUIComponents.shared.galleryView = CustomGalleryView.self
// ...
return true
}