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: Trigger media library picker #11511

Merged
merged 4 commits into from Nov 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/block-library/src/image/edit.native.js
Expand Up @@ -2,11 +2,12 @@
* External dependencies
*/
import { View, Image, TextInput } from 'react-native';
import RNReactNativeGutenbergBridge from 'react-native-gutenberg-bridge';

/**
* Internal dependencies
*/
import { MediaPlaceholder } from '@wordpress/editor';
import { MediaPlaceholder, RichText } from '@wordpress/editor';

export default function ImageEdit( props ) {
const { attributes, isSelected, setAttributes } = props;
Expand All @@ -19,9 +20,9 @@ export default function ImageEdit( props ) {
};

const onMediaLibraryPress = () => {
// This method should present an image picker from
// the WordPress media library.
//TODO: Implement media library method.
// Call onMediaLibraryPress from the Native<->RN bridge. It should trigger an image picker from
// the WordPress media library and call the provided callback to set the image URL.
RNReactNativeGutenbergBridge.onMediaLibraryPress( ( mediaUrl ) => setAttributes( { url: mediaUrl } ) );
};

if ( ! url ) {
Expand All @@ -40,7 +41,7 @@ export default function ImageEdit( props ) {
resizeMethod="scale"
source={ { uri: url } }
/>
{ ( caption.length > 0 || isSelected ) && (
{ ( ! RichText.isEmpty( caption ) > 0 || isSelected ) && (
<View style={ { padding: 12, flex: 1 } }>
<TextInput
style={ { textAlign: 'center' } }
Expand Down