@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
9
9
import React from 'react' ;
10
10
import { StyleSheet , Animated , TextInput as RNTextInput , Image as RNImage } from 'react-native' ;
11
11
import { Constants } from '../../helpers' ;
12
- import { Colors , Typography } from '../../style' ;
12
+ import { Colors , Typography , Spacings } from '../../style' ;
13
13
import BaseInput from './BaseInput' ;
14
14
import Modal from '../modal' ;
15
15
import TextArea from './TextArea' ;
@@ -125,6 +125,14 @@ export default class TextField extends BaseInput {
125
125
* transform function executed on value and return transformed value
126
126
*/
127
127
transformer : PropTypes . func ,
128
+ /**
129
+ * Pass to render a prefix text as part of the input
130
+ */
131
+ prefix : PropTypes . string ,
132
+ /**
133
+ * The prefix style
134
+ */
135
+ prefixStyle : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . number , PropTypes . array ] ) ,
128
136
/**
129
137
* Fixed title that will displayed above the input (note: floatingPlaceholder MUST be 'false')
130
138
*/
@@ -417,6 +425,14 @@ export default class TextField extends BaseInput {
417
425
}
418
426
}
419
427
428
+ renderPrefix ( ) {
429
+ const { prefix, prefixStyle} = this . props ;
430
+ if ( prefix ) {
431
+ const typography = this . getTypography ( ) ;
432
+ return < Text style = { [ this . styles . prefix , typography , { lineHeight : undefined } , prefixStyle ] } > { prefix } </ Text > ;
433
+ }
434
+ }
435
+
420
436
renderTitle ( ) {
421
437
const { floatingPlaceholder, title, titleColor, titleStyle} = this . getThemeProps ( ) ;
422
438
const color = this . getStateColor ( titleColor || PLACEHOLDER_COLOR_BY_STATE ) ;
@@ -525,7 +541,7 @@ export default class TextField extends BaseInput {
525
541
style,
526
542
placeholderTextColor,
527
543
multiline,
528
- hideUnderline,
544
+ // hideUnderline,
529
545
numberOfLines,
530
546
expandable,
531
547
rightIconSource,
@@ -542,7 +558,7 @@ export default class TextField extends BaseInput {
542
558
const inputStyle = [
543
559
hasRightElement && this . styles . rightElement ,
544
560
this . styles . input ,
545
- hideUnderline && this . styles . inputWithoutUnderline ,
561
+ // hideUnderline && this.styles.inputWithoutUnderline,
546
562
{ ...typographyStyle } ,
547
563
Constants . isAndroid && { lineHeight} ,
548
564
expandable && { maxHeight : lineHeight * ( Constants . isAndroid ? 3 : 3.3 ) } ,
@@ -627,6 +643,7 @@ export default class TextField extends BaseInput {
627
643
{ paddingTop : this . getTopPaddings ( ) }
628
644
] }
629
645
>
646
+ { this . renderPrefix ( ) }
630
647
{ this . renderPlaceholder ( ) }
631
648
{ expandable ? this . renderExpandableInput ( ) : this . renderTextInput ( ) }
632
649
{ this . renderRightButton ( ) }
@@ -697,34 +714,40 @@ function createStyles({centered, multiline, expandable}) {
697
714
flexDirection : 'row' ,
698
715
justifyContent : centered ? 'center' : undefined ,
699
716
borderBottomWidth : 1 ,
700
- borderColor : Colors . dark70
717
+ borderColor : Colors . dark70 ,
718
+ paddingBottom : Constants . isIOS ? 10 : 5
701
719
} ,
702
720
innerContainerWithoutUnderline : {
703
- borderBottomWidth : 0
721
+ borderBottomWidth : 0 ,
722
+ paddingBottom : 0
704
723
} ,
705
724
input : {
706
725
flexGrow : 1 ,
707
726
textAlign : centered ? 'center' : inputTextAlign ,
708
727
backgroundColor : 'transparent' ,
709
- marginBottom : Constants . isIOS ? 10 : 5 ,
728
+ // marginBottom: Constants.isIOS ? 10 : 5,
710
729
padding : 0 , // for Android
711
730
textAlignVertical : 'top' , // for Android
712
731
borderColor : 'transparent' , // borderColor & borderWidth is a fix for collapsing issue on Android
713
- borderWidth : 1 // for Android
732
+ borderWidth : Constants . isAndroid ? 1 : undefined // for Android
714
733
} ,
715
734
expandableInput : {
716
735
flexGrow : 1 ,
717
736
flexDirection : 'row' ,
718
737
alignItems : 'center'
719
738
} ,
720
- inputWithoutUnderline : {
721
- marginBottom : undefined
722
- } ,
739
+ // inputWithoutUnderline: {
740
+ // marginBottom: undefined
741
+ // },
723
742
expandableModalContent : {
724
743
flex : 1 ,
725
744
paddingTop : 15 ,
726
745
paddingHorizontal : 20
727
746
} ,
747
+ prefix : {
748
+ color : Colors . grey30 ,
749
+ marginRight : Spacings . s1
750
+ } ,
728
751
placeholder : {
729
752
textAlign : 'left'
730
753
} ,
0 commit comments