Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThemedSwitch.tsx

29 lines674 Bytes

1import { Platform, Switch, type SwitchProps } from "react-native";
2​
3import { MaterialSwitch } from "./MaterialSwitch";
4​
5export type ThemedSwitchProps = Pick<
6 SwitchProps,
7 | "accessibilityHint"
8 | "accessibilityLabel"
9 | "disabled"
10 | "onValueChange"
11 | "style"
12 | "testID"
13 | "value"
14>;
15​
16export function ThemedSwitch(props: ThemedSwitchProps) {
17 if (Platform.OS === "android") {
18 return <MaterialSwitch {...props} />;
19 }
20​
21 return (
22 <Switch
23 {...props}
24 ios_backgroundColorClassName="accent-switch-inactive-track"
25 trackColorOffClassName="accent-switch-inactive-track"
26 trackColorOnClassName="accent-switch-active-track"
27 />
28 );