diff --git a/index.js b/index.js index a81672f..0abba94 100644 --- a/index.js +++ b/index.js @@ -86,35 +86,37 @@ class FloatLabelTextField extends Component { } } - leftPadding() { + leftPadding = () => { return { width: this.props.leftPadding || 0 } } - withBorder() { + withBorder = () => { if (!this.props.noBorder) { return styles.withBorder; } } render() { + const inputStyle = (this.props.inputStyle) ? this.props.inputStyle : null; + const placeholderFocusStyle = (this.props.placeholderFocusStyle) ? this.props.placeholderFocusStyle : null; return ( - {this.placeholderValue()} + {this.placeholderValue()} this.setFocus()} - onBlur={() => this.unsetFocus()} + onFocus={this.setFocus} + onBlur={this.unsetFocus} onChangeText={(value) => this.setText(value)} /> @@ -124,27 +126,27 @@ class FloatLabelTextField extends Component { ); } - inputRef() { + inputRef = () => { return this.refs.input; } - focus() { + focus = () => { this.inputRef().focus(); } - blur() { + blur = () => { this.inputRef().blur(); } - isFocused() { + isFocused = () => { return this.inputRef().isFocused(); } - clear() { + clear = () => { this.inputRef().clear(); } - setFocus() { + setFocus = () => { this.setState({ focused: true }); @@ -153,7 +155,7 @@ class FloatLabelTextField extends Component { } catch (_error) { } } - unsetFocus() { + unsetFocus = () => { this.setState({ focused: false }); @@ -162,19 +164,19 @@ class FloatLabelTextField extends Component { } catch (_error) { } } - labelStyle() { + labelStyle = () => { if (this.state.focused) { return styles.focused; } } - placeholderValue() { + placeholderValue = () => { if (this.state.text) { return this.props.placeholder; } } - setText(value) { + setText = (value) => { this.setState({ text: value }); @@ -188,7 +190,7 @@ const styles = StyleSheet.create({ container: { flex: 1, height: 45, - backgroundColor: 'white', + backgroundColor: 'transparent', justifyContent: 'center' }, viewContainer: {