Link Preview
Overview
LMFeedLinkPreview is used to display a preview of a link or URL. It displays the link preview image (if available), title, description, and the URL itself.

File Location:
LMFeedLinkPreview.swift
UI Components
containerView: A LMFeedViewmain container view that holds all other subviews.containerStackView: A vertical LMFeedStackView that arranges the image view and metadata container view.crossButton: An LMFeedButton that represents the cross button for removing the link preview.imageView: An LMFeedImageView that displays the link preview image.separatorView: A LMFeedView that acts as a separator between the image and metadata.metaDataContainerView: A container view that holds the metadata stack view.metaDataStackView: A vertical LMFeedStackView that arranges the title, description, and URL labels.titleLabel: An LMFeedLabel that displays the link's title.descriptionLabel: An LMFeedLabel that displays the link's description.urlLabel: An LMFeedLabel that displays the link's URL.
Data Variables
crossButtonSize: ACGFloatvalue that determines the size of the cross button.crossButtonAction: A closure that is executed when the cross button is tapped.
Methods
configure(): Configures the link preview with the providedContentModeldata and an optionalcrossButtonActionclosure.
Action Handlers
didTapCrossButton(): The selector method for the cross button's tap action. It executes thecrossButtonActionclosure if it is not nil.
Customization
CustomLinkPreview.swift
class CustomLinkPreview: LMFeedLinkPreview {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .green
titleLabel.textColor = .white
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.linkPreview = CustomLinkPreview.self
// ...
return true
}