Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Notifications Refresh] Comment Content Redesign #23147

Conversation

salimbraksa
Copy link
Contributor

@salimbraksa salimbraksa commented May 3, 2024

Fixes https://github.com/Automattic/wordpress-mobile/issues/31 and part of https://github.com/Automattic/wordpress-mobile/issues/38

Dependencies

This PR depends on:

Description

This PR introduces a new component for the comment table view cell, while the previous cell, CommentContentTableViewCell, continues to be used in the Reader Comments screen. I decided against refactoring the original for a couple of reasons:

  1. There's a risk of causing regression issues specifically on the Reader Comments screen.
  2. The existing class is already quite complex and lengthy. Adding further logic to manage styling would complicate it even more.

The new class CommentDetailContentTableViewCell is comprised of 2 components:

  • CommentContentHeaderView: This component was implemented in this PR.
  • CommentDetailContentView: I've extracted the comment rendering logic from CommentContentTableViewCell into this component.
Comment Menu

Test Instructions

Comment Moderation Allowed

  1. Run Jetpack and login.
  2. Navigate to "Notifications" screen.
  3. Select a "Comment" notification.
  4. Compare the implementation against the design.
  5. If the comment has links or mentions, tap one of them and expect a web view is shown.
  6. Tap the more menu.
  7. Expect these buttons to be visible: "User Info", "Share", "Edit Comment" and "Change Status".
  8. Verify "User Info", "Share" and "Edit Comment" buttons work as expected.

Comment Moderation Not Allowed

  1. Go to Comment.swift, and force allowsModeration to return false.
  2. Build and run the app.
  3. Navigate to My Site > Comments.
  4. Tap any comment.
  5. Tap the more menu.
  6. Expect these buttons to be visible: "User Info", "Share".

Regression Notes

  1. Potential unintended areas of impact
    Smoke test the "Comment Detail" screen when accessed from "My Site > Comments".

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing.

  3. What automated tests I added (or what prevented me from doing so)
    None.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@salimbraksa salimbraksa self-assigned this May 3, 2024
@salimbraksa salimbraksa changed the base branch from trunk to task/notifications-comment-content-header May 3, 2024 12:14
@salimbraksa salimbraksa force-pushed the task/notifications-comment-content branch from 888486a to 6f15c2b Compare May 3, 2024 12:19
@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 3, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23147-3d77d0a
Version24.8
Bundle IDorg.wordpress.alpha
Commit3d77d0a
App Center BuildWPiOS - One-Offs #9826
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 3, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23147-3d77d0a
Version24.8
Bundle IDcom.jetpack.alpha
Commit3d77d0a
App Center Buildjetpack-installable-builds #8874
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@@ -0,0 +1,82 @@
import UIKit

final class CommentDetailContentView: UIView {
Copy link
Contributor Author

@salimbraksa salimbraksa May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I've mentioned in the PR description, most of the logic was extracted from CommentContentTableViewCell, except:

  • The cell was using a NSLayoutConstraint to constraint the height, I'm using intrinsicContentSize instead.
  • The cell was providing 2 methods to render comments ( web, richContent ). I've extracted only the web rendering method because it was the one used in Comment Detail screen.
  • Added a Configuration type to encapsulate configuration properties.

case .rendered(let height): return height
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This State enum is not very useful right now, but I was thinking of showing an activity indicator because the comment rendering is async.

)
button.accessibilityLabel = NSLocalizedString("Share comment", comment: "Accessibility label for button to share a comment from a notification")
return button
}()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit and share bar buttons were removed from the navigation bar, because now they're buttons in the comment's menu.

case .share:
shareCommentURL()
case .changeStatus(let status):
print("Option \(status) tapped")
Copy link
Contributor Author

@salimbraksa salimbraksa May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling status changes will be addressed in a separate PR as it depends on this issue.

let contentConfig = CommentDetailContentTableViewCell.ContentConfiguration(comment: comment) { [weak self] _ in
UIView.performWithoutAnimation {
self?.tableView.performBatchUpdates({})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When rendering the comment, we use the performBatchUpdates method to relayout the cells and update their heights. This approach was part of the previous implementation. What I've added is the wrapping of this method inside UIView.performWithoutAnimation, ensuring that the cells' relayout occurs without any animation. In my opinion, the default animation appeared clunky.

@@ -729,7 +698,7 @@ private extension CommentDetailViewController {
present(activityViewController, animated: true, completion: nil)
}

func presentUserInfoSheet(_ senderView: UIView) {
func presentUserInfoSheet() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The senderView: UIView param was not used, so I removed it.

@salimbraksa salimbraksa marked this pull request as ready for review May 3, 2024 17:58
Base automatically changed from task/notifications-comment-content-header to feature/notifications_refresh_p2 May 4, 2024 01:52
@salimbraksa salimbraksa force-pushed the task/notifications-comment-content branch from 6a74476 to 95870d0 Compare May 4, 2024 01:53
Copy link
Contributor

@justtwago justtwago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the changes and everything works well. My only concern is a really little padding between a header and content. It looks really tight. Maybe it's worth double check with Chris and perhaps restore the previous value?

Comment on lines +48 to +51
func configure(with headerConfig: HeaderConfiguration, contentConfig: ContentConfiguration, parent: UIViewController) {
self.updateHeader(with: headerConfig, parent: parent)
self.commentView.configure(with: contentConfig)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double-check: what is the purpose of this initializer? It is not used and I'm not sure if we have a case for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This acts as the primary configure method, while the other one is merely a convenience method. The convenience configure method is supposed to call this one, but I just realized that it's not the case. Resolved in 3d77d0a

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@salimbraksa salimbraksa merged commit cac14dc into feature/notifications_refresh_p2 May 8, 2024
25 checks passed
@salimbraksa salimbraksa deleted the task/notifications-comment-content branch May 8, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants