From 5c4c7e9af57122438ed899660b826be0df10f62e Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Fri, 13 Apr 2018 19:06:15 +0800 Subject: [PATCH 1/4] Update index.js --- index.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index a81672f..a2088ec 100644 --- a/index.js +++ b/index.js @@ -86,11 +86,11 @@ class FloatLabelTextField extends Component { } } - leftPadding() { + leftPadding = () => { return { width: this.props.leftPadding || 0 } } - withBorder() { + withBorder = () => { if (!this.props.noBorder) { return styles.withBorder; } @@ -124,27 +124,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 +153,7 @@ class FloatLabelTextField extends Component { } catch (_error) { } } - unsetFocus() { + unsetFocus = () => { this.setState({ focused: false }); @@ -162,19 +162,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 +188,7 @@ const styles = StyleSheet.create({ container: { flex: 1, height: 45, - backgroundColor: 'white', + backgroundColor: 'transparent', justifyContent: 'center' }, viewContainer: { From b9abea6d33a5ed355473f53b091a43b6d429b96c Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Fri, 13 Apr 2018 19:14:48 +0800 Subject: [PATCH 2/4] add custom input style --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a2088ec..a13f17d 100644 --- a/index.js +++ b/index.js @@ -97,6 +97,7 @@ class FloatLabelTextField extends Component { } render() { + const inputStyle = (this.props.inputStyle) ? this.props.inputStyle : null; return ( @@ -109,7 +110,7 @@ class FloatLabelTextField extends Component { Date: Fri, 13 Apr 2018 19:16:03 +0800 Subject: [PATCH 3/4] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a13f17d..ce6d5e4 100644 --- a/index.js +++ b/index.js @@ -114,8 +114,8 @@ class FloatLabelTextField extends Component { defaultValue={this.props.defaultValue} value={this.state.text} maxLength={this.props.maxLength} - onFocus={() => this.setFocus()} - onBlur={() => this.unsetFocus()} + onFocus={this.setFocus} + onBlur={this.unsetFocus} onChangeText={(value) => this.setText(value)} /> From eb931ea546f657868e9db3fa124d7e50f501ab97 Mon Sep 17 00:00:00 2001 From: fattahmuhyiddeen Date: Sat, 14 Apr 2018 10:48:01 +0800 Subject: [PATCH 4/4] Update index.js --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ce6d5e4..0abba94 100644 --- a/index.js +++ b/index.js @@ -98,13 +98,14 @@ class FloatLabelTextField extends Component { render() { const inputStyle = (this.props.inputStyle) ? this.props.inputStyle : null; + const placeholderFocusStyle = (this.props.placeholderFocusStyle) ? this.props.placeholderFocusStyle : null; return ( - {this.placeholderValue()} + {this.placeholderValue()}