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

[Mobile] - Cover block - Media editing #23280

Merged
merged 18 commits into from Jul 24, 2020
Merged

Conversation

geriux
Copy link
Member

@geriux geriux commented Jun 18, 2020

Gutenberg Mobile PR -> wordpress-mobile/gutenberg-mobile#2403
WordPress iOS PR -> wordpress-mobile/WordPress-iOS#14420
WordPress Android PR -> wordpress-mobile/WordPress-Android#12356

Description

This PR adds Media editing functionality to the Cover block. With the recent changes and refactor we can reuse the same functionality as in Image and Media & Text block.

Since Cover has some overlay views, I had to extract the media editing button to be able to render it on top, so I created a new component ImageEditingButton which is the one that the Image component uses but now can be imported from other components for more customization.

It also adds a new prop pickerOptions to the MediaEdit component to pass extra options for the picker.

How has this been tested?

Steps to test ---

Edit an image

  • Open the app with metro running
  • Add a Cover block
  • Tap on the block and upload a picture
  • Once the image has been uploaded tap on it
  • Expect the image to be selected and the media button option to be visible at the top right
  • Tap on the media editing button
  • Expect to see the options
  • Tap on Edit
  • Expect to see the media editor
  • Edit the image and tap on done
  • Expect to see the edited picture uploaded

Replace an image

  • Open the app with metro running
  • Add a Cover block
  • Tap on the block and upload a picture
  • Once the image has been uploaded tap on it
  • Expect the image to be selected and the media button option to be visible at the top right
  • Tap on the media editing button
  • Expect to see the options
  • Tap on Replace
  • Expect to see the media picker
  • Upload a new picture
  • Expect to see the new picture uploaded

Full screen preview

  • Open the app with metro running
  • Add a Cover block
  • Tap on the block and upload a picture
  • Once the image has been uploaded tap on it
  • Expect the image to be selected
  • Tap on the image again
  • Expect to see the image in full screen

Screenshots

iOS Android

Types of changes

New feature

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.

@geriux geriux added [Status] In Progress Tracking issues with work in progress Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Jun 18, 2020
@github-actions
Copy link

github-actions bot commented Jun 18, 2020

Size Change: 0 B

Total Size: 1.15 MB

ℹ️ View Unchanged
Filename Size Change
build/a11y/index.min.js 1.14 kB 0 B
build/annotations/index.min.js 3.67 kB 0 B
build/api-fetch/index.min.js 3.43 kB 0 B
build/autop/index.min.js 2.82 kB 0 B
build/blob/index.min.js 620 B 0 B
build/block-directory/index.min.js 7.63 kB 0 B
build/block-directory/style-rtl.css 953 B 0 B
build/block-directory/style.css 952 B 0 B
build/block-editor/index.min.js 125 kB 0 B
build/block-editor/style-rtl.css 10.8 kB 0 B
build/block-editor/style.css 10.8 kB 0 B
build/block-library/editor-rtl.css 7.61 kB 0 B
build/block-library/editor.css 7.61 kB 0 B
build/block-library/index.min.js 132 kB 0 B
build/block-library/style-rtl.css 7.82 kB 0 B
build/block-library/style.css 7.83 kB 0 B
build/block-library/theme-rtl.css 728 B 0 B
build/block-library/theme.css 729 B 0 B
build/block-serialization-default-parser/index.min.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.min.js 3.1 kB 0 B
build/blocks/index.min.js 48.3 kB 0 B
build/components/index.min.js 200 kB 0 B
build/components/style-rtl.css 15.7 kB 0 B
build/components/style.css 15.6 kB 0 B
build/compose/index.min.js 9.68 kB 0 B
build/core-data/index.min.js 11.5 kB 0 B
build/data-controls/index.min.js 1.29 kB 0 B
build/data/index.min.js 8.45 kB 0 B
build/date/index.min.js 5.38 kB 0 B
build/deprecated/index.min.js 772 B 0 B
build/dom-ready/index.min.js 568 B 0 B
build/dom/index.min.js 3.23 kB 0 B
build/edit-navigation/index.min.js 10.8 kB 0 B
build/edit-navigation/style-rtl.css 1.08 kB 0 B
build/edit-navigation/style.css 1.08 kB 0 B
build/edit-post/index.min.js 304 kB 0 B
build/edit-post/style-rtl.css 5.61 kB 0 B
build/edit-post/style.css 5.61 kB 0 B
build/edit-site/index.min.js 16.9 kB 0 B
build/edit-site/style-rtl.css 3.06 kB 0 B
build/edit-site/style.css 3.06 kB 0 B
build/edit-widgets/index.min.js 9.37 kB 0 B
build/edit-widgets/style-rtl.css 2.45 kB 0 B
build/edit-widgets/style.css 2.45 kB 0 B
build/editor/editor-styles-rtl.css 537 B 0 B
build/editor/editor-styles.css 539 B 0 B
build/editor/index.min.js 45.3 kB 0 B
build/editor/style-rtl.css 3.78 kB 0 B
build/editor/style.css 3.78 kB 0 B
build/element/index.min.js 4.65 kB 0 B
build/escape-html/index.min.js 733 B 0 B
build/format-library/index.min.js 7.72 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.min.js 2.13 kB 0 B
build/html-entities/index.min.js 621 B 0 B
build/i18n/index.min.js 3.56 kB 0 B
build/is-shallow-equal/index.min.js 711 B 0 B
build/keyboard-shortcuts/index.min.js 2.51 kB 0 B
build/keycodes/index.min.js 1.94 kB 0 B
build/list-reusable-blocks/index.min.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.min.js 5.32 kB 0 B
build/notices/index.min.js 1.79 kB 0 B
build/nux/index.min.js 3.4 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.min.js 2.56 kB 0 B
build/primitives/index.min.js 1.4 kB 0 B
build/priority-queue/index.min.js 789 B 0 B
build/redux-routine/index.min.js 2.85 kB 0 B
build/rich-text/index.min.js 13.9 kB 0 B
build/server-side-render/index.min.js 2.71 kB 0 B
build/shortcode/index.min.js 1.7 kB 0 B
build/token-list/index.min.js 1.27 kB 0 B
build/url/index.min.js 4.06 kB 0 B
build/viewport/index.min.js 1.85 kB 0 B
build/warning/index.min.js 1.14 kB 0 B
build/wordcount/index.min.js 1.17 kB 0 B

compressed-size-action

@geriux geriux force-pushed the rnmobile/cover-media-editing branch 2 times, most recently from 64840d9 to 0206627 Compare July 7, 2020 11:42
@geriux geriux marked this pull request as ready for review July 7, 2020 15:43
@geriux geriux removed the [Status] In Progress Tracking issues with work in progress label Jul 7, 2020
@geriux geriux requested a review from mkevins July 7, 2020 15:48
@geriux geriux changed the title [RNMobile] - Cover block - Media editing [Mobile] - Cover block - Media editing Jul 7, 2020
@geriux
Copy link
Member Author

geriux commented Jul 7, 2020

Hey @iamthomasbishop 👋 This is also ready for a design review whenever you can. Thank you!

@geriux geriux changed the base branch from rnmobile/media-text-image-refactor to master July 8, 2020 16:33
@geriux geriux force-pushed the rnmobile/cover-media-editing branch from c4b465e to 48df5ed Compare July 8, 2020 16:48
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 tested this on Android (via Pixel 3a) using the steps provided and everything is working as described! I also tried leaving the editor while the upload for the newly edit image was completing, and reopening the editor shows the correct image (url is the remote one). Nice work @geriux 🎉 . Overall, code looks good, I just left a few suggestions.

packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/components/src/mobile/image/index.native.js Outdated Show resolved Hide resolved
@iamthomasbishop
Copy link

@geriux Looks mostly good! The only thing that stands out to me is that you have to tap twice to select the background image before seeing the edit button. Would it be possible to instead show the edit button when the parent is selected? I think this might feel more intuitive.

@geriux
Copy link
Member Author

geriux commented Jul 10, 2020

@geriux Looks mostly good! The only thing that stands out to me is that you have to tap twice to select the background image before seeing the edit button. Would it be possible to instead show the edit button when the parent is selected? I think this might feel more intuitive.

Thanks for the feedback @iamthomasbishop! So the thing is the Media edit button is included with the Image component, so its z-index only affects this component. In Cover, we have the overlay so if we make the button to show when the block is selected it'd show up like this:

One workaround I tried is to hide the overlay when it's selected, and only show it when the block options are shown for example:

But I'm not sure if it'd be confusing to make those opacity changes, what do you think?

# Conflicts:
#	packages/block-library/src/cover/edit.native.js
#	packages/block-library/src/cover/style.native.scss
@geriux geriux added the [Status] In Progress Tracking issues with work in progress label Jul 14, 2020
@geriux
Copy link
Member Author

geriux commented Jul 14, 2020

Hey @iamthomasbishop I managed to move the button 🎉

I'll work on getting some builds for you to test soon.

@iamthomasbishop
Copy link

@geriux That's great news! 🥳 Will test when a new build is available!

@geriux geriux removed the [Status] In Progress Tracking issues with work in progress label Jul 15, 2020
@geriux
Copy link
Member Author

geriux commented Jul 15, 2020

Hey @iamthomasbishop builds are ready =) Thanks!

@geriux
Copy link
Member Author

geriux commented Jul 15, 2020

Hey @mkevins 👋 this is ready for another review, thanks!

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 tested a few flows, and it's looking pretty good with the new button behavior. I left a few minor comments, but overall it's looking good. 👍

I'll defer fully testing (e.g. upload failure / retry / progress, etc.) until after the other design issue(s) are resolved. Btw, the gallery image has inset border in a separate layer, so it's not being dimmed by the overlay, in case that helps with ideas.

packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
packages/block-library/src/cover/edit.native.js Outdated Show resolved Hide resolved
@geriux
Copy link
Member Author

geriux commented Jul 17, 2020

Thank you for the feedback @iamthomasbishop !

  • Now that we have the Clear Media action in the block settings sheet, do you think it'd make sense to also add it as an action in the Action/BottomSheet that right now contains Edit and Replace?

We are adding Remove for the gallery, I think this would work for this case too. What do you think? I'm attaching a gif below.

  • Do you think it'd make sense to give that action/BottomSheet a title/description that is labeled Media options? I think we're getting this from the native side, so maybe we'd apply this across the board. We could get more specific with the label depending on its media type ( Image options, Video options, etc) but I think a more generic label like Media options would probably be fine if we want to keep it simple.

I think we should, I added it in the example below.

  • Do you think it'd make sense to show a button in place of the edit button when I've cleared the media (either from the settings sheet or this action/bottom sheet)? (example — note: in this example, I uploaded an image bg, added a gradient overlay, and then cleared the media. I know we'll likely add more media attachment options in the settings sheet, but on top of the cell here seemed like the most obvious place to reach in this scenario)

I think it'd make sense, I saw this in a mockup if I'm not mistaken, with all the Cover work with solid colors and now these changes with media editing we could easily add it.

@geriux Ah, I just noticed one more thing: the image selection outline (the blue inset border) is covered by the overlay background — is there any way to set the border to the outside of the image boundary or when selected, change the inset position of the overlay to account for this? Here's an example, with and without an overlay.

Nice catch! I'll fix it.

Here's a gif with all the changes, what do you think?

iOS Android

For Android, as you can see in the gif above the options have icons. Would you want to remove the icons as we did with the block options menu? e.g.

@iamthomasbishop
Copy link

We are adding Remove for the gallery, I think this would work for this case too. What do you think? I'm attaching a gif below.

@geriux I think the Remove action on the gallery block is doing something slightly different -- it's removing the image cell altogether. Whereas for the cover block, it's only explicitly removing the background image. So perhaps the label here should be Clear media, which would match our settings button?

I think we should, I added it in the example below.

Looks good!

I think it'd make sense, I saw this in a mockup if I'm not mistaken, with all the Cover work with solid colors and now these changes with media editing we could easily add it.

Looks like @antonis already added a ticket to work on that separately, which I hadn't even seen earlier -- great minds think alike? 😉

Here's a gif with all the changes, what do you think?

Looking great!

For Android, as you can see in the gif above the options have icons. Would you want to remove the icons as we did with the block options menu? e.g.

I think we can remove the icons, yes. This reminds me I need to write some clear guidelines for when/when not to use icons 😄

@geriux
Copy link
Member Author

geriux commented Jul 20, 2020

@geriux I think the Remove action on the gallery block is doing something slightly different -- it's removing the image cell altogether. Whereas for the cover block, it's only explicitly removing the background image. So perhaps the label here should be Clear media, which would match our settings button?

Sounds good! I'll add Clear media for this one and Remove for gallery.

I think we can remove the icons, yes. This reminds me I need to write some clear guidelines for when/when not to use icons 😄

Awesome, thanks!

@geriux
Copy link
Member Author

geriux commented Jul 20, 2020

Hey @iamthomasbishop I've just made new builds with the latest feedback, just in case you want to give another quick check.

@mkevins This is ready for another review 🙇 Thanks!

@geriux geriux requested a review from mkevins July 20, 2020 15:41
@mkevins
Copy link
Contributor

mkevins commented Jul 22, 2020

This is looking good. I tested lots of flows on Android, including media upload failure, retry, cancel, as well as the editing flows like editing, changing media, removing media, etc. And all of that is working as expected. Also, the inset border is not covered by the overlay 🎉.

The only potential blocker is with image preview: it seems that tapping the cover block without an image (but with a color) still tries to display the preview, even though there is no media. This results in a blank screen:

Also, since it automattically returns from the blank preview screen after a few seconds (with a toast), sometimes when you tap the back button, it leaves the editor instead. If you tap early enough, it just goes back to the editor, but if you tap just as the preview goes away on its own, the post is closed.

Also, one thing to note, (though it may not be directly related this PR), it seems after adding color, there is no way to change the background to media.. or maybe I just couldn't find the option. Is this known / expected?

@geriux
Copy link
Member Author

geriux commented Jul 22, 2020

This is looking good. I tested lots of flows on Android, including media upload failure, retry, cancel, as well as the editing flows like editing, changing media, removing media, etc. And all of that is working as expected. Also, the inset border is not covered by the overlay 🎉.

Awesome! Thanks for reviewing and testing those flows!

The only potential blocker is with image preview: it seems that tapping the cover block without an image (but with a color) still tries to display the preview, even though there is no media. This results in a blank screen:

Nice catch! I added this to check if there's an URL set. Didn't realize the the backgroundType is set to image by default.

Also, since it automattically returns from the blank preview screen after a few seconds (with a toast), sometimes when you tap the back button, it leaves the editor instead. If you tap early enough, it just goes back to the editor, but if you tap just as the preview goes away on its own, the post is closed.

I think this was due to passing an undefined URL to the preview so it should work as expected now.

Also, one thing to note, (though it may not be directly related this PR), it seems after adding color, there is no way to change the background to media.. or maybe I just couldn't find the option. Is this known / expected?

It is known and it's being handled in another PR. Thanks for bringing it up though =D

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.

Tested again after your latest changes, and it's fixed now. Nice work @geriux ! LGTM!

@geriux
Copy link
Member Author

geriux commented Jul 23, 2020

Tested again after your latest changes, and it's fixed now. Nice work @geriux ! LGTM!

Thank you so much for reviewing and testing this @mkevins!

Hey @iamthomasbishop 👋 Let me know if you want to review this again or if its good to merge. Thanks!

@iamthomasbishop
Copy link

@geriux Looking great to me! I noticed one tiny issue but it's already being resolved in another issue, so I think this one is good to ship!

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants