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] - Media & Text: Allow media to be selected and render focal point #22788

Merged
merged 28 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6277b44
RNMobile - Image and Media & Text standarization - Component refactor
May 29, 2020
4a267d6
RNMobile - Media & Text: Add support for crop image to fill setting
Jun 1, 2020
7487b1a
RNMobile - Image Component - Add missing upload styles
Jun 1, 2020
30a60ef
Merge branch 'master' into rnmobile/media-text-image-refactor
Jun 1, 2020
d938b13
RNMobile - Media Upload Progress - Update tests: adding new mock
Jun 2, 2020
d7bc2a3
RNMobile - Media & Text: Dark mode styles for placeholders
Jun 2, 2020
8c5ff0b
RNMobile - Image With Focal point - Export functions
Jun 2, 2020
cd0a2dc
RNMobile - Media & Text - Focal point fixes
Jun 2, 2020
3f4ea08
RNMobile - Image block - Move caption out of the image onPress
Jun 3, 2020
660dd55
RNMobile - Image component - onLayout sizing improvements
Jun 3, 2020
0f9cfe5
RNMobile - Image component - Selected border height style
Jun 3, 2020
ba739fb
RNMobile - Image component - Fix placeholder
Jun 3, 2020
504e76c
RNMobile - Media&Text / Image block - Image sizing
Jun 4, 2020
04fb096
RNMobile - Media&Text - Video alignment and dark mode styles
Jun 5, 2020
98ba626
RNMobile - Media&Text - Android resizeMethod and style fixes
Jun 5, 2020
13659cd
RNMobile - Media&Text - Fix video flag
Jun 5, 2020
9e61ccf
RNMobile - Media & Text improvements and Image block
Jun 16, 2020
caec19c
Merge branch 'master' into rnmobile/media-text-image-refactor
Jun 16, 2020
e23d5f3
RNMobile - Image block: Renaming of icon, pass true value props directly
Jun 18, 2020
3449d65
Merge branch 'master' into rnmobile/media-text-image-refactor
Jun 18, 2020
db4c557
Mobile - Improve image focal point to fix crop image issue in Media Text
Jun 23, 2020
2745a98
Mobile - Media & Text remove extra padding
Jun 23, 2020
da0d387
Merge branch 'master' into rnmobile/media-text-image-refactor
Jun 24, 2020
24e1a9e
Merge branch 'master' into rnmobile/media-text-image-refactor
Jun 30, 2020
5fe1f46
Merge branch 'master' into rnmobile/media-text-image-refactor
Jul 7, 2020
0951ae2
Merge branch 'master' into rnmobile/media-text-image-refactor
Jul 7, 2020
0d222f4
Mobile - React native editor - Release notes update
Jul 8, 2020
fb24477
Merge branch 'master' into rnmobile/media-text-image-refactor
Jul 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export {
MEDIA_TYPE_VIDEO,
} from './media-upload';
export { default as MediaUploadProgress } from './media-upload-progress';
export { default as MediaEdit } from './media-edit';
export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
export { default as BlockCaption } from './block-caption';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ import {
MediaUploadProgress,
} from '@wordpress/block-editor';

function MediaProgress( { height, width, url, id } ) {
function MediaProgress( { url, id } ) {
return (
<MediaUploadProgress
height={ height }
width={ width }
coverUrl={ url }
mediaId={ id }
renderContent={ ( { isUploadFailed, finalWidth, finalHeight, retryMessage } ) => {
renderContent={ ( { isUploadFailed, retryMessage } ) => {
return (
<ImageBackground
style={ { width: finalWidth, height: finalHeight } }
resizeMethod="scale"
source={ { uri: url } }
>
Expand All @@ -50,14 +46,6 @@ A media ID that identifies the current upload.
- Required: Yes
- Platform: Mobile

### coverUrl

By passing an image url, it'll calculate the right size depending on the container of the component maintaining its aspect ratio, it'll pass these values through `renderContent`.

- Type: `String`
- Required: No
- Platform: Mobile

### renderContent

Content to be rendered along with the progress bar, usually the thumbnail of the media being uploaded.
Expand All @@ -68,31 +56,8 @@ Content to be rendered along with the progress bar, usually the thumbnail of the

It passes an object containing the following properties:

**With** `coverUrl` as a parameter:

`{ isUploadInProgress, isUploadFailed, finalWidth, finalHeight, imageWidthWithinContainer, retryMessage }`

**Without** `coverUrl` as a parameter:

`{ isUploadInProgress, isUploadFailed, retryMessage }`


### width

Forces the final width to be returned in `finalWidth`

- Type: `Number`
- Required: No
- Platform: Mobile

### height

Forces the final height to be returned in `finalHeight`

- Type: `Number`
- Required: No
- Platform: Mobile

### onUpdateMediaProgress

Callback called when the progress of the upload is updated.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import ImageSize from './image-size';
import styles from './styles.scss';

export const MEDIA_UPLOAD_STATE_UPLOADING = 1;
Expand Down Expand Up @@ -117,12 +116,7 @@ export class MediaUploadProgress extends React.Component {
}

render() {
const {
coverUrl,
width,
height,
renderContent = () => {},
} = this.props;
const { renderContent = () => {} } = this.props;
geriux marked this conversation as resolved.
Show resolved Hide resolved
const { isUploadInProgress, isUploadFailed } = this.state;
const showSpinner = this.state.isUploadInProgress;
const progress = this.state.progress * 100;
Expand All @@ -138,46 +132,11 @@ export class MediaUploadProgress extends React.Component {
<Spinner progress={ progress } />
</View>
) }
{ coverUrl && (
<ImageSize src={ coverUrl }>
{ ( sizes ) => {
const {
imageWidthWithinContainer,
imageHeightWithinContainer,
} = sizes;

let finalHeight = imageHeightWithinContainer;
if (
height > 0 &&
height < imageHeightWithinContainer
) {
finalHeight = height;
}

let finalWidth = imageWidthWithinContainer;
if (
width > 0 &&
width < imageWidthWithinContainer
) {
finalWidth = width;
}
return renderContent( {
isUploadInProgress,
isUploadFailed,
finalWidth,
finalHeight,
imageWidthWithinContainer,
retryMessage,
} );
} }
</ImageSize>
) }
{ ! coverUrl &&
renderContent( {
isUploadInProgress,
isUploadFailed,
retryMessage,
} ) }
{ renderContent( {
isUploadInProgress,
isUploadFailed,
retryMessage,
} ) }
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ jest.mock( 'react-native-gutenberg-bridge', () => {
const subscribeMediaUpload = ( callback ) => {
this.uploadCallBack = callback;
};
const mediaSources = {
deviceCamera: 'DEVICE_CAMERA',
deviceLibrary: 'DEVICE_MEDIA_LIBRARY',
siteMediaLibrary: 'SITE_MEDIA_LIBRARY',
};
return {
subscribeMediaUpload,
sendMediaUpload: callUploadCallback,
mediaSources,
};
} );

Expand Down
Loading