Skip to content
Merged
Show file tree
Hide file tree
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
89 changes: 48 additions & 41 deletions FloatingLabel.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,7 +40,6 @@ class FloatingLabel extends Textbox {
if (locals.editable === false) {
textboxStyle = stylesheet.textbox.notEditable;
}

const help = locals.help ? <Text style={helpBlockStyle}>{locals.help}</Text> : null;
const error = locals.hasError && locals.error ? <Text style={errorBlockStyle}>{locals.error}</Text> : null;
const label =
Expand All @@ -51,45 +56,47 @@ class FloatingLabel extends Textbox {

const placeholderString = (self.state.placeholderString !== undefined) ? self.state.placeholderString : locals.label
return (
<View style={formGroupStyle}>
{label}
<TextInput
ref='input'
autoCapitalize={locals.autoCapitalize}
autoCorrect={locals.autoCorrect}
autoFocus={locals.autoFocus}
bufferDelay={locals.bufferDelay}
clearButtonMode={locals.clearButtonMode}
editable={locals.editable}
enablesReturnKeyAutomatically={locals.enablesReturnKeyAutomatically}
keyboardType={locals.keyboardType}
multiline={locals.multiline}
onBlur={self._onBlur.bind(self, locals)}
onEndEditing={locals.onEndEditing}
onFocus={self._onFocus.bind(self, locals)}
onSubmitEditing={locals.onSubmitEditing}
password={locals.password}
placeholderTextColor={locals.placeholderTextColor}
returnKeyType={locals.returnKeyType}
selectTextOnFocus={locals.selectTextOnFocus}
secureTextEntry={locals.secureTextEntry}
selectionState={locals.selectionState}
onChangeText={(value) => {
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}
</View>
<TouchableWithoutFeedback onPress={() => self.refs.input.focus()}>
<View style={formGroupStyle}>
{label}
<TextInput
ref='input'
autoCapitalize={locals.autoCapitalize}
autoCorrect={locals.autoCorrect}
autoFocus={locals.autoFocus}
bufferDelay={locals.bufferDelay}
clearButtonMode={locals.clearButtonMode}
editable={locals.editable}
enablesReturnKeyAutomatically={locals.enablesReturnKeyAutomatically}
keyboardType={locals.keyboardType}
multiline={locals.multiline}
onBlur={self._onBlur.bind(self, locals)}
onEndEditing={locals.onEndEditing}
onFocus={self._onFocus.bind(self, locals)}
onSubmitEditing={locals.onSubmitEditing}
password={locals.password}
placeholderTextColor={locals.placeholderTextColor}
returnKeyType={locals.returnKeyType}
selectTextOnFocus={locals.selectTextOnFocus}
secureTextEntry={locals.secureTextEntry}
selectionState={locals.selectionState}
onChangeText={(value) => {
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}
</View>
</TouchableWithoutFeedback>
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down