Video Text Cell
Overview
LMFeedVideoTextCell is a subclass of LMPostWidgetTableViewCell designed to display text content in video feed posts within the LikeMinds Feed module. It features an expandable/collapsible text area with a "See More" button, dynamic height calculation, and support for rich text interactions such as URLs, hashtags, and routes. The cell is styled for video feeds, including a transparent background and white text.
File Location:
LMFeedVideoTextCell.swift
Functionality
Protocols
LMFeedVideoTextCellHeightDelegate
A protocol for notifying height changes when the cell expands or collapses:
videoTextCell(_ cell: LMFeedVideoTextCell, didChangeHeight height: CGFloat): Called when the cell's height changes due to expansion or collapse.
UI Components
postText: An LMFeedTextview displaying the post's body text. Supports rich text, links, hashtags, and routes. Styled for video feeds (white text, shadow, transparent background).seeMoreButton: An LMFeedButton that toggles expansion/collapse of the text area. Shows "...See More" or "view less" as appropriate.
Data Variables
heightDelegate: A weak reference to an instance conforming toLMFeedVideoTextCellHeightDelegatefor height change notifications.expandedState: ABoolindicating whether the cell is expanded.postID: An optionalStringthat stores the identifier of the post (inherited).
Methods
configure(data: LMFeedPostContentModel): Configures the cell with the provided post data. Sets the text, resets expansion state, and updates the "See More" button visibility.toggleExpansion(): Expands or collapses the text area, animating the height change and updating the button title.calculateExpandedHeight(): Calculates the required height for the expanded state based on the text content.updateSeeMoreButtonState(): Shows or hides the "See More" button depending on the text length.tappedTextView(tapGesture: UITapGestureRecognizer): Handles taps on the text view, detecting URLs, hashtags, routes, or post taps.didTapURL(url: URL): Called when a URL is tapped in the text view.didTapHashTag(hashtag: String): Called when a hashtag is tapped in the text view.didTapRoute(route: String): Called when a route is tapped in the text view.didTapSeeMoreButton(): Called when the "See More" button is tapped. Toggles expansion/collapse.
Action Handlers
didTapSeeMoreButton(): The selector method for the "See More" button's tap action. Toggles the expanded state and notifies the delegate of height changes.
Customisation
CustomVideoTextCell.swift
class CustomVideoTextCell: LMFeedVideoTextCell {
override func setupAppearance() {
super.setupAppearance()
contentView.backgroundColor = .black
postText.font = UIFont.italicSystemFont(ofSize: 16)
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.videoTextCell = CustomVideoTextCell.self
// ...
return true
}