Skip to content

Commit 6c4bfc8

Browse files
committed
Merge pull request #1 from APSL/label_focus
Label focus
2 parents 52bebcc + 7b6604e commit 6c4bfc8

File tree

2 files changed

+49
-42
lines changed

2 files changed

+49
-42
lines changed

FloatingLabel.js

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { Text, TextInput, View, Animated } from 'react-native'
1+
import React, {
2+
Text,
3+
TextInput,
4+
View,
5+
Animated,
6+
TouchableWithoutFeedback,
7+
} from 'react-native'
28
import t from 'tcomb-form-native'
39

410
const Textbox = t.form.Textbox
@@ -34,7 +40,6 @@ class FloatingLabel extends Textbox {
3440
if (locals.editable === false) {
3541
textboxStyle = stylesheet.textbox.notEditable;
3642
}
37-
3843
const help = locals.help ? <Text style={helpBlockStyle}>{locals.help}</Text> : null;
3944
const error = locals.hasError && locals.error ? <Text style={errorBlockStyle}>{locals.error}</Text> : null;
4045
const label =
@@ -51,45 +56,47 @@ class FloatingLabel extends Textbox {
5156

5257
const placeholderString = (self.state.placeholderString !== undefined) ? self.state.placeholderString : locals.label
5358
return (
54-
<View style={formGroupStyle}>
55-
{label}
56-
<TextInput
57-
ref='input'
58-
autoCapitalize={locals.autoCapitalize}
59-
autoCorrect={locals.autoCorrect}
60-
autoFocus={locals.autoFocus}
61-
bufferDelay={locals.bufferDelay}
62-
clearButtonMode={locals.clearButtonMode}
63-
editable={locals.editable}
64-
enablesReturnKeyAutomatically={locals.enablesReturnKeyAutomatically}
65-
keyboardType={locals.keyboardType}
66-
multiline={locals.multiline}
67-
onBlur={self._onBlur.bind(self, locals)}
68-
onEndEditing={locals.onEndEditing}
69-
onFocus={self._onFocus.bind(self, locals)}
70-
onSubmitEditing={locals.onSubmitEditing}
71-
password={locals.password}
72-
placeholderTextColor={locals.placeholderTextColor}
73-
returnKeyType={locals.returnKeyType}
74-
selectTextOnFocus={locals.selectTextOnFocus}
75-
secureTextEntry={locals.secureTextEntry}
76-
selectionState={locals.selectionState}
77-
onChangeText={(value) => {
78-
locals.onChange(value)
79-
self._onChangeText.bind(self, value, locals)
80-
}}
81-
placeholder={placeholderString}
82-
maxLength={locals.maxLength}
83-
numberOfLines={locals.numberOfLines}
84-
textAlign={locals.textAlign}
85-
textAlignVertical={locals.textAlignVertical}
86-
underlineColorAndroid={locals.underlineColorAndroid}
87-
style={[styles.textInput, textboxStyle]}
88-
value={locals.value}
89-
/>
90-
{help}
91-
{error}
92-
</View>
59+
<TouchableWithoutFeedback onPress={() => self.refs.input.focus()}>
60+
<View style={formGroupStyle}>
61+
{label}
62+
<TextInput
63+
ref='input'
64+
autoCapitalize={locals.autoCapitalize}
65+
autoCorrect={locals.autoCorrect}
66+
autoFocus={locals.autoFocus}
67+
bufferDelay={locals.bufferDelay}
68+
clearButtonMode={locals.clearButtonMode}
69+
editable={locals.editable}
70+
enablesReturnKeyAutomatically={locals.enablesReturnKeyAutomatically}
71+
keyboardType={locals.keyboardType}
72+
multiline={locals.multiline}
73+
onBlur={self._onBlur.bind(self, locals)}
74+
onEndEditing={locals.onEndEditing}
75+
onFocus={self._onFocus.bind(self, locals)}
76+
onSubmitEditing={locals.onSubmitEditing}
77+
password={locals.password}
78+
placeholderTextColor={locals.placeholderTextColor}
79+
returnKeyType={locals.returnKeyType}
80+
selectTextOnFocus={locals.selectTextOnFocus}
81+
secureTextEntry={locals.secureTextEntry}
82+
selectionState={locals.selectionState}
83+
onChangeText={(value) => {
84+
locals.onChange(value)
85+
self._onChangeText.bind(self, value, locals)
86+
}}
87+
placeholder={placeholderString}
88+
maxLength={locals.maxLength}
89+
numberOfLines={locals.numberOfLines}
90+
textAlign={locals.textAlign}
91+
textAlignVertical={locals.textAlignVertical}
92+
underlineColorAndroid={locals.underlineColorAndroid}
93+
style={[styles.textInput, textboxStyle]}
94+
value={locals.value}
95+
/>
96+
{help}
97+
{error}
98+
</View>
99+
</TouchableWithoutFeedback>
93100
)
94101
}
95102
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-floating-label",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "A floating label text input factory for tcomb-form-native",
55
"main": "FloatingLabel.js",
66
"scripts": {

0 commit comments

Comments
 (0)