({
value,
disabled,
onValueChange,
color,
theme: themeOverrides,
...rest
}: Props)
| 59 | * ``` |
| 60 | */ |
| 61 | const Switch = ({ |
| 62 | value, |
| 63 | disabled, |
| 64 | onValueChange, |
| 65 | color, |
| 66 | theme: themeOverrides, |
| 67 | ...rest |
| 68 | }: Props) => { |
| 69 | const theme = useInternalTheme(themeOverrides); |
| 70 | const { checkedColor, onTintColor, thumbTintColor } = getSwitchColor({ |
| 71 | theme, |
| 72 | disabled, |
| 73 | value, |
| 74 | color, |
| 75 | }); |
| 76 | |
| 77 | const props = |
| 78 | version && version.major === 0 && version.minor <= 56 |
| 79 | ? { |
| 80 | onTintColor, |
| 81 | thumbTintColor, |
| 82 | } |
| 83 | : Platform.OS === 'web' |
| 84 | ? { |
| 85 | activeTrackColor: onTintColor, |
| 86 | thumbColor: thumbTintColor, |
| 87 | activeThumbColor: checkedColor, |
| 88 | } |
| 89 | : { |
| 90 | thumbColor: thumbTintColor, |
| 91 | trackColor: { |
| 92 | true: onTintColor, |
| 93 | false: onTintColor, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | return ( |
| 98 | <NativeSwitch |
| 99 | value={value} |
| 100 | disabled={disabled} |
| 101 | onValueChange={disabled ? undefined : onValueChange} |
| 102 | {...props} |
| 103 | {...rest} |
| 104 | /> |
| 105 | ); |
| 106 | }; |
| 107 | |
| 108 | export default Switch; |
nothing calls this directly
no test coverage detected
searching dependent graphs…