import { useContext } from "react";
import { Switch } from "react-native";
import { AppContext } from "../../utils";

export default function MySwitch({ style, value, onValueChange }) {
  const appContext = useContext(AppContext);

  return (
    <Switch
      style={style}
      value={value}
      onValueChange={onValueChange}
      trackColor={{
        true: appContext.appTheme.switch.trackColorTrue,
        false: appContext.appTheme.switch.trackColorFalse,
      }}
      thumbColor={
        value === true
          ? appContext.appTheme.switch.thumbColorTrue
          : appContext.appTheme.switch.thumbColorFalse
      }
      ios_backgroundColor={appContext.appTheme.switch.ios_backgroundColor}
    />
  );
}
