Skip to main content

Footer View

Overview

LMFeedPostFooterView is a custom table view footer designed to display action buttons and counts for liking, commenting, saving, and sharing a post in a feed.

LMFeedPostFooterView

Protocols

LMFeedPostFooterViewProtocol

Defines delegate methods for interacting with the post footer view:

  • didTapLikeButton(for postID: String): Called when the like button is tapped.
  • didTapLikeTextButton(for postID: String): Called when the like text button is tapped.
  • didTapCommentButton(for postID: String): Called when the comment button is tapped.
  • didTapSaveButton(for postID: String): Called when the save button is tapped.
  • didTapShareButton(for postID: String): Called when the share button is tapped.
  • didTapPost(postID: String): Called when the entire footer is tapped.

UI Components

  • containerView: A view that contains all other subviews.
  • actionStackView: A horizontal stack view that organizes the action buttons.
  • likeButton: A button to like/unlike the post.
  • likeTextButton: A button displaying the like count.
  • commentButton: A button for adding comments.
  • saveButton: A button to save/unsave the post.
  • shareButton: A button to share the post.
  • spacer: A view used for spacing within the stack views.

Data Variables

  • delegate: An instance of LMFeedPostFooterViewProtocol to handle interactions.
  • postID: The identifier of the post.
  • likeCount: The count of likes for the post.

Methods

  • configure(): Configures the footer view with the provided data and sets up the delegate for cell interactions.

  • getLikeText()

    Generates the appropriate text based on the like count.

  • getCommentText(): Generates the appropriate text based on the comment count.

Action Handlers

  • didTapLikeButton(): Invokes the delegate method when the like button is tapped.

  • didTapLikeTextButton(): Invokes the delegate method when the like text button is tapped.

  • didTapCommentButton(): Invokes the delegate method when the comment button is tapped.

  • didTapSaveButton(): Invokes the delegate method when the save button is tapped.

  • didTapShareButton(): Invokes the delegate method when the share button is tapped.

  • didTapPost(): Invokes the delegate method when the entire footer is tapped.

Customisation

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