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

[RNMobile] Media & Text - Media picker buttons functionality #17537

Merged
merged 14 commits into from
Oct 10, 2019

Conversation

geriux
Copy link
Member

@geriux geriux commented Sep 23, 2019

Can be merged after #17392

gutenberg-mobile PR wordpress-mobile/gutenberg-mobile#1378

Description

This PR adds the missing functionality for the Media & Text block wordpress-mobile/gutenberg-mobile#1313

On Android It will only support images until we can filter by more than one type at a time (images & videos) in the media picker.

Now the functionality it's the same as the image and video blocks.

How has this been tested?

  • Open the WordPress app and start a new post.
  • Insert a new Media & Text block.
  • Add an image from the photo library/camera.
  • Expect the progress bar to show up while the file is being uploaded. While it's doing that you can cancel the upload.
  • Once an image is uploaded you can do a long press to open the media options to change the file.
  • If the connection fails, a retry option will be available.
  • Test the image/video can be also selected from the WordPress media library.

Screenshots

iOS


Android


Types of changes

New feature (non-breaking change which adds functionality)

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.

const { mediaUrl, isSelected } = this.props;
const { isUploadInProgress } = this.state;
const { isUploadFailed, retryMessage } = params;
const videoHeight = ( Dimensions.get( 'window' ).width / 2 ) / VIDEO_ASPECT_RATIO;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can set the aspectRatio style prop directly and avoid the calculation. Otherwise, I think using the window width would be problematic because the ratio should apply to the container width, not the full window, but I haven't been able to test this because of the other issue I commented

Copy link
Contributor

Choose a reason for hiding this comment

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

Confirmed that this gets the wrong aspect ratio when uploading a video on iPad:

IMG_D8955C916037-1

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice! I'll check aspectRatio and also make sure it looks great on tablets as well

const ALLOWED_MEDIA_TYPES = [ MEDIA_TYPE_IMAGE, ...( Platform.OS === 'ios' ? [ MEDIA_TYPE_VIDEO ] : [] ) ];

// Default Video ratio 16:9
const VIDEO_ASPECT_RATIO = 16 / 9;
Copy link
Contributor

@koke koke Sep 25, 2019

Choose a reason for hiding this comment

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

I don't love that we are hardcoding this, but I see we were already doing it in the video block. Can we move that logic to the newly extracted VideoPlayer component so we can improve it in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes! Will do!

@gziolo gziolo added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Sep 26, 2019
@geriux
Copy link
Member Author

geriux commented Sep 26, 2019

Hey @koke this is ready to be reviewed again, Travis failed due to a linting issue that will be fixed in #17598

@geriux geriux requested a review from koke September 26, 2019 08:45
@koke
Copy link
Contributor

koke commented Sep 26, 2019

I think this is looking good. I had something else in mind for the aspect ratio changes, but now I realize that the video component probably isn't as smart as images and we want a fixed ratio there. I'd probably like to have in the future an API for VideoPlayer and the placeholder component that does the right thing by itself, but I think this is good for now.

Let's try to wrap up #17392 first and merge that one and the lint fixes from master before I do the final testing round. 👍

@geriux
Copy link
Member Author

geriux commented Sep 27, 2019

Updated! Now all checks are green 🎉 ready to be reviewed again =)

@koke
Copy link
Contributor

koke commented Sep 30, 2019

I noticed one thing that we don't have to fix in this PR but it's worth discussing with @iamthomasbishop. I wanted to change the media once I had uploaded it. When the block is selected, the toolbar is visible, but since there is no focus on any text component, the toolbar is at the bottom:

Simulator Screen Shot - iPhone 11 - 2019-09-30 at 11 55 04

I stared at the screen and tapped on too many things for a minute trying to edit the image/video, but I just couldn't see the toolbar at the bottom.

@iamthomasbishop
Copy link

@koke I think the toolbar positioning is expected, but I wouldn't expect the pencil icon to be visible until I have selected the video block within the group. I know the web currently follows the above pattern, but it's always confusing to me. Shouldn't that button only be shown when I've selected the video block?

@koke
Copy link
Contributor

koke commented Oct 1, 2019

@iamthomasbishop the left part of media & text doesn't use nested blocks, it's just either one image or one video, so it's part of the parent (media-text) block. I understand that was the expected design, but I still found myself confused for a bit trying to find how to replace the image/video there

@iamthomasbishop
Copy link

the left part of media & text doesn't use nested blocks, it's just either one image or one video, so it's part of the parent (media-text) block

Yea sorry, I thought from the example above that the parent (media-text) was selected. The replacing mechanism is definitely confusing, I've always disliked that icon. I think the web has recently updated that replace image icon (at least on the image block) to be more obvious, can we match that? Example:

Screen Shot 2019-10-01 at 1 49 21 PM

The other thing that I mentioned still applies – why do we even show the image/media replace button while the parent is selected? That's confusing to me.

@koke
Copy link
Contributor

koke commented Oct 4, 2019

I'll merge #17682 in a test branch to see how it look

I tried that myself when testing and it went full width but still had the same issue.

@geriux
Copy link
Member Author

geriux commented Oct 5, 2019

@koke I've just updated this PR with the fix for the issue you mentioned, I also tested this fix with your PR and it works well too 🎉

@koke
Copy link
Contributor

koke commented Oct 7, 2019

I feel like I had reported this before, but I can't find my comment anywhere so maybe I didn't? 😱

  1. Add a media-text block
  2. Tap Add image or video
  3. Choose any method
  4. Tap cancel without selecting an image
  5. Red screen: Cannot read property 'id' of undefined

This is on iOS. I tested on Android and it seems fine.

@geriux
Copy link
Member Author

geriux commented Oct 7, 2019

I feel like I had reported this before, but I can't find my comment anywhere so maybe I didn't? 😱

  1. Add a media-text block
  2. Tap Add image or video
  3. Choose any method
  4. Tap cancel without selecting an image
  5. Red screen: Cannot read property 'id' of undefined

Oh wow! I haven't seen that D: I'll check it out today. Did the other issue get fixed with the latest changes?

@koke
Copy link
Contributor

koke commented Oct 7, 2019

I think this is good to go once the red screen issue is solved. 🎉

Copy link
Contributor

@koke koke 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 ready 🎉
To avoid further issues, I'll wait until wordpress-mobile/gutenberg-mobile#1410 is merged to start merging all the related PRs

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've tested this on Android with the additional changes here: wordpress-mobile/gutenberg-mobile#1412 and here: wordpress-mobile/gutenberg-mobile#1400. This is looking good. Nice work @geriux ! 🎉

@koke koke merged commit a5be006 into WordPress:master Oct 10, 2019
@koke koke deleted the feature/media-text-upload-progress branch October 10, 2019 10:11
@youknowriad youknowriad added this to the Gutenberg 6.7 milestone Oct 14, 2019
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.

9 participants