xref: /MusicFree/src/components/base/switch.tsx (revision 1119c2ea435417cd5c53719f91691ff2b1aa8670)
1import React from 'react';
2import {SwitchProps} from 'react-native';
3import useColors from '@/hooks/useColors';
4import {Switch} from 'react-native-gesture-handler';
5import Color from 'color';
6
7interface ISwitchProps extends SwitchProps {}
8export default function ThemeSwitch(props: ISwitchProps) {
9    const colors = useColors();
10    return (
11        <Switch
12            {...props}
13            trackColor={{
14                false: Color(colors.placeholder).alpha(0.8).toString(),
15                true: Color(colors.primary).alpha(0.6).toString(),
16            }}
17            thumbColor={
18                props?.value ? colors.primary ?? '#eba0b3' : colors.placeholder
19            }
20            onValueChange={props.onValueChange ?? undefined}
21        />
22    );
23}
24