11import React , { Component } from 'react' ;
22import { 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
144import { Navigation } from 'react-native-navigation' ;
15- import _ from 'lodash' ;
5+
6+ import {
7+ renderBooleanOption ,
8+ renderRadioGroup ,
9+ renderSliderOption ,
10+ renderColorOption
11+ } from '../../ExampleScreenPresenter' ;
1612
1713const ERROR_STATES = {
1814 noError : 'No Error' ,
@@ -37,81 +33,14 @@ export default class BasicTextFieldScreen extends Component {
3733 disabled : false ,
3834 centered : false ,
3935 useHelperText : false ,
40- titleColor : Colors . blue30 ,
36+ titleColor : undefined ,
4137 error : ERROR_STATES . noError ,
4238 multiline : false ,
4339 typography : 70 ,
4440 charCount : 0
4541 } ;
4642 }
4743
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-
11544 render ( ) {
11645 const {
11746 hideUnderline,
@@ -158,16 +87,21 @@ export default class BasicTextFieldScreen extends Component {
15887 < Text text50M marginB-s4 >
15988 Options
16089 </ 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 ) }
171105 </ View >
172106 </ ScrollView >
173107 </ View >
0 commit comments