Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 17 additions & 3 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import RNReactNativeGutenbergBridge from 'react-native-gutenberg-bridge';
/**
* Internal dependencies
*/
import { MediaPlaceholder, RichText } from '@wordpress/editor';
import { MediaPlaceholder, RichText, BlockControls } from '@wordpress/editor';
import { Toolbar, IconButton } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

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

const onMediaLibraryPress = () => {
// 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 ) => {
if ( mediaUrl ) {
setAttributes( { url: mediaUrl } );
Expand All @@ -38,8 +38,22 @@ export default function ImageEdit( props ) {
);
}

const toolbarEditButton = (
<Toolbar>
<IconButton
className="components-toolbar__control"
label={ __( 'Edit image' ) }
icon="edit"
onClick={ onMediaLibraryPress }
/>
</Toolbar>
);

return (
<View style={ { flex: 1 } }>
<BlockControls>
{ toolbarEditButton }
</BlockControls>
<Image
style={ { width: '100%', height: 200 } }
resizeMethod="scale"
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './primitives';
export { default as Dashicon } from './dashicon';
export { default as Toolbar } from './toolbar';
export { default as withSpokenMessages } from './higher-order/with-spoken-messages';
export { default as IconButton } from './icon-button';
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill';

// Higher-Order Components
Expand Down