diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index 985c333e4be40..daad9b0df5dde 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -44,6 +44,7 @@ export default class ImageEdit extends React.Component { this.removeMediaUploadListener = this.removeMediaUploadListener.bind( this ); this.finishMediaUploadWithSuccess = this.finishMediaUploadWithSuccess.bind( this ); this.finishMediaUploadWithFailure = this.finishMediaUploadWithFailure.bind( this ); + this.updateAlt = this.updateAlt.bind( this ); this.onImagePressed = this.onImagePressed.bind( this ); } @@ -128,9 +129,13 @@ export default class ImageEdit extends React.Component { } } + updateAlt( newAlt ) { + this.props.setAttributes( { alt: newAlt } ); + } + render() { const { attributes, isSelected, setAttributes } = this.props; - const { url, caption, height, width } = attributes; + const { url, caption, height, width, alt } = attributes; const onMediaLibraryButtonPressed = () => { requestMediaPickFromMediaLibrary( ( mediaId, mediaUrl ) => { @@ -191,19 +196,13 @@ export default class ImageEdit extends React.Component { isVisible={ this.state.showSettings } onClose={ onImageSettingsClose } hideHeader - rightButton={ - - } > {} } + value={ alt || '' } + valuePlaceholder={ __( 'None' ) } + onChangeValue={ this.updateAlt } /> + { label && { label } } + { children } + { help && { help } } + + ); +} diff --git a/packages/components/src/index.native.js b/packages/components/src/index.native.js index 65dd41e713fa3..b66663af05285 100644 --- a/packages/components/src/index.native.js +++ b/packages/components/src/index.native.js @@ -7,6 +7,8 @@ export { default as withSpokenMessages } from './higher-order/with-spoken-messag export { default as IconButton } from './icon-button'; export { default as Spinner } from './spinner'; export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill'; +export { default as BaseControl } from './base-control'; +export { default as TextareaControl } from './textarea-control'; // Higher-Order Components export { default as withFilters } from './higher-order/with-filters'; diff --git a/packages/components/src/textarea-control/index.native.js b/packages/components/src/textarea-control/index.native.js new file mode 100644 index 0000000000000..059eea86728d7 --- /dev/null +++ b/packages/components/src/textarea-control/index.native.js @@ -0,0 +1,26 @@ +/** + * External dependencies + */ +import { TextInput } from 'react-native'; + +/** + * Internal dependencies + */ +import BaseControl from '../base-control'; + +function TextareaControl( { label, value, help, onChange, rows = 4 } ) { + return ( + + 1 } + textAlignVertical="top" + /> + + ); +} + +export default TextareaControl; diff --git a/packages/editor/src/components/mobile/bottom-sheet/cell.native.js b/packages/editor/src/components/mobile/bottom-sheet/cell.native.js index 0ab9a87e61027..6dc8ff4b26ef2 100644 --- a/packages/editor/src/components/mobile/bottom-sheet/cell.native.js +++ b/packages/editor/src/components/mobile/bottom-sheet/cell.native.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { TouchableOpacity, Text, View } from 'react-native'; +import { TouchableOpacity, Text, View, TextInput } from 'react-native'; /** * WordPress dependencies @@ -18,16 +18,29 @@ export default function Cell( props ) { onPress, label, value, + valuePlaceholder = '', drawSeparator = true, icon, labelStyle = {}, valueStyle = {}, + onChangeValue, } = props; - const defaultLabelStyle = value ? styles.cellLabel : styles.cellLabelCentered; + const showValue = value !== undefined; + const isValueEditable = onChangeValue !== undefined; + const defaultLabelStyle = showValue ? styles.cellLabel : styles.cellLabelCentered; + let valueTextInput; + + const onCellPress = () => { + if ( isValueEditable ) { + valueTextInput.focus(); + } else { + onPress(); + } + }; return ( - + { icon && ( @@ -36,10 +49,20 @@ export default function Cell( props ) { ) } - { label } + + { label } + - { value && ( - { value } + { showValue && ( + valueTextInput = c } + numberOfLines={ 1 } + style={ { ...styles.cellValue, ...valueStyle } } + value={ value } + placeholder={ valuePlaceholder } + onChangeText={ onChangeValue } + editable={ isValueEditable } + /> ) } { drawSeparator && ( diff --git a/packages/editor/src/components/mobile/bottom-sheet/index.native.js b/packages/editor/src/components/mobile/bottom-sheet/index.native.js index 6926a33d6cd04..e89bc50d44e28 100644 --- a/packages/editor/src/components/mobile/bottom-sheet/index.native.js +++ b/packages/editor/src/components/mobile/bottom-sheet/index.native.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { Text, View } from 'react-native'; +import { Text, View, KeyboardAvoidingView, Platform } from 'react-native'; import Modal from 'react-native-modal'; import SafeArea from 'react-native-safe-area'; @@ -58,7 +58,10 @@ class BottomSheet extends Component { onSwipe={ this.props.onClose } swipeDirection="down" > - + { hideHeader || ( @@ -78,12 +81,12 @@ class BottomSheet extends Component { ) } - { this.props.children } - + + ); } } diff --git a/packages/editor/src/components/mobile/bottom-sheet/styles.scss b/packages/editor/src/components/mobile/bottom-sheet/styles.scss index 120c2fcdef860..f02aa77fe4498 100644 --- a/packages/editor/src/components/mobile/bottom-sheet/styles.scss +++ b/packages/editor/src/components/mobile/bottom-sheet/styles.scss @@ -65,8 +65,8 @@ flex-direction: row; min-height: 50; justify-content: space-between; - padding-left: 12; - padding-right: 12; + margin-left: 12; + margin-right: 12; align-items: center; } @@ -82,6 +82,7 @@ .cellLabel { font-size: 18px; color: #000; + margin-right: 12px; } .cellLabelCentered { @@ -94,4 +95,5 @@ .cellValue { font-size: 18px; color: $dark-gray-400; + text-align: right; }