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.
UI Components
containerView
: The main container view that holds all other subviews.containerStackView
: A verticalLMStackView
that arranges the image view and metadata container view.crossButton
: AnLMButton
that represents the cross button for removing the link preview.imageView
: AnLMImageView
that displays the link preview image.separatorView
: ALMView
that acts as a separator between the image and metadata.metaDataContainerView
: A container view that holds the metadata stack view.metaDataStackView
: A verticalLMStackView
that arranges the title, description, and URL labels.titleLabel
: AnLMLabel
that displays the link's title.descriptionLabel
: AnLMLabel
that displays the link's description.urlLabel
: AnLMLabel
that displays the link's URL.
Data Variables
crossButtonSize
: ACGFloat
value 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 providedContentModel
data and an optionalcrossButtonAction
closure.
Action Handlers
didTapCrossButton()
: The selector method for the cross button's tap action. It executes thecrossButtonAction
closure 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
}