Skip to main content

Comment View

Overview

LMFeedCommentView is designed to display detailed information about a comment for a feed post.

LMFeedPostDetailCommentHeaderView

Protocols

LMFeedPostCommentProtocol

  • didTapUserName(for uuid: String): Handles the tap action on a user's name, passing the user's UUID.
  • didTapCommentMenuButton(for commentId: String): Handles the tap action on a comment menu button, passing the comment ID.
  • didTapLikeButton(for commentId: String, indexPath: IndexPath): Handles the tap action on a like button for a comment, passing the comment ID and the index path of the comment.
  • didTapLikeCountButton(for commentId: String): Handles the tap action on a like count button for a comment, passing the comment ID.
  • didTapReplyButton(for commentId: String): Handles the tap action on a reply button for a comment, passing the comment ID.
  • didTapReplyCountButton(for commentId: String): Handles the tap action on a reply count button for a comment, passing the comment ID.
  • didTapURL(url: URL): Handles the tap action on a URL, passing the URL.

UI Components

  • containerView: An instance of LMView serving as the main container for all other subviews.
  • authorNameLabel: An instance of LMLabel used to display the name of the comment's author.
  • commentStack: An instance of LMStackView that vertically aligns the comment and the see-more text button.
  • commentContainerStack: An instance of LMStackView that horizontally aligns the comment stack and the menu button.
  • commentLabel: An instance of LMTextView used to display the text of the comment.
  • menuButton: An instance of LMButton used to present additional options related to the comment.
  • actionStack: An instance of LMStackView that horizontally aligns action buttons like like, reply, and the separator view.
  • likeButton: An instance of LMButton that lets users like the comment.
  • likeTextButton: An instance of LMButton used to display the number of likes a comment has received.
  • sepratorView: An instance of LMView used as a visual separator in the action stack.
  • replyButton: An instance of LMButton that allows users to reply to the comment.
  • replyCountButton: An instance of LMButton used to display the number of replies a comment has received.
  • commentTimeLabel: An instance of LMLabel that shows when the comment was made.

Data Variables

  • delegate: A weak reference to an object conforming to LMFeedPostCommentProtocol, used for callback events.
  • commentId: A String containing the identifier for the comment.
  • indexPath: An IndexPath indicating the position of the comment in a list.
  • likeCount: An Int representing the number of likes the comment has received.
  • commentUserUUID: A String containing the UUID of the user who made the comment.

Methods

  • configure(): Configures the view, setting up its content and appearance based on the model's data.

Action Handlers

  • didTapMenuButton(): Invoked when the menu button is tapped, informing the delegate to show additional options.

  • didTapLikeButton(): Toggles the like state for the comment and updates the UI accordingly.

  • didTapLikeCountButton(): Informs the delegate that the number of likes was tapped.

  • didTapReplyButton(): Informs the delegate that the reply button was tapped, typically to initiate a reply action.

  • didTapReplyCountButton(): Informs the delegate that the number of replies was tapped, usually to expand or view replies.

  • didTapCommentUser(): Invoked when the author's name label is tapped, potentially navigating to the author's profile.

Customisation

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