@@ -9,35 +9,46 @@ import {
99 TextInput
1010} from 'react-native' ;
1111
12- const BASE_HEIGHT = 23 ;
12+ const BASE_HEIGHT = 20 ;
13+ const OFFSET = theme . value ( 10 , 4 ) ;
1314
1415class CellInput extends React . Component {
1516 static defaultProps = {
1617 rows : 1 ,
17- autoResize : false
18+ autoResize : false ,
19+ minRows : 1
1820 }
1921
2022 static propTypes = {
2123 ...TextInput . propTypes ,
2224 rows : React . PropTypes . number ,
25+ minRows : React . PropTypes . number ,
2326 autoResize : React . PropTypes . bool
2427 }
2528
2629 constructor ( props ) {
2730 super ( props ) ;
2831
32+ let height = BASE_HEIGHT ;
33+
34+ // autorize is not yet supported in android (?)
35+ if ( this . props . multiline && ( ! this . props . autoResize || theme . isAndroid ) ) {
36+ height = Math . max ( BASE_HEIGHT * this . props . rows , BASE_HEIGHT * this . props . minRows ) ;
37+ }
38+
2939 this . state = {
30- rows : this . props . rows
40+ height
3141 }
3242 }
3343
3444 handleOnContentSizeChange = ( e ) => {
3545 const contentHeight = e . nativeEvent . contentSize . height ;
3646
37- if ( this . props . autoResize ) {
47+ // autorize is not yet supported in android (?)
48+ if ( this . props . autoResize && theme . isIOS ) {
3849 if ( ( contentHeight - contentHeight % BASE_HEIGHT ) / BASE_HEIGHT < this . props . rows ) {
39- this . setNativeProps ( {
40- height : contentHeight
50+ this . setState ( {
51+ height : Math . max ( BASE_HEIGHT * this . props . minRows , contentHeight )
4152 } ) ;
4253 }
4354 }
@@ -56,22 +67,17 @@ class CellInput extends React.Component {
5667 }
5768
5869 renderTextInput ( ) {
59- const textInputStyle = this . props . multiline &&
60- {
61- // paddingBottom: theme.padding,
62- height : this . props . autoResize ? BASE_HEIGHT : BASE_HEIGHT * this . props . rows
63- }
64-
6570 return (
6671 < TextInput
6772 ref = { component => this . _textInput = component }
6873 clearButtonMode = "while-editing"
6974 selectionColor = { theme . color . info }
75+ placeholderTextColor = { this . props . placeholderTextColor || theme . color . muted }
76+ autoCapitalize = "sentences"
7077 { ...this . props }
71- style = { [ styles . textInput , textInputStyle , this . props . style ] }
78+ style = { [ styles . textInput , { height : this . state . height + OFFSET } ] }
7279 onContentSizeChange = { this . handleOnContentSizeChange }
7380 placeholder = { this . props . multiline === true ? this . props . title || this . props . placeholder : this . props . placeholder }
74- placeholderTextColor = { theme . color . muted }
7581 underlineColorAndroid = "transparent"
7682 />
7783 ) ;
@@ -82,8 +88,10 @@ class CellInput extends React.Component {
8288 < Cell
8389 icon = { this . props . icon }
8490 tintColor = { this . props . tintColor }
91+ disclosure = { this . props . disclosure }
92+ contentPosition = "top"
8593 title = { ! this . props . multiline && this . props . title }
86- style = { this . props . editable === false && styles . inputDisabled }
94+ style = { [ this . props . editable === false && styles . inputDisabled , this . props . style ] }
8795 >
8896 { this . renderTextInput ( ) }
8997 </ Cell >
@@ -95,6 +103,7 @@ const styles = StyleSheet.create({
95103 textInput : {
96104 fontSize : theme . font . medium ,
97105 textAlign : 'left' ,
106+ textAlignVertical : 'top' ,
98107 flex : 1 ,
99108 height : BASE_HEIGHT ,
100109 padding : 0
0 commit comments