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/upload captured photo #13450

Merged
merged 7 commits into from
Jan 25, 2019
11 changes: 11 additions & 0 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
subscribeMediaUpload,
onMediaLibraryPressed,
onUploadMediaPressed,
onCapturePhotoPressed,
} from 'react-native-gutenberg-bridge';

/**
Expand Down Expand Up @@ -122,10 +123,20 @@ export default class ImageEdit extends React.Component {
} );
};

const onCapturePhotoButtonPressed = () => {
onCapturePhotoPressed( ( mediaId, mediaUri ) => {
if ( mediaUri ) {
this.addMediaUploadListener( );
setAttributes( { url: mediaUri, id: mediaId } );
}
} );
};

return (
<MediaPlaceholder
onUploadMediaPressed={ onUploadMediaButtonPressed }
onMediaLibraryPressed={ onMediaLibraryButtonPressed }
onCapturePhotoPressed={ onCapturePhotoButtonPressed }
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ function MediaPlaceholder( props ) {
{ __( 'Upload a new image or select a file from your library.' ) }
</Text>
<View style={ styles.emptyStateButtonsContainer }>
<Button title={ __( 'Upload' ) } onPress={ props.onUploadMediaPressed } />
<Button title={ __( 'Media Library' ) } onPress={ props.onMediaLibraryPressed } />
<Button title={ __( 'Device Library' ) } onPress={ props.onUploadMediaPressed } />
<Button title={ __( 'Take photo' ) } onPress={ props.onCapturePhotoPressed } />
</View>
<Button title={ __( 'Media Library' ) } onPress={ props.onMediaLibraryPressed } />
</View>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

.emptyStateButtonsContainer {
margin-top: 15;
margin-bottom: 15;
flex-direction: row;
justify-content: space-evenly;
width: 100%;
Expand Down