diff --git a/package.json b/package.json index 1e63b0fb..6a3c083b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "react-native-material-textfield", - "version": "0.16.1", + "name": "@anasmasood94/react-native-material-textfield", + "version": "0.16.2", "license": "BSD-3-Clause", "author": "Alexander Nazarov ", @@ -25,7 +25,7 @@ "repository": { "type": "git", - "url": "git://github.com/n4kz/react-native-material-textfield.git" + "url": "git://github.com/anasmasood94/react-native-material-textfield.git" }, "dependencies": { diff --git a/src/components/affix/index.js b/src/components/affix/index.js index 0f85022e..8d7cd742 100644 --- a/src/components/affix/index.js +++ b/src/components/affix/index.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { PureComponent } from 'react'; -import { Animated } from 'react-native'; +import { Animated, Text } from 'react-native'; import styles from './styles'; @@ -11,7 +11,7 @@ export default class Affix extends PureComponent { static propTypes = { numberOfLines: PropTypes.number, - style: Animated.Text.propTypes.style, + style: Text.propTypes.style, color: PropTypes.string.isRequired, fontSize: PropTypes.number.isRequired, diff --git a/src/components/field/index.js b/src/components/field/index.js index 281b7451..1487b077 100644 --- a/src/components/field/index.js +++ b/src/components/field/index.js @@ -82,6 +82,14 @@ export default class TextField extends PureComponent { bottom: PropTypes.number, }), + value: PropTypes.arrayOf(PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ])) || PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + ]), + labelOffset: Label.propTypes.offset, labelTextStyle: Text.propTypes.style, @@ -113,6 +121,7 @@ export default class TextField extends PureComponent { renderLeftAccessory: PropTypes.func, renderRightAccessory: PropTypes.func, + renderAccessory: PropTypes.func, prefix: PropTypes.string, suffix: PropTypes.string, @@ -205,6 +214,10 @@ export default class TextField extends PureComponent { let errorState = errorStateFromProps(this.props); let prevErrorState = errorStateFromProps(prevProps); + if (this.state.text != this.props.value) { + this.setState({ text: this.props.value }); + } + if (errorState ^ prevErrorState) { this.startFocusAnimation(); } @@ -521,7 +534,7 @@ export default class TextField extends PureComponent { } renderAccessory(prop) { - let { [prop]: renderAccessory } = this.props; + let { renderAccessory } = this.props; return 'function' === typeof renderAccessory? renderAccessory(): @@ -609,6 +622,7 @@ export default class TextField extends PureComponent { editable, tintColor, style: inputStyleOverrides, + textInputStyle, } = this.props; let props = this.inputProps(); @@ -620,7 +634,7 @@ export default class TextField extends PureComponent { {...props} - style={[styles.input, inputStyle, inputStyleOverrides]} + style={[styles.input, inputStyle, inputStyleOverrides, textInputStyle]} editable={!disabled && editable} onChange={this.onChange} onChangeText={this.onChangeText} @@ -706,7 +720,6 @@ export default class TextField extends PureComponent { {this.renderLine(lineProps)} - {this.renderAccessory('renderLeftAccessory')} {this.renderLabel(styleProps)} diff --git a/src/components/helper/index.js b/src/components/helper/index.js index 6060f9f5..76eb54d7 100644 --- a/src/components/helper/index.js +++ b/src/components/helper/index.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { PureComponent } from 'react'; -import { Animated } from 'react-native'; +import { Animated, Text } from 'react-native'; import styles from './styles'; @@ -11,7 +11,7 @@ export default class Helper extends PureComponent { disabled: PropTypes.bool, - style: Animated.Text.propTypes.style, + style: Text.propTypes.style, baseColor: PropTypes.string, errorColor: PropTypes.string, diff --git a/src/components/label/index.js b/src/components/label/index.js index 82eaf033..4eb5f8b6 100644 --- a/src/components/label/index.js +++ b/src/components/label/index.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { PureComponent } from 'react'; -import { Animated } from 'react-native'; +import { Animated, Text } from 'react-native'; import styles from './styles'; @@ -43,7 +43,7 @@ export default class Label extends PureComponent { y1: PropTypes.number, }), - style: Animated.Text.propTypes.style, + style: Text.propTypes.style, label: PropTypes.string, };