Comment View
Overview
LMFeedCommentView
is designed to display detailed information about a comment for a feed post.
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 ofLMView
serving as the main container for all other subviews.authorNameLabel
: An instance ofLMLabel
used to display the name of the comment's author.commentStack
: An instance ofLMStackView
that vertically aligns the comment and the see-more text button.commentContainerStack
: An instance ofLMStackView
that horizontally aligns the comment stack and the menu button.commentLabel
: An instance ofLMTextView
used to display the text of the comment.menuButton
: An instance ofLMButton
used to present additional options related to the comment.actionStack
: An instance ofLMStackView
that horizontally aligns action buttons like like, reply, and the separator view.likeButton
: An instance ofLMButton
that lets users like the comment.likeTextButton
: An instance ofLMButton
used to display the number of likes a comment has received.sepratorView
: An instance ofLMView
used as a visual separator in the action stack.replyButton
: An instance ofLMButton
that allows users to reply to the comment.replyCountButton
: An instance ofLMButton
used to display the number of replies a comment has received.commentTimeLabel
: An instance ofLMLabel
that shows when the comment was made.
Data Variables
delegate
: A weak reference to an object conforming toLMFeedPostCommentProtocol
, used for callback events.commentId
: AString
containing the identifier for the comment.indexPath
: AnIndexPath
indicating the position of the comment in a list.likeCount
: AnInt
representing the number of likes the comment has received.commentUserUUID
: AString
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
}