import React, { FC } from 'react';
import { Switch } from 'react-native';

import { COLOR_SECONDARY } from '../../constants/custom';
import { setColorOpacity } from '../../helpers/stringHelpers';

type props = {
  isEnabled: boolean;
  setIsEnabled: (value: boolean) => void;
};

const SwitchCustom: FC<props> = ({ isEnabled, setIsEnabled }) => (
  <Switch
    trackColor={{ false: '#767577', true: setColorOpacity(COLOR_SECONDARY, 0.5) }}
    thumbColor={isEnabled ? COLOR_SECONDARY : '#f4f3f4'}
    ios_backgroundColor="#3e3e3e"
    onValueChange={setIsEnabled}
    value={isEnabled}
  />
);

export default SwitchCustom;
