@@ -18,6 +18,7 @@ type State = {
18
18
name : string ;
19
19
outlinedText : string ;
20
20
largeText : string ;
21
+ flatTextPassword : string ;
21
22
outlinedLargeText : string ;
22
23
nameNoPadding : string ;
23
24
flatDenseText : string ;
@@ -29,6 +30,11 @@ type State = {
29
30
outlinedMultiline : string ;
30
31
outlinedTextArea : string ;
31
32
maxLengthName : string ;
33
+ flatTextSecureEntry : boolean ;
34
+ outlineTextSecureEntry : boolean ;
35
+ iconsColor : {
36
+ [ key : string ] : string | undefined ;
37
+ } ;
32
38
} ;
33
39
34
40
class TextInputExample extends React . Component < Props , State > {
@@ -39,7 +45,9 @@ class TextInputExample extends React.Component<Props, State> {
39
45
name : '' ,
40
46
outlinedText : '' ,
41
47
largeText : '' ,
48
+ flatTextPassword : 'Password' ,
42
49
outlinedLargeText : '' ,
50
+ outlinedTextPassword : 'Password' ,
43
51
nameNoPadding : '' ,
44
52
flatDenseText : '' ,
45
53
flatDense : '' ,
@@ -50,10 +58,37 @@ class TextInputExample extends React.Component<Props, State> {
50
58
outlinedMultiline : '' ,
51
59
outlinedTextArea : '' ,
52
60
maxLengthName : '' ,
61
+ flatTextSecureEntry : true ,
62
+ outlineTextSecureEntry : true ,
63
+ iconsColor : {
64
+ flatLeftIcon : undefined ,
65
+ flatRightIcon : undefined ,
66
+ outlineLeftIcon : undefined ,
67
+ outlineRightIcon : undefined ,
68
+ } ,
53
69
} ;
54
70
55
71
_isUsernameValid = ( name : string ) => / ^ [ a - z A - Z ] * $ / . test ( name ) ;
56
72
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
+
57
92
render ( ) {
58
93
const {
59
94
theme : {
@@ -78,13 +113,53 @@ class TextInputExample extends React.Component<Props, State> {
78
113
placeholder = "Type something"
79
114
value = { this . state . text }
80
115
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" /> }
81
126
/>
82
127
< TextInput
83
128
style = { [ styles . inputContainerStyle , styles . fontSize ] }
84
129
label = "Flat input large font"
85
130
placeholder = "Type something"
86
131
value = { this . state . largeText }
87
132
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
+ }
88
163
/>
89
164
< TextInput
90
165
style = { styles . inputContainerStyle }
@@ -93,6 +168,7 @@ class TextInputExample extends React.Component<Props, State> {
93
168
placeholder = "Type something"
94
169
value = { this . state . flatDenseText }
95
170
onChangeText = { flatDenseText => this . setState ( { flatDenseText } ) }
171
+ left = { < TextInput . Affix text = "#" /> }
96
172
/>
97
173
< TextInput
98
174
style = { styles . inputContainerStyle }
@@ -129,6 +205,16 @@ class TextInputExample extends React.Component<Props, State> {
129
205
placeholder = "Type something"
130
206
value = { this . state . outlinedText }
131
207
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" /> }
132
218
/>
133
219
< TextInput
134
220
mode = "outlined"
@@ -139,6 +225,37 @@ class TextInputExample extends React.Component<Props, State> {
139
225
onChangeText = { outlinedLargeText =>
140
226
this . setState ( { outlinedLargeText } )
141
227
}
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
+ }
142
259
/>
143
260
< TextInput
144
261
mode = "outlined"
@@ -150,6 +267,7 @@ class TextInputExample extends React.Component<Props, State> {
150
267
onChangeText = { outlinedDenseText =>
151
268
this . setState ( { outlinedDenseText } )
152
269
}
270
+ left = { < TextInput . Affix text = "$" /> }
153
271
/>
154
272
< TextInput
155
273
mode = "outlined"
@@ -196,7 +314,7 @@ class TextInputExample extends React.Component<Props, State> {
196
314
onChangeText = { name => this . setState ( { name } ) }
197
315
/>
198
316
< HelperText
199
- type = "error "
317
+ type = "info "
200
318
visible = { ! this . _isUsernameValid ( this . state . name ) }
201
319
>
202
320
Error: Only letters are allowed
@@ -269,7 +387,7 @@ const styles = StyleSheet.create({
269
387
margin : 8 ,
270
388
} ,
271
389
fontSize : {
272
- fontSize : 24 ,
390
+ fontSize : 32 ,
273
391
} ,
274
392
textArea : {
275
393
height : 80 ,
0 commit comments