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

feat: paddinghorizontal props for legacy input #1002

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions example/src/Examples/TextInputExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type State = {
text: string,
name: string,
outlinedText: string,
standardInput: string,
};

class TextInputExample extends React.Component<Props, State> {
Expand All @@ -27,6 +28,7 @@ class TextInputExample extends React.Component<Props, State> {
text: '',
name: '',
outlinedText: '',
standardInput: '',
};

_isUsernameValid = () => /^[a-zA-Z]*$/.test(this.state.name);
Expand Down Expand Up @@ -75,6 +77,13 @@ class TextInputExample extends React.Component<Props, State> {
style={styles.inputContainerStyle}
label="Disabled outlined input"
/>
<TextInput
mode="flat"
paddingHorizontal={0}
style={styles.inputContainerStyle}
label="Standard input"
onChangeText={standardInput => this.setState({ standardInput })}
/>
<View style={styles.inputContainerStyle}>
<TextInput
label="Input with helper text"
Expand Down
8 changes: 7 additions & 1 deletion src/components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export type TextInputProps = {|
* The number of lines to show in the input (Android only).
*/
numberOfLines?: number,
/**
* The number of lines to show in the input (Android only).
*/
paddingHorizontal?: number,
/**
* Callback that is called when the text input is focused.
*/
Expand Down Expand Up @@ -152,6 +156,7 @@ class TextInput extends React.Component<TextInputProps, State> {
error: false,
multiline: false,
editable: true,
paddingHorizontal: 12,
render: (props: RenderProps) => <NativeTextInput {...props} />,
};

Expand Down Expand Up @@ -360,7 +365,7 @@ class TextInput extends React.Component<TextInputProps, State> {
}

render() {
const { mode, ...rest } = this.props;
const { mode, paddingHorizontal, ...rest } = this.props;

return mode === 'outlined' ? (
<TextInputOutlined
Expand All @@ -381,6 +386,7 @@ class TextInput extends React.Component<TextInputProps, State> {
innerRef={ref => {
this._root = ref;
}}
paddingHorizontal={paddingHorizontal}
onFocus={this._handleFocus}
onBlur={this._handleBlur}
onChangeText={this._handleChangeText}
Expand Down
5 changes: 5 additions & 0 deletions src/components/TextInput/TextInputFlat.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TextInputFlat extends React.Component<ChildTextInputProps, {}> {
error: false,
multiline: false,
editable: true,
paddingHorizontal: 12,
render: (props: RenderProps) => <NativeTextInput {...props} />,
};

Expand All @@ -47,6 +48,7 @@ class TextInputFlat extends React.Component<ChildTextInputProps, {}> {
onBlur,
onChangeText,
onLayoutAnimatedText,
paddingHorizontal,
...rest
} = this.props;

Expand Down Expand Up @@ -188,6 +190,7 @@ class TextInputFlat extends React.Component<ChildTextInputProps, {}> {
inputRange: [0, 1],
outputRange: [hasActiveOutline ? 1 : 0, 0],
}),
paddingHorizontal,
},
]}
numberOfLines={1}
Expand All @@ -202,6 +205,7 @@ class TextInputFlat extends React.Component<ChildTextInputProps, {}> {
{
color: placeholderColor,
opacity: hasActiveOutline ? parentState.labeled : 1,
paddingHorizontal,
},
]}
numberOfLines={1}
Expand Down Expand Up @@ -238,6 +242,7 @@ class TextInputFlat extends React.Component<ChildTextInputProps, {}> {
color: inputTextColor,
fontFamily,
textAlignVertical: multiline ? 'top' : 'center',
paddingHorizontal,
},
],
}: RenderProps)
Expand Down