Skip to main content

Document Cell

Overview

LMFeedPostDocumentCell is a subclass of LMPostWidgetTableViewCell designed to display posts with document attachments in a feed.

LMFeedPostDocumentCell

Protocols

LMFeedPostDocumentCellProtocol

Conforms to LMPostWidgetTableViewCellProtocol. It includes functions for handling interactions within the document cell:

  • didTapShowMoreDocuments(for indexPath: IndexPath): Invoked when the user taps the "See More" button to view additional documents.
  • didTapDocument(with url: URL): Called when a document preview is tapped.

UI Components

  • documentContainerStack: An LMStackView used to vertically stack document preview views.
  • seeMoreDocumentsButton: An LMButton for showing more documents if they exceed the predefined limit.

Data Variables

  • delegate: A weak reference to an instance conforming to LMFeedPostDocumentCellProtocol for handling user interactions.
  • indexPath: Optionally stores the IndexPath of the cell within the tableView, useful for delegate callbacks.

Methods

  • configure(): Configures the cell with the data and sets the delegate. It prepares the document previews and sets the post Text accordingly.

Action Handlers

  • didTapSeeMoreDocuments(): The selector method for the "See More" button's tap action. It checks if the indexPath is set and notifies the delegate to handle the event.

Customisation

CustomDocumentCell.swift
class CustomDocumentCell: LMFeedPostDocumentCell {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .green
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.documentCell = CustomDocumentCell.self
// ...
return true
}