Skip to content

[Modal Layout Picker] Create Layout Picker category bar UI using static data#12573

Merged
antonis merged 39 commits intodevelopfrom
issue/2437-MLP_Categories
Sep 14, 2020
Merged

[Modal Layout Picker] Create Layout Picker category bar UI using static data#12573
antonis merged 39 commits intodevelopfrom
issue/2437-MLP_Categories

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Jul 31, 2020

Fixes: wordpress-mobile/gutenberg-mobile#2437

Related PRs:

Description

This PR implements the category bar in the header of the Starter Page Template Picker for new pages.

To test:

Layout Picker should show when creating a new page from My Site or Site Pages the Modal Layout Picker appears.

Note: For demo/testing purposes, the categories repeat the same layout 30 times because the static data only has one layout per category.

Select a Category

  1. Select a category
    • Expect to see the sections condensed to be only the selected category filter
  2. Deselect the category
    • Expect to see the other categories return

Select Multiple-Categories

  1. Select a category
    • Expect to see the sections condensed to be only the selected category filter
  2. Select a different category
    • Expect to see the new section added to the list
  3. Deselect a category
    • Expect the list to update again to be only the selected categories
  4. Deselect the rest of the categories
    • Expect the all of the categories to return

Selecting a Layout then filter on the same category

  1. Select a layout in a category such as Blog
  2. Select the category in the filter bar that matches the category of the selected layout
    • Expect to see the section updated to only show the selected category, and for the selected layout to still be selected.
  3. Deselect the category in the filter
    • Expect to see the other categories return, and for the selected layout to still be selected.

Selecting a Layout then filter on the same category deselect layout

  1. Select a layout in a category such as Blog
  2. Select the category in the filter bar that matches the category of the selected layout
    • Expect to see the section updated to only show the selected category, and for the selected layout to still be selected.
  3. Deselect the layout
    • Expect the bottom bar to revert to "Create a Blank Page"
  4. Deselect the category in the filter
    • Expect to see the other categories return, and for no layout to be selected

Selecting a Layout then filter on a different category

  1. Select a layout in a category such as Blog
  2. Select a category in the filter bar that does not match the category of the selected layout
    • Expect to see the section updated to only show the selected category, and for the bottom bar to remain as "Preview" and "Create Page"
  3. Deselect the category in the filter
    • Expect to see the other categories return, and for the selected layout to still be selected.

Selecting a Layout then filter on a different category select a different layout

  1. Select a layout in a category such as Blog
  2. Select a category in the filter bar that does not match the category of the selected layout
    • Expect to see the section updated to only show the selected category, and for the bottom bar to remain as "Preview" and "Create Page"
  3. Select a different layout
  4. Deselect the category in the filter
    • Expect to see the other categories return, and for the selected layout from step 3 to still be selected.

Screenshots:

No category Selected category
device-2020-08-03-134049 device-2020-08-03-134102
No category dark Selected category dark
device-2020-08-03-134736 device-2020-08-03-134716
Selection Selection dark
2 1

PR submission checklist:

  • I have considered adding unit tests where possible.
  • 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.

@antonis antonis added [Type] Enhancement [Status] Needs Design Review A designer needs to sign off on the implemented design. labels Jul 31, 2020
@antonis antonis self-assigned this Jul 31, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Jul 31, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Jul 31, 2020

You can test the changes on this Pull Request by downloading the APK here.

@antonis antonis force-pushed the issue/2437-MLP_Categories branch from 04acaf7 to fc54662 Compare August 3, 2020 09:55
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Aug 3, 2020

Hello @iamthomasbishop 👋 ,
I have drafted the layout categories selection using static data. There are still some rough edges that I need to take care of (e.g. landscape mode and some UI bugs) but at this point this should behave very close to the final MLP.
You can check the screenshots attached to the PR or download the APK here.

I have a question regarding the expected behavior when the user selected layout is filtered out (Selection dark gif above). Should we just hide it or also clear the user selection?

Thank you in advance for your feedback 🙇

cc @chipsnyder

@chipsnyder
Copy link
Copy Markdown
Contributor

I have a question regarding the expected behavior when the user selected layout is filtered out (Selection dark gif above). Should we just hide it or also clear the user selection?

IMO if the selection is filtered out then we should treat it as being deselected.

@iamthomasbishop
Copy link
Copy Markdown

iamthomasbishop commented Aug 4, 2020

I have a question regarding the expected behavior when the user selected layout is filtered out (Selection dark gif above). Should we just hide it or also clear the user selection?

I have a counter to @chipsnyder's opinion 😃 I would actually keep the selection, because:

  • If I've tapped a layout and move about, then brought back into view via the filters, its state is stored. In most cases, I want to keep it selected as I explore.
  • If I want to make a new selection, all I have to do is tap a different one.

Some of the early designs tried a couple of treatments/call-outs for the "selected" one, but in the end decided to keep it super simple and understood the trade-off would be exactly this situation (when filters toggle the row a selected item is in).

antonis added 8 commits August 4, 2020 23:13
…tegories

# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerAdapter.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerFragment.kt
…tegories

# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/viewmodel/mlp/ModalLayoutPickerViewModel.kt
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/LayoutSelectionListener.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/LayoutsAdapter.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerAdapter.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerFragment.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerListItem.kt
#	WordPress/src/main/java/org/wordpress/android/ui/mlp/ModalLayoutPickerViewHolder.kt
#	WordPress/src/main/java/org/wordpress/android/viewmodel/mlp/ModalLayoutPickerViewModel.kt
#	WordPress/src/main/res/values/colors.xml
#	WordPress/src/main/res/values/dimens.xml
#	WordPress/src/test/java/org/wordpress/android/viewmodel/mlp/ModalLayoutPickerViewModelTest.kt
@antonis antonis changed the base branch from issue/2436-MLP_with_static_data to develop September 1, 2020 14:19
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Sep 4, 2020

Warnings
⚠️ PR is not assigned to a milestone.
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@antonis antonis marked this pull request as ready for review September 7, 2020 11:10
@antonis antonis requested a review from ashiagr September 7, 2020 11:15
Copy link
Copy Markdown
Contributor

@ashiagr ashiagr left a comment

Choose a reason for hiding this comment

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

I tested described flows and everything came across very well. Nice job @antonis !
Just left few code-related comments/ suggestions, lmkwyt.

Also I haven't reviewed test cases yet, will review after this first pass.

)
category.setTextColor(
parent.context.getColorFromAttribute(
if (selected) attr.categoriesButtonTextSelected else attr.categoriesButtonText
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we pass selected state values from the ViewModal itself instead of adding this logic in the ViewHolder?

Also instead of creating our own layouts to filter content, we can use pre-built material filter-chips. These can be added in a ChipGroup and put into a single line using singleLine. This is just a suggestion, feel free to ignore it 🙂.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good suggestion. I've moved the state values to UiState with 52cbeff.

Using the material filter-chips looks like a good improvement. I suggest to leave this to be revisited along with design feedback. Wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to leave this to be revisited along with design feedback. Wdyt?

Sounds good 👍

Comment on lines +73 to +79
<item name="categoriesButtonText">@color/white</item>
<item name="categoriesButtonBackground">@color/mlp_categories_button_background_dark</item>
<item name="categoriesButtonTextSelected">@color/black</item>
<item name="categoriesButtonBackgroundSelected">@color/mlp_categories_button_background_selected_dark</item>
<item name="categoriesButtonCheckIconColor">@color/black</item>
<item name="mlpDividerColor">@color/mlp_divider_dark</item>
<item name="categoriesBackground">@color/mlp_categories_background_dark</item>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using separate colors in values-night/styles.xml and values/styles.xml we can use color attributes from the Material Design theme.

e.g.
For categoriesButtonText which is
<item name="categoriesButtonText">@color/white</item> in dark mode
and
<item name="categoriesButtonText">@color/black</item> in light mode

we can use colorOnSurface which gives the same output and we need not add additional style attributes specially for Modal Layout Picker. Lmkwyt.

I myself get confused when to use new style or use these existing color attributes 🙂 but in the end find that we can eliminate most of such styles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed with 90dc9c3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! Wondering if we can eliminate remaining ones as well 🤔. These use different shades of grey:

categoriesBackground
categoriesButtonBackground
categoriesButtonBackgroundSelected
mlpDividerColor

Is it possible that we combine emphasis or alpha values with color attributes like colorSurface to get that shade? We can address it in design review. Feel free to ignore it here.

@antonis antonis requested a review from ashiagr September 8, 2020 12:40
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Sep 9, 2020

Can we add a method onAppBarOffsetChanged in the VM, pass verticalOffset, scrollThreshold as params and call setHeaderTitleVisibility from inside that method based on verticalOffset < scrollThreshold condition?

Yes we can. Thank you for suggesting this :)
I tackled this with 429444d

Copy link
Copy Markdown
Contributor

@ashiagr ashiagr left a comment

Choose a reason for hiding this comment

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

Changes look good to me. Also I've reviewed the tests.
Thank you for all the hard work here @antonis !

I haven't merged this PR yet because of the "Needs Design Review" label. Feel free to merge if it is not a blocker.

@antonis antonis merged commit ae6afe7 into develop Sep 14, 2020
@antonis antonis deleted the issue/2437-MLP_Categories branch September 14, 2020 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Design Review A designer needs to sign off on the implemented design. [Type] Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants