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

Reader: Show empty state for individual rows #23144

Merged
merged 2 commits into from
May 9, 2024

Conversation

dvdchr
Copy link
Contributor

@dvdchr dvdchr commented May 2, 2024

Part of #23069

As titled, this shows an empty state cell when there are no posts under a tag. For cases with no internet connection, after loading fails, the collection view will still display cached posts (if it exists) before displaying the empty state cell. Some more technical changes:

  • Added Section and CardCellItem in ReaderTagCardCell to encapsulate the section & item identifier of the diffable data source. Since the generic type now differs from the one returned from NSFetchedResultsController, I've added a method to translate them to the correct structure.
  • Added ReaderTagCardEmptyCell for the empty state cell. This cell's width is set to the collection view's width.
  • Added AdaptiveCollectionViewFlowLayout so that the collection view properly resizes on orientation change.
  • In the ReaderTagCardCell.xib, I've removed the 8pt leading constraint since it made the empty cell look skewed/not centered. I can revert this if this value was intended.

Here's a preview:

Light Dark

To test

Since the collection view will still display the list if there are cached items, you can modify this line (ReaderTagCardCellViewModel.swift:L171) to ensure that the empty state cell will always be shown:

    let isEmpty = true // coreDataSnapshot.numberOfItems == .zero
  • Launch the Jetpack app.
  • Go to the Reader tab and switch to the tags stream.
  • 🔎 Verify that the empty state cell is displayed correctly.
  • Tap the 'Retry' button.
  • 🔎 Verify that the cell shows the loading state, and then dismisses it after the request completes.
  • Rotate the device.
  • 🔎 Verify that the collection view resizes correctly.

Regression Notes

  1. Potential unintended areas of impact
    Should be none. Component is isolated and hidden behind a feature flag.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manually tested the changes.

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

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)

dvdchr added 2 commits May 2, 2024 19:41
Also included:
* Modified the leading constraint of the collection view in
  ReaderTagCardCell.xib.
* Added AdaptiveCollectionViewFlowLayout to refresh the collection
  view on orientation change.
* Added ReaderTagCardEmptyCell, a collection view cell for the
  empty state. It hosts a SwiftUI view.
@dvdchr dvdchr added this to the 24.9 milestone May 2, 2024
@dvdchr dvdchr requested a review from wargcm May 2, 2024 20:12
@dvdchr dvdchr self-assigned this May 2, 2024
@dvdchr dvdchr mentioned this pull request May 2, 2024
@wpmobilebot
Copy link
Contributor

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 Numberpr23144-e91bbb7
Version24.8
Bundle IDorg.wordpress.alpha
Commite91bbb7
App Center BuildWPiOS - One-Offs #9772
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

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 Numberpr23144-e91bbb7
Version24.8
Bundle IDcom.jetpack.alpha
Commite91bbb7
App Center Buildjetpack-installable-builds #8818
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@wargcm wargcm left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@dvdchr dvdchr merged commit 65bed38 into trunk May 9, 2024
25 of 29 checks passed
@dvdchr dvdchr deleted the issue/23069-cell-empty-state branch May 9, 2024 16:49
Copy link

sentry-io bot commented May 10, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ NSInternalInconsistencyException: attempt to insert item 6 into section 0, but there are only 6 items in section 0 after the update ReaderTagCardCellViewModel.controller View Issue

Did you find this useful? React with a 👍 or 👎

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.

3 participants