[Modal Layout Picker] Create sections and thumbnail UI using static data#14553
[Modal Layout Picker] Create sections and thumbnail UI using static data#14553chipsnyder merged 40 commits intodevelopfrom
Conversation
…g/issue/2436-thumbailPreviews
…g/issue/2436-thumbailPreviews
…g/issue/2436-thumbailPreviews
…r more consistent behavior
|
You can trigger an installable build for these changes by visiting CircleCI here. |
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
Generated by 🚫 dangerJS |
|
Hey @iamthomasbishop, I was able to get a build (
And of course anything else you notice in this build or that we didn't cover in the last PR. |
| let layout = layouts[0] // Static layouts currently only have one layout per category. Reusing the first to help test | ||
| cell.layout = layout | ||
| cell.isAccessibilityElement = true | ||
| cell.accessibilityLabel = layout.title + " \(indexPath.item)" |
There was a problem hiding this comment.
The accessibilityLabel here is using the indexPath as a temporary crutch for testing since the elements are reused.
There was a problem hiding this comment.
Any idea about how descriptive the real names will be?
There was a problem hiding this comment.
The names really aren't that descriptive. The title for the majority of them just aligns with the category title, or we could format the slug which is mostly this same pattern category-#. We'll probably want to have a discussion on what the best value for this would be.
| } | ||
| } | ||
|
|
||
| class AccessibleCollectionView: UICollectionView { |
There was a problem hiding this comment.
This class is being used as a way to work around an issue where the collection view wasn't correctly registering the accessible elements when in a table view cell
Sure! Will take a look asap. Probably tomorrow morning 👍 |
| } | ||
| } | ||
|
|
||
| var completion: PageCoordinator.TemplateSelectionCompletion? = nil |
There was a problem hiding this comment.
This was just moved lower in the section of vars largely just so I would still see it.
| return largeTitleView.frame.height + | ||
| midHeaderHeight |
There was a problem hiding this comment.
Switched these (max|mid|min)HeaderHeight to be stored values, because once I started loading the table view with data I found inconsistency with how the header and footers would layout depending on layout timing. Controlling this value just gave me a better experience.
| func addShadow() { | ||
| layer.shadowColor = UIColor.black.cgColor | ||
|
|
||
| let scale = UIScreen.main.scale |
There was a problem hiding this comment.
I'm dividing by the scale on these values to get closer to what the design specs have however this might be temporary as we continue to refine the shadow in design review. I updated this in the category bar PR to remove this scale and use the same point value.
etoledom
left a comment
There was a problem hiding this comment.
Amazing job @chipsnyder ! 🎉
Just one tinny comment on code, but it looks shinny ✨
- Testing steps resulted as expected (except loading indicators) ✅
- VoiceOver ✅
- RTL layout ✅
- Downloading the thumbnails don't work amazingly well right now. That will be adjusted in a later PR (see additional notes above)
- We're working on the footer buttons dark mode UI
This cover most of my observations. So I'd expect there not to be a loading indicator, right?
A couple other UI small details:
-
Probably it would be nice to set the trailing constraint of the close button to the safe area layout. It looks to me it's too far to the right on landscape:

-
The collection view has a nice left padding but it seems to miss an equal right padding.

-
I'm kind of missing an alternative way to deselect the selected item. This became specially tricky with VoiceOver. The selected item can get lost from the UI and to find it and deselect it can be difficult. Selecting another item and deselecting it works but not sure if we should consider that as an alternative. No hard feelings on this one though, just a thought.
cc @iamthomasbishop to corroborate UI stuff.
|
|
||
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| let cell = UITableViewCell(style: .default, reuseIdentifier: nil) | ||
| let cell = tableView.dequeueReusableCell(withIdentifier: LayoutPickerSectionTableViewCell.cellReuseIdentifier, for: indexPath) as! LayoutPickerSectionTableViewCell |
There was a problem hiding this comment.
Could we guard this cast?
I understand this should never fail but it might if we modify this class in the future.
- If we do want to crash let's do it explicitly with a
fatalErrorwith a descriptive message. - Alternatively we could try to recover instantiating the cell manually and calling an
assertionFailureto let us know something is wrong.
Same on the CollectionViewController.
There was a problem hiding this comment.
Yeah, that's a good point. I think here a guard would just return an empty Table View cell and a crash would be the result of failing to register the correct xib. So I think I like your first option of using the fatalError better that will help future developers if something goes wrong.
| guard UIAccessibility.isVoiceOverRunning, let cellIndexPath = tableView.indexPath(for: cell) else { return } | ||
| tableView.scrollToRow(at: cellIndexPath, at: .middle, animated: true) |
…ll call are referencing the same reuse identifier
|
Thanks for the review @etoledom!
This has been added now.
Great catch on both of these. This has been adjusted.
This is the only one I didn't take care of yet. I'm not sure what another mechanism would look like but open to suggestions. This could be something we revisit if when we come up with a good approach. |
@etoledom That's correct, we'd just show placeholders in the form of ghost/skeleton loaders.
I'm not exactly sure what you mean by "gets lost", but if it is disappearing, that would be frustrating. Ideally, you'd just be able to tap a selected cell again to de-select it or tap another cell to transfer selection, but if we need an explicit "clear" button of sorts, maybe we can do something to facilitate this case. Agreed w/ you on all of your other feedback 👍 Thanks for jumping on that stuff quickly, @chipsnyder ! |
I meant: If you select an item, then continue scrolling horizontally, then scroll some more vertically, it can be challenging to navigate back to find again the selected item, specially for VoiceOver users. I wouldn't say this is a blocker nor something we must fix at all, but more just as an observation. I don't have a good solution in mind either, so no need to focus about this on this PR. |
etoledom
left a comment
There was a problem hiding this comment.
Thank you @chipsnyder for the updates!
Looking great to me 🎉
@etoledom Ahh, okay, that makes more sense. For what it's worth, one of my early design concepts had a special call-out/section at the top of the list that showed "selected layout", but we decided against it because it took up a lot of space. Perhaps this is something we can keep an eye on and add something similar as part of a future iteration. Thanks for raising this! |
|
Checked with @iamthomasbishop merging this piece we'll tackle the lingering design items in later PRs and before enabling this in the wild. |
Fixes wordpress-mobile/gutenberg-mobile#2436
To test:
To disable or enable the development version of Modal Layout Picker
To toggle:
When enabled, the Layout Picker should show when creating a new page from My Site and from the Page list.
Start by navigating to the Modal Layout Picker
General Navigation
Note: Currently, the categories repeat the same layout 30 times because the static data only has one layout per category.
Preview Images
Selecting a Layout
Selecting a layout should highlight the cell and add a checkmark
Only one layout should be selected at any given time
Selecting a Layout should show the buttons "Preview" and "Create Page"
Deselecting a layout should revert the bottom bar to "Create Blank Page"
Screenshots:
Additional Context:
This is a continuation of the work started in #14501 and will be followed up by other tickets as part of Modal Layout Picker Project
Placeholder images and downloading the images on poor network connections will be refined as part of wordpress-mobile/gutenberg-mobile#2445
PR submission checklist:
RELEASE-NOTES.txtif necessary.