Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable {
@IBOutlet private weak var replyButton: UIButton!
@IBOutlet private weak var likeButton: UIButton!

// MARK: Private Properties

/// Called when the cell has finished loading and calculating the height of the HTML content. Passes the new content height as parameter.
private var onContentLoaded: ((CGFloat) -> Void)? = nil

Expand All @@ -62,6 +64,27 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable {
/// Caches the HTML content, to be reused when the orientation changed.
private var htmlContentCache: String? = nil

// MARK: Visibility Control

/// Controls the visibility of the reaction bar view. Setting this to false disables Reply and Likes functionality.
private var isReactionEnabled: Bool = false {
didSet {
reactionBarView.isHidden = !isReactionEnabled
}
}

private var isCommentLikesEnabled: Bool = false {
didSet {
likeButton.isHidden = !isCommentLikesEnabled
}
}

private var isAccessoryButtonEnabled: Bool = false {
didSet {
accessoryButton.isHidden = !isAccessoryButtonEnabled
}
}

// MARK: Lifecycle

override func awakeFromNib() {
Expand Down Expand Up @@ -93,12 +116,15 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable {

updateLikeButton(liked: comment.isLiked, numberOfLikes: comment.numberOfLikes())

// configure comment content
// Configure feature availability.
isReactionEnabled = !comment.isReadOnly()
isCommentLikesEnabled = isReactionEnabled && (comment.blog?.supports(.commentLikes) ?? false)
isAccessoryButtonEnabled = comment.isApproved()

// Configure comment content.
self.onContentLoaded = onContentLoaded
webView.isOpaque = false // gets rid of the white flash upon content load in dark mode.
webView.loadHTMLString(formattedHTMLString(for: comment.content), baseURL: Self.resourceURL)

// TODO: Configure component visibility
}
}

Expand Down
Loading