From e31c499492cc70b5aa17147f5ebe58c0b97a4326 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Fri, 12 Nov 2021 17:34:20 +0700 Subject: [PATCH] Fix component spacing for comment content cell --- .../Comments/CommentContentTableViewCell.swift | 14 ++++++++++++++ .../Comments/CommentContentTableViewCell.xib | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift index 7954e3c72c84..65709fd82228 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift +++ b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.swift @@ -28,8 +28,15 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable { } } + // MARK: Constants + + private let customBottomSpacing: CGFloat = 10 + // MARK: Outlets + @IBOutlet private weak var containerStackView: UIStackView! + @IBOutlet private weak var containerStackBottomConstraint: NSLayoutConstraint! + @IBOutlet private weak var avatarImageView: CircularImageView! @IBOutlet private weak var nameLabel: UILabel! @IBOutlet private weak var dateLabel: UILabel! @@ -144,6 +151,13 @@ class CommentContentTableViewCell: UITableViewCell, NibReusable { isAccessoryButtonEnabled = comment.isApproved() isModerationEnabled = comment.allowsModeration() + // When reaction bar is hidden, add some space between the webview and the moderation bar. + containerStackView.setCustomSpacing(isReactionEnabled ? 0 : customBottomSpacing, after: webView) + + // When both reaction bar and moderation bar is hidden, the custom spacing for the webview won't be applied since it's at the bottom of the stack view. + // The reaction bar and the moderation bar have their own spacing, unlike the webview. Therefore, additional bottom spacing is needed. + containerStackBottomConstraint.constant = (isReactionEnabled || isModerationEnabled) ? 0 : customBottomSpacing + if isModerationEnabled { moderationBar.commentStatus = CommentStatusType.typeForStatus(comment.status) } diff --git a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.xib b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.xib index dc0c71ccf858..abd8dff0e832 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.xib +++ b/WordPress/Classes/ViewRelated/Comments/CommentContentTableViewCell.xib @@ -1,9 +1,9 @@ - + - + @@ -106,7 +106,7 @@