Skip to main content

Header View

Overview

LMFeedPostHeaderView is a custom table view header designed to display the author's details, post metadata, and action buttons for posts in a feed.

LMFeedPostHeaderView

Protocols

LMFeedPostHeaderViewProtocol

Defines delegate methods for interacting with the post header view:

  • didTapProfilePicture(having uuid: String): Called when the profile picture is tapped.
  • didTapPostMenuButton(for postID: String): Called when the menu button of the post is tapped.
  • didTapPost(postID: String): Called when the post itself is tapped.

UI Components

  • contentContainerView: A view that contains all other subviews.
  • imageView: Displays the author's profile picture.
  • outerStackView: A horizontal stack view that organizes the main content horizontally.
  • innerStackView: A vertical stack view nested within the outerStackView for arranging author details and subtitle.
  • pinButton: An action button to indicate or change the pin status of the post.
  • menuButton: Presents more options for the post.
  • authorStackView: A horizontal stack view for the author's name and tag.
  • subTitleLabel: Displays metadata like the post's age or edit status.
  • authorNameLabel: Shows the author's name.
  • authorTagLabel: Shows a tag associated with the author (e.g., "Admin").
  • spacerView: Used for spacing within the stack views.

Data Variables

  • delegate: An instance of LMFeedPostHeaderViewProtocol to handle interactions.
  • userUUID: The UUID of the user who created the post.
  • postID: The identifier of the post.

Methods

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

  • togglePinStatus(): Toggles the visibility of the pin button, indicating whether a post is pinned or not.

Action Handlers

  • didTapProfilePicture(): Invokes the delegate method when the profile picture is tapped.

  • didTapMenuButton(): Invokes the delegate method when the menu button is tapped.

  • didTapPost(): Invokes the delegate method when the post itself is tapped.

Customisation

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