xref: /MusicFree/src/components/base/switch.tsx (revision 4c80a6012f7e5017419804aebf4baf6099d76e64)
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.textSecondary).alpha(0.8).toString(),
15                true:
16                    Color(colors.textHighlight).alpha(0.8).toString() ??
17                    '#eba0b3',
18            }}
19            thumbColor={
20                props?.value
21                    ? colors.textHighlight ?? '#eba0b3'
22                    : colors.textSecondary
23            }
24            onValueChange={props.onValueChange ?? undefined}
25        />
26    );
27}
28