1
1
import React , { Component } from 'react' ;
2
2
import { ScrollView } from 'react-native' ;
3
- import {
4
- Colors ,
5
- View ,
6
- Text ,
7
- TextField ,
8
- RadioGroup ,
9
- RadioButton ,
10
- Checkbox ,
11
- Slider ,
12
- ColorPalette
13
- } from 'react-native-ui-lib' ; //eslint-disable-line
3
+ import { Colors , View , Text , TextField , Slider , ColorPalette } from 'react-native-ui-lib' ; //eslint-disable-line
14
4
import { Navigation } from 'react-native-navigation' ;
15
- import _ from 'lodash' ;
5
+
6
+ import {
7
+ renderBooleanOption ,
8
+ renderRadioGroup ,
9
+ renderSliderOption ,
10
+ renderColorOption
11
+ } from '../../ExampleScreenPresenter' ;
16
12
17
13
const ERROR_STATES = {
18
14
noError : 'No Error' ,
@@ -37,81 +33,14 @@ export default class BasicTextFieldScreen extends Component {
37
33
disabled : false ,
38
34
centered : false ,
39
35
useHelperText : false ,
40
- titleColor : Colors . blue30 ,
36
+ titleColor : undefined ,
41
37
error : ERROR_STATES . noError ,
42
38
multiline : false ,
43
39
typography : 70 ,
44
40
charCount : 0
45
41
} ;
46
42
}
47
43
48
- renderColorOption ( title , key ) {
49
- const value = this . state [ key ] ;
50
- return (
51
- < View marginV-s2 >
52
- < Text text70M > { title } </ Text >
53
- < ColorPalette
54
- value = { value }
55
- colors = { [ 'transparent' , Colors . blue30 , Colors . grey10 , Colors . yellow30 , Colors . green30 , Colors . purple30 ] }
56
- onValueChange = { value => this . setState ( { [ key ] : value === 'transparent' ? undefined : value } ) }
57
- />
58
- </ View >
59
- ) ;
60
- }
61
-
62
- renderSliderOption ( title , key , { min = 0 , max = 10 , step = 1 , initial = 0 } ) {
63
- const value = this . state [ key ] ;
64
- return (
65
- < View marginV-s2 >
66
- < Text marginB-s1 text70M >
67
- { title }
68
- </ Text >
69
- < View row centerV >
70
- < Slider
71
- testID = { key }
72
- value = { initial }
73
- containerStyle = { { flex : 1 } }
74
- minimumValue = { min }
75
- maximumValue = { max }
76
- step = { step }
77
- onValueChange = { value => this . setState ( { [ key ] : value } ) }
78
- />
79
- < Text marginL-s4 text70 >
80
- text{ value }
81
- </ Text >
82
- </ View >
83
- </ View >
84
- ) ;
85
- }
86
-
87
- renderRadioGroup ( title , key , options ) {
88
- const value = this . state [ key ] ;
89
- return (
90
- < View marginB-s2 >
91
- < Text text70M marginB-s2 >
92
- { title }
93
- </ Text >
94
- < RadioGroup initialValue = { value } onValueChange = { value => this . setState ( { [ key ] : value } ) } >
95
- { _ . map ( options , ( value , key ) => {
96
- return < RadioButton testID = { key } key = { key } marginB-s2 label = { value } value = { options [ key ] } /> ;
97
- } ) }
98
- </ RadioGroup >
99
- </ View >
100
- ) ;
101
- }
102
-
103
- renderBooleanOption ( title , key ) {
104
- const value = this . state [ key ] ;
105
- return (
106
- < View row centerV spread marginB-s4 >
107
- < Text text70M style = { { flex : 1 } } >
108
- { title }
109
- </ Text >
110
- < Checkbox textID = { key } value = { value } onValueChange = { value => this . setState ( { [ key ] : value } ) } />
111
- </ View >
112
- ) ;
113
- }
114
-
115
44
render ( ) {
116
45
const {
117
46
hideUnderline,
@@ -158,16 +87,21 @@ export default class BasicTextFieldScreen extends Component {
158
87
< Text text50M marginB-s4 >
159
88
Options
160
89
</ Text >
161
- { this . renderSliderOption ( 'Typography (modifier)' , 'typography' , { min : 30 , max : 100 , step : 10 , initial : 70 } ) }
162
- { this . renderBooleanOption ( 'Multiline' , 'multiline' ) }
163
- { this . renderBooleanOption ( 'Disabled' , 'disabled' ) }
164
- { this . renderBooleanOption ( 'Centered' , 'centered' ) }
165
- { this . renderBooleanOption ( 'Hide Underline' , 'hideUnderline' ) }
166
- { this . renderColorOption ( 'Underline Color' , 'underlineColor' ) }
167
- { this . renderRadioGroup ( 'Guiding Text' , 'guidingText' , GUIDING_TEXTS ) }
168
- { this . renderColorOption ( 'Title Color' , 'titleColor' ) }
169
- { this . renderSliderOption ( 'Character Counter' , 'charCount' , { min : 0 , max : 150 , step : 3 } ) }
170
- { this . renderRadioGroup ( 'Errors' , 'error' , ERROR_STATES ) }
90
+ { renderSliderOption . call ( this , 'Typography (modifier)' , 'typography' , {
91
+ min : 30 ,
92
+ max : 100 ,
93
+ step : 10 ,
94
+ initial : 70
95
+ } ) }
96
+ { renderBooleanOption . call ( this , 'Multiline' , 'multiline' ) }
97
+ { renderBooleanOption . call ( this , 'Disabled' , 'disabled' ) }
98
+ { renderBooleanOption . call ( this , 'Centered' , 'centered' ) }
99
+ { renderBooleanOption . call ( this , 'Hide Underline' , 'hideUnderline' ) }
100
+ { renderColorOption . call ( this , 'Underline Color' , 'underlineColor' ) }
101
+ { renderRadioGroup . call ( this , 'Guiding Text' , 'guidingText' , GUIDING_TEXTS ) }
102
+ { renderColorOption . call ( this , 'Title Color' , 'titleColor' ) }
103
+ { renderSliderOption . call ( this , 'Character Counter' , 'charCount' , { min : 0 , max : 150 , step : 3 } ) }
104
+ { renderRadioGroup . call ( this , 'Errors' , 'error' , ERROR_STATES ) }
171
105
</ View >
172
106
</ ScrollView >
173
107
</ View >
0 commit comments