import {
  useWindowDimensions,
  View,
  TouchableOpacity,
  Text,
  Image,
  LayoutAnimation,
} from "react-native";
export const SimpleSwitch = ({
  bool,
  setBool,
  color,
  value,
  image = require("../../assets/icons.png"),
  subText = "",
}) => {
  const { width } = useWindowDimensions();
  return (
    <View style={{ flex: 1 }}>
      <TouchableOpacity
        style={{
          backgroundColor: bool == value.toString() ? color : null,
          padding: 5,
          borderRadius: 5,
          margin: 10,
          alignItems: "center",
          justifyContent: "center",
          flexDirection: "row",
          flex: 1,
        }}
        onPress={() => {
          LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
          setBool(value.toString());
        }}
      >
        <Image
          source={image}
          style={{
            aspectRatio: 1,
            height: undefined,
            width: "100%",
            borderRadius: 5,
          }}
          resizeMethod="scale"
        />
      </TouchableOpacity>
      <Text
        style={{
          fontSize: 14,
          textAlign: "center",
          textAlignVertical: "center",
        }}
      >
        {subText}
      </Text>
    </View>
  );
};
