Skip to content

Commit

Permalink
Unify container component within html text input
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Mar 25, 2022
1 parent 7fac2ec commit 5c6e21a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 102 deletions.

This file was deleted.

50 changes: 0 additions & 50 deletions packages/components/src/mobile/html-text-input/container.ios.js

This file was deleted.

74 changes: 45 additions & 29 deletions packages/components/src/mobile/html-text-input/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { TextInput } from 'react-native';
import { ScrollView, TextInput } from 'react-native';

/**
* WordPress dependencies
Expand All @@ -20,7 +20,7 @@ import {
/**
* Internal dependencies
*/
import HTMLInputContainer from './container';
import KeyboardAvoidingView from '../keyboard-avoiding-view';
import styles from './style.scss';

export class HTMLTextInput extends Component {
Expand Down Expand Up @@ -73,7 +73,13 @@ export class HTMLTextInput extends Component {
}

render() {
const { getStylesFromColorScheme, style } = this.props;
const {
editTitle,
getStylesFromColorScheme,
parentHeight,
style,
title,
} = this.props;
const titleStyle = [
styles.htmlViewTitle,
style?.text && { color: style.text },
Expand All @@ -90,32 +96,42 @@ export class HTMLTextInput extends Component {
...( style?.text && { color: style.text } ),
};
return (
<HTMLInputContainer parentHeight={ this.props.parentHeight }>
<TextInput
autoCorrect={ false }
accessibilityLabel="html-view-title"
textAlignVertical="center"
numberOfLines={ 1 }
style={ titleStyle }
value={ this.props.title }
placeholder={ __( 'Add title' ) }
placeholderTextColor={ placeholderStyle.color }
onChangeText={ this.props.editTitle }
/>
<TextInput
autoCorrect={ false }
accessibilityLabel="html-view-content"
textAlignVertical="top"
multiline
style={ htmlStyle }
value={ this.state.value }
onChangeText={ this.edit }
onBlur={ this.stopEditing }
placeholder={ __( 'Start writing…' ) }
placeholderTextColor={ placeholderStyle.color }
scrollEnabled={ HTMLInputContainer.scrollEnabled }
/>
</HTMLInputContainer>
<KeyboardAvoidingView
style={ styles.keyboardAvoidingView }
parentHeight={ parentHeight }
>
<ScrollView style={ styles.scrollView }>
<TextInput
autoCorrect={ false }
accessibilityLabel="html-view-title"
textAlignVertical="center"
numberOfLines={ 1 }
style={ titleStyle }
value={ title }
placeholder={ __( 'Add title' ) }
placeholderTextColor={ placeholderStyle.color }
onChangeText={ editTitle }
/>
<TextInput
ref={ this.contentTextInputRef }
autoCorrect={ false }
accessibilityLabel="html-view-content"
textAlignVertical="top"
multiline
style={ htmlStyle }
value={ this.state.value }
onChangeText={ this.edit }
onBlur={ this.stopEditing }
placeholder={ __( 'Start writing…' ) }
placeholderTextColor={ placeholderStyle.color }
scrollEnabled={ false }
// [Only iOS] This prop prevents the text input from
// automatically getting focused after scrolling
// content.
rejectResponderTermination={ false }
/>
</ScrollView>
</KeyboardAvoidingView>
);
}
}
Expand Down

0 comments on commit 5c6e21a

Please sign in to comment.