From f06d8f600a1a8e0d38a8a3dc5f6e9802789e4001 Mon Sep 17 00:00:00 2001 From: alvaromb Date: Tue, 29 Mar 2016 09:43:27 +0200 Subject: [PATCH 1/2] Added focus when tapping the label --- FloatingLabel.js | 89 ++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/FloatingLabel.js b/FloatingLabel.js index 2263b49..21da0b3 100644 --- a/FloatingLabel.js +++ b/FloatingLabel.js @@ -1,4 +1,10 @@ -import React, { Text, TextInput, View, Animated } from 'react-native' +import React, { + Text, + TextInput, + View, + Animated, + TouchableWithoutFeedback, +} from 'react-native' import t from 'tcomb-form-native' const Textbox = t.form.Textbox @@ -34,7 +40,6 @@ class FloatingLabel extends Textbox { if (locals.editable === false) { textboxStyle = stylesheet.textbox.notEditable; } - const help = locals.help ? {locals.help} : null; const error = locals.hasError && locals.error ? {locals.error} : null; const label = @@ -51,45 +56,47 @@ class FloatingLabel extends Textbox { const placeholderString = (self.state.placeholderString !== undefined) ? self.state.placeholderString : locals.label return ( - - {label} - { - locals.onChange(value) - self._onChangeText.bind(self, value, locals) - }} - placeholder={placeholderString} - maxLength={locals.maxLength} - numberOfLines={locals.numberOfLines} - textAlign={locals.textAlign} - textAlignVertical={locals.textAlignVertical} - underlineColorAndroid={locals.underlineColorAndroid} - style={[styles.textInput, textboxStyle]} - value={locals.value} - /> - {help} - {error} - + self.refs.input.focus()}> + + {label} + { + locals.onChange(value) + self._onChangeText.bind(self, value, locals) + }} + placeholder={placeholderString} + maxLength={locals.maxLength} + numberOfLines={locals.numberOfLines} + textAlign={locals.textAlign} + textAlignVertical={locals.textAlignVertical} + underlineColorAndroid={locals.underlineColorAndroid} + style={[styles.textInput, textboxStyle]} + value={locals.value} + /> + {help} + {error} + + ) } } From 7b6604ec2b1009e76f0f769b3cc92cf23fab891b Mon Sep 17 00:00:00 2001 From: alvaromb Date: Tue, 29 Mar 2016 09:43:54 +0200 Subject: [PATCH 2/2] v0.1.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0a27cd..3ecf1b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-floating-label", - "version": "0.1.3", + "version": "0.1.4", "description": "A floating label text input factory for tcomb-form-native", "main": "FloatingLabel.js", "scripts": {