From e69f422e763351978b0a522fe3a89a3c6bb109e8 Mon Sep 17 00:00:00 2001 From: dabit3 Date: Thu, 22 Sep 2016 09:27:12 -0500 Subject: [PATCH] added refs to TextInputs issue #42 issue #39 --- Readme.MD | 4 + package.json | 2 +- src/form/FormInput.js | 175 ++++++++++++++++++++++-------------------- src/input/Search.js | 9 ++- 4 files changed, 103 insertions(+), 87 deletions(-) diff --git a/Readme.MD b/Readme.MD index c6d44d355b..b62afeb44d 100644 --- a/Readme.MD +++ b/Readme.MD @@ -533,6 +533,8 @@ import { SearchBar } from 'react-native-elements' | noIcon | false | boolean | remove icon from textinput | | lightTheme | false | boolean | change theme to light theme | | round | false | boolean | change TextInput styling to rounded corners | +| containerRef | none | ref | ref for TextInput conainer | +| textInputRef | none | ref | ref for TextInput | ## Cross Platform Tab Bar @@ -735,6 +737,8 @@ import { FormLabel, FormInput } from 'react-native-elements' | ---- | ---- | ----| ---- | | containerStyle | none | object (style) | TextInput container styling (optional) | | inputStyle | none | object (style) | TextInput styling (optional) | +| textInputRef | none | ref | tet ref of TextInput | +| containerRef | none | ref | get ref of TextInput container | #### FormLabel props diff --git a/package.json b/package.json index 2323d97ede..8c53298647 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-elements", - "version": "0.5.2", + "version": "0.5.3", "description": "React Native Elements & UI Toolkit", "main": "src/index.js", "repository": { diff --git a/src/form/FormInput.js b/src/form/FormInput.js index d3165d3601..d55e16eb06 100644 --- a/src/form/FormInput.js +++ b/src/form/FormInput.js @@ -1,92 +1,99 @@ -import React from 'react' +import React, { Component } from 'react' import { TextInput, StyleSheet, View, Platform } from 'react-native' import colors from '../config/colors' let styles = {} -const FormInput = ({ - containerStyle, - inputStyle, - value, - autoCapitalize, - autoCorrect, - autoFocus, - blurOnSubmit, - defaultValue, - editable, - keyboardType, - maxLength, - multiline, - onBlur, - onChange, - onChangeText, - onContentSizeChange, - onEndEditing, - onFocus, - onLayout, - onSelectionChange, - onSubmitEditing, - placeholder, - placeholderTextColor, - returnKeyType, - secureTextEntry, - selectTextOnFocus, - selectionColor, - inlineImageLeft, - inlineImagePadding, - numberOfLines, - returnKeyLabel, - underlineColorAndroid, - clearButtonMode, - clearTextOnFocus, - dataDetectorTypes, - enablesReturnKeyAutomatically, - keyboardAppearance, - onKeyPress, - selectionState -}) => ( - - - -) +class FormInput extends Component { + render () { + const { + containerStyle, + inputStyle, + value, + autoCapitalize, + autoCorrect, + autoFocus, + blurOnSubmit, + defaultValue, + editable, + keyboardType, + maxLength, + multiline, + onBlur, + onChange, + onChangeText, + onContentSizeChange, + onEndEditing, + onFocus, + onLayout, + onSelectionChange, + onSubmitEditing, + placeholder, + placeholderTextColor, + returnKeyType, + secureTextEntry, + selectTextOnFocus, + selectionColor, + inlineImageLeft, + inlineImagePadding, + numberOfLines, + returnKeyLabel, + underlineColorAndroid, + clearButtonMode, + clearTextOnFocus, + dataDetectorTypes, + enablesReturnKeyAutomatically, + keyboardAppearance, + onKeyPress, + selectionState, + textInputRef, + containerRef + } = this.props + return ( + + + ) + } +} styles = StyleSheet.create({ container: { diff --git a/src/input/Search.js b/src/input/Search.js index 140598e50d..ab9aeeb0e6 100644 --- a/src/input/Search.js +++ b/src/input/Search.js @@ -49,15 +49,20 @@ const Search = ({ onKeyPress, selectionState, isFocused, - clear + clear, + textInputRef, + containerRef }) => { return ( -