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

WIP: Feat/more flexible text input #316

Closed
wants to merge 3 commits into from
Closed
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
22 changes: 20 additions & 2 deletions src/components/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Props = {
* Underline color of the input.
*/
underlineColor?: string,
/**
* Underline style of the input.
*/
underlineStyle?: any,
/**
* Whether the input can have multiple lines.
*/
Expand All @@ -55,6 +59,10 @@ type Props = {
*/
value?: string,
style?: any,
/**
* Style of native text input.
*/
textInputStyle?: any,
/**
* @optional
*/
Expand Down Expand Up @@ -208,7 +216,9 @@ class TextInput extends React.Component<Props, State> {
disabled,
label,
underlineColor,
underlineStyle,
style,
textInputStyle,
theme,
...rest
} = this.props;
Expand Down Expand Up @@ -265,6 +275,8 @@ class TextInput extends React.Component<Props, State> {
}),
};

const placeholder = label ? this.state.placeholder : rest.placeholder; // display placeholder if no label wasn't passed

return (
<View style={style}>
<AnimatedText
Expand All @@ -276,7 +288,7 @@ class TextInput extends React.Component<Props, State> {
<NativeTextInput
{...rest}
value={value}
placeholder={this.state.placeholder}
placeholder={placeholder}
placeholderTextColor={colors.placeholder}
editable={!disabled}
ref={this._setRef}
Expand All @@ -291,14 +303,20 @@ class TextInput extends React.Component<Props, State> {
color: inputTextColor,
fontFamily,
},
textInputStyle,
]}
/>
<View pointerEvents="none" style={styles.bottomLineContainer}>
<View
style={[styles.bottomLine, { backgroundColor: inactiveColor }]}
/>
<Animated.View
style={[styles.bottomLine, styles.focusLine, bottomLineStyle]}
style={[
styles.bottomLine,
styles.focusLine,
bottomLineStyle,
underlineStyle,
]}
/>
</View>
</View>
Expand Down