@@ -10,44 +10,53 @@ import {
10
10
RadioGroup ,
11
11
Slider ,
12
12
SegmentedControl ,
13
+ SegmentedControlItemProps ,
13
14
Text ,
15
+ TextProps ,
14
16
View
15
17
} from 'react-native-ui-lib' ;
16
18
17
- export function renderHeader ( title , others ) {
19
+ interface RadioGroupOptions {
20
+ isRow ?: boolean ;
21
+ afterValueChanged ?: ( ) => void ;
22
+ useValueAsLabel ?: boolean ;
23
+ }
24
+
25
+ export function renderHeader ( title : string , others : TextProps ) {
18
26
return (
19
27
< Text text30 grey10 { ...others } >
20
28
{ title }
21
29
</ Text >
22
30
) ;
23
31
}
24
32
25
- export function renderBooleanOption ( title , key ) {
33
+ export function renderBooleanOption ( title : string , key : string ) {
34
+ // @ts -ignore
26
35
const value = this . state [ key ] ;
27
36
return (
28
37
< View row centerV spread marginB-s4 key = { key } >
29
- < Text flex >
30
- { title }
31
- </ Text >
38
+ < Text flex > { title } </ Text >
32
39
< Switch
33
40
useCustomTheme
34
41
key = { key }
35
- textID = { key }
42
+ testID = { key }
36
43
value = { value }
44
+ // @ts -ignore
37
45
onValueChange = { value => this . setState ( { [ key ] : value } ) }
38
46
/>
39
47
</ View >
40
48
) ;
41
49
}
42
50
43
- export function renderBooleanGroup ( title , options ) {
51
+ export function renderBooleanGroup ( title : string , options : string [ ] ) {
44
52
return (
45
53
< View marginB-s2 >
46
54
< Text text70M marginB-s2 >
47
55
{ title }
48
56
</ Text >
49
57
< View row style = { styles . rowWrap } >
50
58
{ _ . map ( options , key => {
59
+ // @ts -ignore
51
60
const value = this . state [ key ] ;
52
61
return (
53
62
< View spread centerH row key = { key } >
@@ -57,6 +66,7 @@ export function renderBooleanGroup(title, options) {
57
66
key = { key }
58
67
testID = { key }
59
68
value = { value }
69
+ // @ts -ignore
60
70
onValueChange = { value => this . setState ( { [ key ] : value } ) }
61
71
/>
62
72
< Text text70 marginR-s3 marginB-s2 >
@@ -70,7 +80,11 @@ export function renderBooleanGroup(title, options) {
70
80
) ;
71
81
}
72
82
73
- export function renderRadioGroup ( title , key , options , { isRow, afterValueChanged, useValueAsLabel} = { } ) {
83
+ export function renderRadioGroup ( title : string ,
84
+ key : string ,
85
+ options : object ,
86
+ { isRow, afterValueChanged, useValueAsLabel} : RadioGroupOptions = { } ) {
87
+ // @ts -ignore
74
88
const value = this . state [ key ] ;
75
89
return (
76
90
< View marginB-s2 >
@@ -83,6 +97,7 @@ export function renderRadioGroup(title, key, options, {isRow, afterValueChanged,
83
97
row = { isRow }
84
98
style = { isRow && styles . rowWrap }
85
99
initialValue = { value }
100
+ // @ts -ignore
86
101
onValueChange = { value => this . setState ( { [ key ] : value } , afterValueChanged ) }
87
102
>
88
103
{ _ . map ( options , ( value , key ) => {
@@ -103,23 +118,28 @@ export function renderRadioGroup(title, key, options, {isRow, afterValueChanged,
103
118
) ;
104
119
}
105
120
106
- export function renderColorOption ( title ,
107
- key ,
121
+ export function renderColorOption ( title : string ,
122
+ key : string ,
108
123
colors = [ 'transparent' , Colors . blue30 , Colors . grey10 , Colors . yellow30 , Colors . green30 , Colors . purple30 ] ) {
124
+ // @ts -ignore
109
125
const value = this . state [ key ] ;
110
126
return (
111
127
< View marginV-s2 >
112
128
< Text text70M > { title } </ Text >
113
129
< ColorPalette
114
130
value = { value }
115
131
colors = { colors }
132
+ // @ts -ignore
116
133
onValueChange = { value => this . setState ( { [ key ] : value === 'transparent' ? undefined : value } ) }
117
134
/>
118
135
</ View >
119
136
) ;
120
137
}
121
138
122
- export function renderSliderOption ( title , key , { min = 0 , max = 10 , step = 1 , initial = 0 , sliderText = '' } ) {
139
+ export function renderSliderOption ( title : string ,
140
+ key : string ,
141
+ { min = 0 , max = 10 , step = 1 , initial = 0 , sliderText = '' } ) {
142
+ // @ts -ignore
123
143
const value = this . state [ key ] || initial ;
124
144
return (
125
145
< View marginV-s2 >
@@ -134,6 +154,7 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
134
154
minimumValue = { min }
135
155
maximumValue = { max }
136
156
step = { step }
157
+ // @ts -ignore
137
158
onValueChange = { value => this . setState ( { [ key ] : value } ) }
138
159
/>
139
160
< Text marginL-s4 text70 style = { styles . text } >
@@ -145,7 +166,8 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
145
166
) ;
146
167
}
147
168
148
- export function renderMultipleSegmentOptions ( title , key , options ) {
169
+ export function renderMultipleSegmentOptions ( title : string , key : string , options : ( SegmentedControlItemProps & { value : any } ) [ ] ) {
170
+ // @ts -ignore
149
171
const value = this . state [ key ] ;
150
172
const index = _ . findIndex ( options , { value} ) ;
151
173
@@ -155,6 +177,7 @@ export function renderMultipleSegmentOptions(title, key, options) {
155
177
< SegmentedControl
156
178
initialIndex = { index }
157
179
segments = { options }
180
+ // @ts -ignore
158
181
onChangeIndex = { index => this . setState ( { [ key ] : options [ index ] . value } ) }
159
182
/>
160
183
</ View >
0 commit comments