@@ -18,6 +18,7 @@ type State = {
1818 name : string ;
1919 outlinedText : string ;
2020 largeText : string ;
21+ flatTextPassword : string ;
2122 outlinedLargeText : string ;
2223 nameNoPadding : string ;
2324 flatDenseText : string ;
@@ -29,6 +30,11 @@ type State = {
2930 outlinedMultiline : string ;
3031 outlinedTextArea : string ;
3132 maxLengthName : string ;
33+ flatTextSecureEntry : boolean ;
34+ outlineTextSecureEntry : boolean ;
35+ iconsColor : {
36+ [ key : string ] : string | undefined ;
37+ } ;
3238} ;
3339
3440class TextInputExample extends React . Component < Props , State > {
@@ -39,7 +45,9 @@ class TextInputExample extends React.Component<Props, State> {
3945 name : '' ,
4046 outlinedText : '' ,
4147 largeText : '' ,
48+ flatTextPassword : 'Password' ,
4249 outlinedLargeText : '' ,
50+ outlinedTextPassword : 'Password' ,
4351 nameNoPadding : '' ,
4452 flatDenseText : '' ,
4553 flatDense : '' ,
@@ -50,10 +58,37 @@ class TextInputExample extends React.Component<Props, State> {
5058 outlinedMultiline : '' ,
5159 outlinedTextArea : '' ,
5260 maxLengthName : '' ,
61+ flatTextSecureEntry : true ,
62+ outlineTextSecureEntry : true ,
63+ iconsColor : {
64+ flatLeftIcon : undefined ,
65+ flatRightIcon : undefined ,
66+ outlineLeftIcon : undefined ,
67+ outlineRightIcon : undefined ,
68+ } ,
5369 } ;
5470
5571 _isUsernameValid = ( name : string ) => / ^ [ a - z A - Z ] * $ / . test ( name ) ;
5672
73+ _changeIconColor = ( name : string ) => {
74+ const {
75+ theme : {
76+ colors : { accent } ,
77+ } ,
78+ } = this . props ;
79+
80+ const { iconsColor : currentColors } = this . state ;
81+
82+ const color = ( currentColors as State [ 'iconsColor' ] ) [ name ] ;
83+
84+ const iconsColor = {
85+ ...currentColors ,
86+ [ name ] : ! color ? accent : undefined ,
87+ } ;
88+
89+ this . setState ( { iconsColor } ) ;
90+ } ;
91+
5792 render ( ) {
5893 const {
5994 theme : {
@@ -78,13 +113,53 @@ class TextInputExample extends React.Component<Props, State> {
78113 placeholder = "Type something"
79114 value = { this . state . text }
80115 onChangeText = { text => this . setState ( { text } ) }
116+ left = {
117+ < TextInput . Icon
118+ name = "heart"
119+ color = { this . state . iconsColor [ 'flatLeftIcon' ] }
120+ onPress = { ( ) => {
121+ this . _changeIconColor ( 'flatLeftIcon' ) ;
122+ } }
123+ />
124+ }
125+ right = { < TextInput . Affix text = "/100" /> }
81126 />
82127 < TextInput
83128 style = { [ styles . inputContainerStyle , styles . fontSize ] }
84129 label = "Flat input large font"
85130 placeholder = "Type something"
86131 value = { this . state . largeText }
87132 onChangeText = { largeText => this . setState ( { largeText } ) }
133+ left = { < TextInput . Affix text = "#" /> }
134+ right = {
135+ < TextInput . Icon
136+ name = "heart"
137+ color = { this . state . iconsColor [ 'flatRightIcon' ] }
138+ onPress = { ( ) => {
139+ this . _changeIconColor ( 'flatRightIcon' ) ;
140+ } }
141+ />
142+ }
143+ />
144+ < TextInput
145+ style = { [ styles . inputContainerStyle , styles . fontSize ] }
146+ label = "Flat input large font"
147+ placeholder = "Type something"
148+ value = { this . state . flatTextPassword }
149+ onChangeText = { flatTextPassword =>
150+ this . setState ( { flatTextPassword } )
151+ }
152+ secureTextEntry = { this . state . flatTextSecureEntry }
153+ right = {
154+ < TextInput . Icon
155+ name = { this . state . flatTextSecureEntry ? 'eye' : 'eye-off' }
156+ onPress = { ( ) =>
157+ this . setState ( {
158+ flatTextSecureEntry : ! this . state . flatTextSecureEntry ,
159+ } )
160+ }
161+ />
162+ }
88163 />
89164 < TextInput
90165 style = { styles . inputContainerStyle }
@@ -93,6 +168,7 @@ class TextInputExample extends React.Component<Props, State> {
93168 placeholder = "Type something"
94169 value = { this . state . flatDenseText }
95170 onChangeText = { flatDenseText => this . setState ( { flatDenseText } ) }
171+ left = { < TextInput . Affix text = "#" /> }
96172 />
97173 < TextInput
98174 style = { styles . inputContainerStyle }
@@ -129,6 +205,16 @@ class TextInputExample extends React.Component<Props, State> {
129205 placeholder = "Type something"
130206 value = { this . state . outlinedText }
131207 onChangeText = { outlinedText => this . setState ( { outlinedText } ) }
208+ left = {
209+ < TextInput . Icon
210+ name = "heart"
211+ color = { this . state . iconsColor [ 'outlineLeftIcon' ] }
212+ onPress = { ( ) => {
213+ this . _changeIconColor ( 'outlineLeftIcon' ) ;
214+ } }
215+ />
216+ }
217+ right = { < TextInput . Affix text = "/100" /> }
132218 />
133219 < TextInput
134220 mode = "outlined"
@@ -139,6 +225,37 @@ class TextInputExample extends React.Component<Props, State> {
139225 onChangeText = { outlinedLargeText =>
140226 this . setState ( { outlinedLargeText } )
141227 }
228+ left = { < TextInput . Affix text = "$" /> }
229+ right = {
230+ < TextInput . Icon
231+ name = "heart"
232+ color = { this . state . iconsColor [ 'outlineRightIcon' ] }
233+ onPress = { ( ) => {
234+ this . _changeIconColor ( 'outlineRightIcon' ) ;
235+ } }
236+ />
237+ }
238+ />
239+ < TextInput
240+ mode = "outlined"
241+ style = { [ styles . inputContainerStyle , styles . fontSize ] }
242+ label = "Outlined large font"
243+ placeholder = "Type something"
244+ value = { this . state . outlinedTextPassword }
245+ onChangeText = { outlinedLargeText =>
246+ this . setState ( { outlinedLargeText } )
247+ }
248+ secureTextEntry = { this . state . outlineTextSecureEntry }
249+ right = {
250+ < TextInput . Icon
251+ name = { this . state . outlineTextSecureEntry ? 'eye' : 'eye-off' }
252+ onPress = { ( ) =>
253+ this . setState ( {
254+ outlineTextSecureEntry : ! this . state . outlineTextSecureEntry ,
255+ } )
256+ }
257+ />
258+ }
142259 />
143260 < TextInput
144261 mode = "outlined"
@@ -150,6 +267,7 @@ class TextInputExample extends React.Component<Props, State> {
150267 onChangeText = { outlinedDenseText =>
151268 this . setState ( { outlinedDenseText } )
152269 }
270+ left = { < TextInput . Affix text = "$" /> }
153271 />
154272 < TextInput
155273 mode = "outlined"
@@ -196,7 +314,7 @@ class TextInputExample extends React.Component<Props, State> {
196314 onChangeText = { name => this . setState ( { name } ) }
197315 />
198316 < HelperText
199- type = "error "
317+ type = "info "
200318 visible = { ! this . _isUsernameValid ( this . state . name ) }
201319 >
202320 Error: Only letters are allowed
@@ -269,7 +387,7 @@ const styles = StyleSheet.create({
269387 margin : 8 ,
270388 } ,
271389 fontSize : {
272- fontSize : 24 ,
390+ fontSize : 32 ,
273391 } ,
274392 textArea : {
275393 height : 80 ,
0 commit comments