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

RN: Add Bottom Sheet Select Control component #28543

Merged
merged 16 commits into from
Feb 25, 2021

Conversation

enejb
Copy link
Contributor

@enejb enejb commented Jan 28, 2021

This PR adds a new Bottom Sheet Selector Component and implements it for the Button Block so that you can pick different buttons widths.

Description

This PR does a few different things.

  1. It adds a new BottomSheetSubSheet component. That is suppose to make it easier to create new controls that navigate using in the BottomSheet one level deep.
  2. It add a new BottomSheetSelectControl that lets you pass in bunch of option and lets the user select the one
  3. It add the new BottomSheetSelectControl to the Button Settings so that the user can choose the Button Width.

How has this been tested?

Load this PR.
Add a button block.
Change the button width.
Does it work as expected.

Screenshots

new-selector.mov
iOS
Button Settings Button Width Selection
simulator_screenshot_575C71A0-100F-4D0E-841D-C2A4392C2E85 Simulator Screen Shot - iPhone 11 Pro - 2021-01-29 at 18 16 26
Button Settings Button Width Selection
Simulator Screen Shot - iPhone 11 - 2021-02-02 at 21 40 51 Simulator Screen Shot - iPhone 11 - 2021-02-02 at 21 41 01

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@enejb enejb changed the title Add Bottom Sheet Select Control componet RN: Add Bottom Sheet Select Control componet Jan 28, 2021
@github-actions
Copy link

github-actions bot commented Jan 28, 2021

Size Change: +3.79 kB (0%)

Total Size: 1.39 MB

Filename Size Change
build/a11y/index.js 1.14 kB +1 B (0%)
build/annotations/index.js 3.79 kB +13 B (0%)
build/api-fetch/index.js 3.41 kB +4 B (0%)
build/block-directory/index.js 9.1 kB +3 B (0%)
build/block-editor/index.js 124 kB +197 B (0%)
build/block-editor/style-rtl.css 12.1 kB +1 B (0%)
build/block-library/blocks/buttons/editor-rtl.css 315 B +82 B (+35%) 🚨
build/block-library/blocks/buttons/editor.css 315 B +82 B (+35%) 🚨
build/block-library/blocks/buttons/style-rtl.css 364 B +46 B (+14%) ⚠️
build/block-library/blocks/buttons/style.css 363 B +45 B (+14%) ⚠️
build/block-library/blocks/navigation-link/editor.css 395 B -2 B (-1%)
build/block-library/blocks/query/editor-rtl.css 814 B +655 B (+412%) 🆘
build/block-library/blocks/query/editor.css 812 B +652 B (+408%) 🆘
build/block-library/blocks/social-links/style-rtl.css 1.32 kB -43 B (-3%)
build/block-library/blocks/social-links/style.css 1.32 kB -42 B (-3%)
build/block-library/editor-rtl.css 9.44 kB +402 B (+4%)
build/block-library/editor.css 9.43 kB +403 B (+4%)
build/block-library/index.js 148 kB +1.03 kB (+1%)
build/block-library/style-rtl.css 8.83 kB -15 B (0%)
build/block-library/style.css 8.84 kB -14 B (0%)
build/blocks/index.js 48.3 kB +12 B (0%)
build/components/index.js 272 kB -6 B (0%)
build/compose/index.js 11.1 kB +6 B (0%)
build/core-data/index.js 16.8 kB +8 B (0%)
build/customize-widgets/index.js 4.08 kB +4 B (0%)
build/data/index.js 8.87 kB +8 B (0%)
build/date/index.js 31.8 kB +1 B (0%)
build/dom/index.js 4.95 kB +14 B (0%)
build/edit-navigation/index.js 11 kB +17 B (0%)
build/edit-post/index.js 307 kB +9 B (0%)
build/edit-site/index.js 26.4 kB +18 B (0%)
build/edit-widgets/index.js 20.1 kB +16 B (0%)
build/editor/index.js 42.1 kB +17 B (0%)
build/element/index.js 4.62 kB +6 B (0%)
build/format-library/index.js 6.77 kB -1 B (0%)
build/i18n/index.js 4.01 kB +4 B (0%)
build/keyboard-shortcuts/index.js 2.54 kB +6 B (0%)
build/keycodes/index.js 1.96 kB +5 B (0%)
build/media-utils/index.js 5.36 kB +7 B (0%)
build/notices/index.js 1.86 kB +5 B (0%)
build/nux/index.js 3.42 kB +4 B (0%)
build/plugins/index.js 2.55 kB +2 B (0%)
build/primitives/index.js 1.42 kB +7 B (0%)
build/redux-routine/index.js 2.83 kB -2 B (0%)
build/reusable-blocks/index.js 3.77 kB +5 B (0%)
build/rich-text/index.js 13.5 kB +108 B (+1%)
build/server-side-render/index.js 2.82 kB +6 B (0%)
build/url/index.js 3.02 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/autop/index.js 2.84 kB 0 B
build/blob/index.js 665 B 0 B
build/block-directory/style-rtl.css 1.01 kB 0 B
build/block-directory/style.css 1.01 kB 0 B
build/block-editor/style.css 12.1 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 103 B 0 B
build/block-library/blocks/audio/style.css 103 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 479 B 0 B
build/block-library/blocks/button/style.css 479 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 421 B 0 B
build/block-library/blocks/columns/style.css 421 B 0 B
build/block-library/blocks/cover/editor-rtl.css 390 B 0 B
build/block-library/blocks/cover/editor.css 389 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.25 kB 0 B
build/block-library/blocks/cover/style.css 1.25 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 396 B 0 B
build/block-library/blocks/embed/style.css 395 B 0 B
build/block-library/blocks/file/editor-rtl.css 199 B 0 B
build/block-library/blocks/file/editor.css 198 B 0 B
build/block-library/blocks/file/style-rtl.css 248 B 0 B
build/block-library/blocks/file/style.css 248 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.45 kB 0 B
build/block-library/blocks/freeform/editor.css 2.45 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 689 B 0 B
build/block-library/blocks/gallery/editor.css 690 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.07 kB 0 B
build/block-library/blocks/gallery/style.css 1.06 kB 0 B
build/block-library/blocks/group/editor-rtl.css 318 B 0 B
build/block-library/blocks/group/editor.css 317 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 717 B 0 B
build/block-library/blocks/image/editor.css 716 B 0 B
build/block-library/blocks/image/style-rtl.css 477 B 0 B
build/block-library/blocks/image/style.css 478 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 159 B 0 B
build/block-library/blocks/latest-comments/editor.css 158 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 269 B 0 B
build/block-library/blocks/latest-comments/style.css 269 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 523 B 0 B
build/block-library/blocks/latest-posts/style.css 522 B 0 B
build/block-library/blocks/list/editor-rtl.css 65 B 0 B
build/block-library/blocks/list/editor.css 65 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 191 B 0 B
build/block-library/blocks/media-text/editor.css 191 B 0 B
build/block-library/blocks/media-text/style-rtl.css 535 B 0 B
build/block-library/blocks/media-text/style.css 532 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 395 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 704 B 0 B
build/block-library/blocks/navigation-link/style.css 702 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.34 kB 0 B
build/block-library/blocks/navigation/editor.css 1.34 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 195 B 0 B
build/block-library/blocks/navigation/style.css 195 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 214 B 0 B
build/block-library/blocks/page-list/editor.css 214 B 0 B
build/block-library/blocks/page-list/style-rtl.css 527 B 0 B
build/block-library/blocks/page-list/style.css 526 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 109 B 0 B
build/block-library/blocks/paragraph/editor.css 109 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 273 B 0 B
build/block-library/blocks/paragraph/style.css 273 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 250 B 0 B
build/block-library/blocks/post-comments-form/style.css 250 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 100 B 0 B
build/block-library/blocks/post-featured-image/style.css 100 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 63 B 0 B
build/block-library/blocks/preformatted/style.css 63 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 316 B 0 B
build/block-library/blocks/pullquote/style.css 316 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 90 B 0 B
build/block-library/blocks/query-loop/editor.css 89 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/quote/editor-rtl.css 61 B 0 B
build/block-library/blocks/quote/editor.css 61 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 165 B 0 B
build/block-library/blocks/search/editor.css 165 B 0 B
build/block-library/blocks/search/style-rtl.css 342 B 0 B
build/block-library/blocks/search/style.css 344 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 236 B 0 B
build/block-library/blocks/separator/style.css 236 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 504 B 0 B
build/block-library/blocks/shortcode/editor.css 504 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 201 B 0 B
build/block-library/blocks/site-logo/editor.css 201 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 115 B 0 B
build/block-library/blocks/site-logo/style.css 115 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 696 B 0 B
build/block-library/blocks/social-links/editor.css 696 B 0 B
build/block-library/blocks/spacer/editor-rtl.css 302 B 0 B
build/block-library/blocks/spacer/editor.css 302 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 99 B 0 B
build/block-library/blocks/subhead/editor.css 99 B 0 B
build/block-library/blocks/subhead/style-rtl.css 80 B 0 B
build/block-library/blocks/subhead/style.css 80 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 390 B 0 B
build/block-library/blocks/table/style.css 390 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 557 B 0 B
build/block-library/blocks/template-part/editor.css 556 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/editor-rtl.css 62 B 0 B
build/block-library/blocks/verse/editor.css 62 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 504 B 0 B
build/block-library/blocks/video/editor.css 503 B 0 B
build/block-library/blocks/video/style-rtl.css 193 B 0 B
build/block-library/blocks/video/style.css 193 B 0 B
build/block-library/common-rtl.css 1.08 kB 0 B
build/block-library/common.css 1.08 kB 0 B
build/block-library/theme-rtl.css 736 B 0 B
build/block-library/theme.css 736 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/components/style-rtl.css 15.5 kB 0 B
build/components/style.css 15.5 kB 0 B
build/customize-widgets/style-rtl.css 168 B 0 B
build/customize-widgets/style.css 168 B 0 B
build/data-controls/index.js 831 B 0 B
build/deprecated/index.js 769 B 0 B
build/dom-ready/index.js 576 B 0 B
build/edit-navigation/style-rtl.css 1.26 kB 0 B
build/edit-navigation/style.css 1.25 kB 0 B
build/edit-post/style-rtl.css 6.81 kB 0 B
build/edit-post/style.css 6.8 kB 0 B
build/edit-site/style-rtl.css 4.41 kB 0 B
build/edit-site/style.css 4.41 kB 0 B
build/edit-widgets/style-rtl.css 3.2 kB 0 B
build/edit-widgets/style.css 3.2 kB 0 B
build/editor/editor-styles-rtl.css 543 B 0 B
build/editor/editor-styles.css 545 B 0 B
build/editor/style-rtl.css 3.89 kB 0 B
build/editor/style.css 3.89 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.js 2.28 kB 0 B
build/html-entities/index.js 622 B 0 B
build/is-shallow-equal/index.js 698 B 0 B
build/list-reusable-blocks/index.js 3.14 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/priority-queue/index.js 791 B 0 B
build/react-i18n/index.js 1.45 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/viewport/index.js 1.86 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@enejb enejb requested review from mkevins and geriux January 29, 2021 01:40
@enejb enejb self-assigned this Jan 29, 2021
@enejb enejb added [Package] Components /packages/components Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) Needs Design Needs design efforts. labels Jan 29, 2021
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

The InspectorControlsChild abstraction makes sense to me. Good work! I left a few comments to consider. Let me know what you think.

@iamthomasbishop
Copy link

@enejb This looks fantastic, nice work! One tiny thing I noticed is that the margins on the left/right sides of the sub-sheet look a bit too narrow. I believe 16px is our standard margin on BottomSheets. Here's a visual for reference:

@enejb
Copy link
Contributor Author

enejb commented Jan 30, 2021

@iamthomasbishop

I updated the padding as well.
Simulator Screen Shot - iPhone 11 Pro - 2021-01-29 at 18 16 26

I didn't update the back button mostly since I am using the current componet that is shared with other parts of the app.

the spacing is the same as the Colour Picker see.
Simulator Screen Shot - iPhone 11 Pro - 2021-01-29 at 18 15 26

@iamthomasbishop
Copy link

@enejb This looks great, thanks for tidying that spacing up.

I didn't update the back button mostly since I am using the current componet that is shared with other parts of the app.

That's fine, the offset on the back button is intentional to match the system-style back button on iOS.

Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

Offered some additional ideas for naming and documentation clarity. Feel free to disregard them if you disagree, though.

@enejb enejb force-pushed the RN/add/bottom-sheet-child-page branch 2 times, most recently from 7b4649d to 9ca4cfd Compare February 3, 2021 05:19
@enejb enejb marked this pull request as ready for review February 3, 2021 05:26
Copy link
Contributor

@mkevins mkevins left a comment

Choose a reason for hiding this comment

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

I think this is getting into good shape. Ideally, IMO, the select control and the generic subsheet implementation would be introduced in separate PRs, since the abstractions introduced are for separate concerns.

Select Control

I like the interface, and especially that it encapsulates the Cell, which is a bit cumbersome to use directly. It is implemented very close to how I'd envisioned it. One thing I'd consider adding is an option title prop, specified after label, so its default value could be label. This would make it slightly more flexible in that the button label wouldn't be tied to the header title of the subsheet.

BottomSheet.SubSheet

I've struggled to find an optimal solution for this abstraction. In its current form, it feels to me like the consumers bear too much of the responsibillity of both state management and rendering, yet I don't see a trivial way of avoiding that without a great loss in generality in the potential usage patterns.

If we succeeded in finding a way around that, we still have a limitation regarding nested usage, since we'd encounter route-name collisions. I think, in any case, that limitation should be documented, but I'm concerned it may not always be clear where this assumption is violated. For example, I was considering a lint-rule, but quickly realized that any descendent component would need to know whether any of its parent components were rendered as a child of the sub-sheet (or vice-versa), which could easily be in another file, and potentially even dynamic (platform variants come to mind).

The alternative is a bit verbose, though, in that new screens would need to be declared in the block settings bottomsheet for each component. This seems a natural consequence of our shared usage of the bottomsheet for all blocks' settings, but passing the route-params back from a shared subscreen is of limited use if we are utilizing the component for multiple separate settings in the parent (it likely makes more sense to use a callback instead). We've been able to use the route-params so far, since the screens defined only ever have singular use for a given modal render.

I think what inherently makes this challenging is that we are using a few different (but similar) patterns to address some cross-cutting concerns within the bottomsheet and block settings (namely contexts, slot-fill, and navigation), and there is some overlap in their potential responsibilities. Navigation, for example, is responsible for whether or not a particular screen is rendered via routes and its stack, while the slot-fills used here have a boolean state variable controlling whether they should render. Another area of overlap is the provider / consumers which can pass props "through" the component heirarchy, while navigation uses params to pass similar information (though the screens themselves are conceptually decoupled from a heirarchy, and are only incidentally heirarchial based on how they are routed, or from their stateful relationships within the stack).

In search of a general solution, I think it's worth considering the case for nested subsheets, and perhaps we could define a convention for dynamic route names that serve this purpose. I haven't had a chance to explore this fully yet, but I believe it's possible, via something like this snack proof of concept I've created: https://snack.expo.io/d6RZX2pY9. I think if we get it right, this could allow us to simplify / DRY up a lot of the current code. Wdyt about the pattern used in that snack?

}
showSheet={ showSubSheet }
>
<SafeAreaView>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether it makes sense to move SafeAreaView to the subsheet? One less responsibility for the consumers. The only bottomsheet usage I'm aware of is the fullscreen subsheet style = {height: 100%}, and that style could also be conditionally applied at the subsheet level, since we have the prop there.

>
<SafeAreaView>
<NavigationHeader
screen={ label }
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are refactoring a bit in this PR, I think a better name for the screen prop is title, especially since the screen in the generic subsheet will have a fixed name now, and this really represents a user-readable string, wherease a screen's name is being used as a programmatic identifier in navigation routes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I think we should tackle this in a different PR mostly since this one is already getting pretty big and it will require changing a few different components.

Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

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

Hey @enejb!

Great work on this!

I left some comments and an issue I found while testing.

I also tested on both platforms (iOS/Android) and I didn't see any visual/functionality issues between them.

screen={ label }
leftButtonOnPress={ goBack }
/>
<View paddingHorizontal={ 16 }>
Copy link
Member

Choose a reason for hiding this comment

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

Can we use style instead? And use the margins from $block-edge-to-content?

@geriux
Copy link
Member

geriux commented Feb 9, 2021

Thank you for the changes @enejb!

I gave this another test and the other issues were fixed but I just found another one on larger screens and the full-width option:

In this case, the Buttons block is set to full-width and the button within is also set to 100% but it looks like is using the max-width from the editor instead of the parent's width.

Here's the HTML code

<!-- wp:buttons {"contentJustification":"center","align":"full"} -->
<div class="wp-block-buttons alignfull is-content-justification-center"><!-- wp:button {"gradient":"pale-ocean","width":100} -->
<div class="wp-block-button has-custom-width wp-block-button__width-100"><a class="wp-block-button__link has-pale-ocean-gradient-background has-background" href="" rel="">Button 2</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

<!-- wp:cover {"customOverlayColor":"#EE4266","align":"full"} -->
<div class="wp-block-cover alignfull has-background-dim" style="background-color:#EE4266"><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…"} -->
<p class="has-text-align-center">Full width</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->

@enejb
Copy link
Contributor Author

enejb commented Feb 9, 2021

Good catch will work on this soon.

@geriux
Copy link
Member

geriux commented Feb 18, 2021

Hey @enejb 👋

I started to test the latest changes but I encountered this issue:

Screenshot 2021-02-18 at 15 23 05

Just by setting the first Button width to 100% overflows its container.

Here's the HTML

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"width":100} -->
<div class="wp-block-button has-custom-width wp-block-button__width-100"><a class="wp-block-button__link" href="" rel="">Button 1</a></div>
<!-- /wp:button -->

<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">Button 2</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

@enejb enejb force-pushed the RN/add/bottom-sheet-child-page branch from 11f73a6 to 5e5cf75 Compare February 18, 2021 23:06
@enejb enejb force-pushed the RN/add/bottom-sheet-child-page branch from 5e5cf75 to 65ff7c5 Compare February 19, 2021 05:26
@enejb
Copy link
Contributor Author

enejb commented Feb 19, 2021

@geriux Thanks for testing.

I think I am getting much closer now.

Tablet

See

Full Width alignment selected.
simulator_screenshot_A8C90A3B-7306-4094-B92E-0B450F2B07D6

Wide Width alignment selected.
simulator_screenshot_971C5BE4-BBDE-4582-9D42-90227EB9D489

No Width alignment selected.
simulator_screenshot_3427BDDF-354B-4A7D-8908-616F9337A99B

Mobile

No Width alignment selected.
simulator_screenshot_C3DEDC5E-3E4E-4E87-86D1-4DC6401714D5

No Width alignment selected.
simulator_screenshot_7D3DE63C-C1EE-4132-B868-CE00821FEE01

Can you take another look?

@geriux
Copy link
Member

geriux commented Feb 24, 2021

Hey @enejb 👋 I've pushed a change that should fix the issue I found on iOS on landscape and the Safe Area:

I've checked different cases and it looks like it's working correctly, can you double check? Thanks!

@enejb
Copy link
Contributor Author

enejb commented Feb 24, 2021

I tested this on the Android side and iOS (iPhone 11 Pro and iPad Simulator) it worked as expected.

I think this is ready to ship!

@enejb enejb force-pushed the RN/add/bottom-sheet-child-page branch from 66c2115 to 9724732 Compare February 25, 2021 05:28
Copy link
Member

@geriux geriux left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Nice work @enejb! Before merging let's wait for the final design ✅ and also can you please update the CHANGELOG with this new feature? Thanks!

@enejb enejb merged commit fbf65da into master Feb 25, 2021
@enejb enejb deleted the RN/add/bottom-sheet-child-page branch February 25, 2021 17:51
@github-actions github-actions bot added this to the Gutenberg 10.2 milestone Feb 25, 2021
@enejb enejb changed the title RN: Add Bottom Sheet Select Control componet RN: Add Bottom Sheet Select Control component Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) Needs Design Needs design efforts. [Package] Components /packages/components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants