@@ -32,6 +32,10 @@ export interface CheckboxProps extends TouchableOpacityProps {
32
32
* The Checkbox color
33
33
*/
34
34
color ?: string ;
35
+ /**
36
+ * alternative Checkbox outline style
37
+ */
38
+ outline ?: boolean ;
35
39
/**
36
40
* The size of the checkbox. affect both width and height
37
41
*/
@@ -172,7 +176,18 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
172
176
}
173
177
174
178
renderCheckbox ( ) {
175
- const { selectedIcon, color, iconColor, label, disabled, testID, style, containerStyle, ...others } = this . props ;
179
+ const {
180
+ selectedIcon,
181
+ color,
182
+ iconColor,
183
+ label,
184
+ disabled,
185
+ testID,
186
+ style,
187
+ containerStyle,
188
+ outline = false ,
189
+ ...others
190
+ } = this . props ;
176
191
177
192
return (
178
193
//@ts -ignore
@@ -186,14 +201,18 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
186
201
>
187
202
{
188
203
< Animated . View
189
- style = { [ this . styles . container , { backgroundColor : this . getColor ( ) } , { opacity : this . animationStyle . opacity } ] }
204
+ style = { [
205
+ this . styles . container ,
206
+ { backgroundColor : outline ? 'transparent' : disabled ? DEFAULT_DISABLED_COLOR : this . getColor ( ) } ,
207
+ { opacity : this . animationStyle . opacity }
208
+ ] }
190
209
>
191
210
< Animated . Image
192
211
style = { [
193
212
this . styles . selectedIcon ,
194
- color && { tintColor : iconColor } ,
213
+ color && { tintColor : outline ? this . getColor ( ) : DEFAULT_ICON_COLOR } ,
195
214
{ transform : this . animationStyle . transform } ,
196
- disabled && { tintColor : DEFAULT_ICON_COLOR }
215
+ disabled && { tintColor : outline ? DEFAULT_DISABLED_COLOR : DEFAULT_ICON_COLOR }
197
216
] }
198
217
source = { selectedIcon || Assets . icons . checkSmall }
199
218
testID = { `${ testID } .selected` }
@@ -220,7 +239,7 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
220
239
}
221
240
222
241
function createStyles ( props : CheckboxProps ) {
223
- const { color = DEFAULT_COLOR , iconColor = DEFAULT_ICON_COLOR , size = DEFAULT_SIZE , borderRadius} = props ;
242
+ const { color = DEFAULT_COLOR , iconColor = DEFAULT_ICON_COLOR , size = DEFAULT_SIZE , borderRadius, outline , disabled } = props ;
224
243
225
244
return StyleSheet . create ( {
226
245
container : {
@@ -232,7 +251,7 @@ function createStyles(props: CheckboxProps) {
232
251
borderColor : color
233
252
} ,
234
253
selectedIcon : {
235
- tintColor : iconColor ,
254
+ tintColor : disabled ? DEFAULT_DISABLED_COLOR : outline ? color : iconColor ,
236
255
alignItems : 'center' ,
237
256
justifyContent : 'center'
238
257
} ,
0 commit comments