Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ React Native TextInput styled with Material Design.

## Installation
```
npm install react-native-md-textinput
npm install https://github.com/ajaxangular/react-native-md-textinput --save
```

## Usage
Expand Down
5 changes: 2 additions & 3 deletions lib/FloatingLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
/* @flow */

import React, {
Component,
Component, PropTypes } from 'react'; import {
StyleSheet,
Animated,
PropTypes
Animated
} from 'react-native';

export default class FloatingLabel extends Component {
Expand Down
26 changes: 19 additions & 7 deletions lib/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
/* @flow */

import React, {
Component,
Component, PropTypes } from 'react'; import {
View,
TextInput,
StyleSheet,
PropTypes
StyleSheet
} from 'react-native';

import Underline from './Underline';
Expand All @@ -20,6 +19,19 @@ export default class TextField extends Component {
text: props.value
};
}

componentWillReceiveProps(nextProps: Object){
if(this.props.text !== nextProps.value){
nextProps.value.length !== 0 ?
this.refs.floatingLabel.floatLabel()
: this.refs.floatingLabel.sinkLabel();
this.setState({text: nextProps.value});
}
if(this.props.height !== nextProps.height){
this.setState({height: nextProps.height});
}
}

focus() {
this.refs.input.focus();
}
Expand Down Expand Up @@ -111,19 +123,19 @@ const styles = StyleSheet.create({
position: 'relative'
},
denseWrapper: {
height: 60,
paddingTop: 28,
height: 40,
paddingTop: 30,
paddingBottom: 4,
position: 'relative'
},
textInput: {
fontSize: 16,
height: 34,
height: 40,
lineHeight: 34
},
denseTextInput: {
fontSize: 13,
height: 27,
height: 37,
lineHeight: 24,
paddingBottom: 3
}
Expand Down
12 changes: 9 additions & 3 deletions lib/Underline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
/* @flow */

import React, {
Component,
Component, PropTypes } from 'react'; import {
View,
StyleSheet,
Animated,
PropTypes
Animated
} from 'react-native';

export default class Underline extends Component {
Expand Down Expand Up @@ -47,6 +46,13 @@ export default class Underline extends Component {
} = this.props;
return (
<View
onLayout={(event) => {
const measuredWidth = event.nativeEvent.layout.width;
if (!measuredWidth) {
return;
}
this.wrapperWidth = measuredWidth;
}}
style={[styles.underlineWrapper, {
backgroundColor: borderColor
}]}
Expand Down