From 6f9be7227a5d9ca5393e8afedfc4a84f8340bb8b Mon Sep 17 00:00:00 2001 From: etoledom Date: Wed, 20 Feb 2019 09:33:57 +0100 Subject: [PATCH 1/4] Mobile: Replaced Links UI with bottom-sheet component --- .../mobile/bottom-sheet/cell.native.js | 13 ++- .../mobile/bottom-sheet/styles.native.scss | 1 + .../format-library/src/link/index.native.js | 20 ++-- .../format-library/src/link/modal.native.js | 98 +++++++++++-------- .../format-library/src/link/modal.native.scss | 4 + 5 files changed, 83 insertions(+), 53 deletions(-) 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 6ac26d2d00ff8b..9acc94bbfb3bbd 100644 --- a/packages/editor/src/components/mobile/bottom-sheet/cell.native.js +++ b/packages/editor/src/components/mobile/bottom-sheet/cell.native.js @@ -16,10 +16,10 @@ import styles from './styles.scss'; import platformStyles from './cellStyles.scss'; export default class Cell extends Component { - constructor() { + constructor( props ) { super( ...arguments ); this.state = { - isEditingValue: false, + isEditingValue: props.autoFocus || false, }; } @@ -53,7 +53,7 @@ export default class Cell extends Component { const onCellPress = () => { if ( isValueEditable ) { - this.setState( { isEditingValue: true } ); + startEditing(); } else if ( onPress !== undefined ) { onPress(); } @@ -63,6 +63,12 @@ export default class Cell extends Component { this.setState( { isEditingValue: false } ); }; + const startEditing = () => { + if ( this.state.isEditingValue === false ) { + this.setState( { isEditingValue: true } ); + } + }; + const separatorStyle = () => { const leftMarginStyle = { ...styles.cellSeparator, ...platformStyles.separatorMarginLeft }; switch ( separatorType ) { @@ -97,6 +103,7 @@ export default class Cell extends Component { onChangeText={ onChangeValue } editable={ isValueEditable } pointerEvents={ this.state.isEditingValue ? 'auto' : 'none' } + onFocus={ startEditing } onBlur={ finishEditing } { ...valueProps } /> diff --git a/packages/editor/src/components/mobile/bottom-sheet/styles.native.scss b/packages/editor/src/components/mobile/bottom-sheet/styles.native.scss index 198d526092a851..53764ee4fe38f1 100644 --- a/packages/editor/src/components/mobile/bottom-sheet/styles.native.scss +++ b/packages/editor/src/components/mobile/bottom-sheet/styles.native.scss @@ -31,6 +31,7 @@ border-top-left-radius: 8px; width: 100%; max-width: 512; + padding-bottom: 0; } .content { diff --git a/packages/format-library/src/link/index.native.js b/packages/format-library/src/link/index.native.js index 4a2def1614323d..4ea3ee0e309342 100644 --- a/packages/format-library/src/link/index.native.js +++ b/packages/format-library/src/link/index.native.js @@ -107,17 +107,15 @@ export const link = { return ( - { this.state.addingLink && - - } + - - - - - - { __( 'Link Settings' ) } - - - - - + + + + + + + {/* { __( 'URL' ) } @@ -143,8 +164,8 @@ class ModalLinkUI extends Component { onChange={ this.onChangeInputValue } /> - - + */} + {/* { __( 'Link Text' ) } @@ -154,8 +175,8 @@ class ModalLinkUI extends Component { onChangeText={ this.onChangeText } /> - - + */} + {/* { __( 'Open in a new window' ) } @@ -165,9 +186,8 @@ class ModalLinkUI extends Component { onValueChange={ this.onChangeOpensInNewWindow } /> - - - + */} + ); } } diff --git a/packages/format-library/src/link/modal.native.scss b/packages/format-library/src/link/modal.native.scss index 72f6a647b23966..10627ee8cc8341 100644 --- a/packages/format-library/src/link/modal.native.scss +++ b/packages/format-library/src/link/modal.native.scss @@ -78,3 +78,7 @@ padding: 5px; } +.clearLinkButton { + color: $alert-red; +} + From 5b1dae2c6d2138db07d0c6bfcaf77d2599a47af3 Mon Sep 17 00:00:00 2001 From: etoledom Date: Wed, 20 Feb 2019 09:59:26 +0100 Subject: [PATCH 2/4] Mobile links UI: Removed commented code. --- .../format-library/src/link/modal.native.js | 99 +++++++------------ 1 file changed, 33 insertions(+), 66 deletions(-) diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index 712c2013a1b17d..3724eb132afb80 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -120,73 +120,40 @@ class ModalLinkUI extends Component { onClose={ this.submitLink } hideHeader > - + + + - - - - - - {/* - - { __( 'URL' ) } - - - - */} - {/* - - { __( 'Link Text' ) } - - - - */} - {/* - - { __( 'Open in a new window' ) } - - - - - */} + + ); } From 822d87c7e101cadb6a7f73e053982e5fe4626839 Mon Sep 17 00:00:00 2001 From: etoledom Date: Wed, 20 Feb 2019 10:16:26 +0100 Subject: [PATCH 3/4] Mobile: Fix lint issues --- .../format-library/src/link/button.native.js | 24 ------ .../format-library/src/link/modal.native.js | 36 ++++----- .../format-library/src/link/modal.native.scss | 81 ------------------- 3 files changed, 18 insertions(+), 123 deletions(-) delete mode 100644 packages/format-library/src/link/button.native.js diff --git a/packages/format-library/src/link/button.native.js b/packages/format-library/src/link/button.native.js deleted file mode 100644 index fa8fd004c5a37b..00000000000000 --- a/packages/format-library/src/link/button.native.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * External dependencies - */ -import { TouchableOpacity, View } from 'react-native'; - -export default function Button( props ) { - const { - children, - onClick, - disabled, - } = props; - - return ( - - - { children } - - - ); -} diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index 3724eb132afb80..56b3468a232c38 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -2,15 +2,14 @@ * External dependencies */ import React from 'react'; -import { Switch, Text, TextInput, View } from 'react-native'; -import Modal from 'react-native-modal'; +import { Switch } from 'react-native'; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import { URLInput, BottomSheet } from '@wordpress/editor'; +import { BottomSheet } from '@wordpress/editor'; import { prependHTTP } from '@wordpress/url'; import { withSpokenMessages, @@ -28,12 +27,11 @@ import { * Internal dependencies */ import { createLinkFormat, isValidHref } from './utils'; -import Button from './button'; import styles from './modal.scss'; class ModalLinkUI extends Component { - constructor( props ) { + constructor() { super( ...arguments ); this.submitLink = this.submitLink.bind( this ); @@ -54,11 +52,11 @@ class ModalLinkUI extends Component { return; } - this.setState({ + this.setState( { inputValue: this.props.activeAttributes.url || '', text: getTextContent( slice( this.props.value ) ), opensInNewWindow: false, - }) + } ); } onChangeInputValue( inputValue ) { @@ -120,17 +118,19 @@ class ModalLinkUI extends Component { onClose={ this.submitLink } hideHeader > - + { /* eslint-disable jsx-a11y/no-autofocus */ + + /* eslint-enable jsx-a11y/no-autofocus */ } Date: Wed, 20 Feb 2019 14:11:03 +0100 Subject: [PATCH 4/4] Mobile Links UI: Remove autofocus on Android. This hides an issue where the modal sometimes will be under the keyboard on Android. --- packages/format-library/src/link/modal.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index 56b3468a232c38..0b0accadc9ea58 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -2,7 +2,7 @@ * External dependencies */ import React from 'react'; -import { Switch } from 'react-native'; +import { Switch, Platform } from 'react-native'; /** * WordPress dependencies @@ -128,7 +128,7 @@ class ModalLinkUI extends Component { autoCorrect={ false } textContentType="URL" onChangeValue={ this.onChangeInputValue } - autoFocus + autoFocus={ Platform.OS === 'ios' } /> /* eslint-enable jsx-a11y/no-autofocus */ }