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.
File Location:
LMFeedPostHeaderView.swift
Functionality
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 LMFeedView that contains all other subviews.imageView: A LMFeedProfileImageView that displays the author's profile picture.outerStackView: A LMFeedStackView that organizes the main content horizontally.innerStackView: A LMFeedStackView nested within the outerStackView for arranging author details and subtitle.pinButton: A LMFeedButton to indicate or change the pin status of the post.menuButton: A LMFeedButton that presents more options for the post.authorStackView: A LMFeedStackView for the author's name and tag.subTitleLabel: A LMFeedLabel that displays metadata like the post's age or edit status.authorNameLabel: A LMFeedLabel that shows the author's name.authorTagLabel: A LMFeedLabel that shows a tag associated with the author (e.g., "Admin").spacerView: A LMFeedView used for spacing within the stack views.
Data Variables
delegate: An instance ofLMFeedPostHeaderViewProtocolto 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
}