MCPcopy
hub / github.com/callstack/react-native-paper / Switch

Function Switch

src/components/Switch/Switch.tsx:61–106  ·  view source on GitHub ↗
({
  value,
  disabled,
  onValueChange,
  color,
  theme: themeOverrides,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

59 * ```
60 */
61const 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
108export default Switch;

Callers

nothing calls this directly

Calls 2

useInternalThemeFunction · 0.90
getSwitchColorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…