Skip to main content

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.

LMFeedPostLinkCell

UI Components

  • containerView: The main container view that holds all other subviews.
  • containerStackView: A vertical LMStackView that arranges the image view and metadata container view.
  • crossButton: An LMButton that represents the cross button for removing the link preview.
  • imageView: An LMImageView that displays the link preview image.
  • separatorView: A LMView that acts as a separator between the image and metadata.
  • metaDataContainerView: A container view that holds the metadata stack view.
  • metaDataStackView: A vertical LMStackView that arranges the title, description, and URL labels.
  • titleLabel: An LMLabel that displays the link's title.
  • descriptionLabel: An LMLabel that displays the link's description.
  • urlLabel: An LMLabel that displays the link's URL.

Data Variables

  • crossButtonSize: A CGFloat 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 provided ContentModel data and an optional crossButtonAction closure.

Action Handlers

  • didTapCrossButton(): The selector method for the cross button's tap action. It executes the crossButtonAction 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
}