jrshikoku/components/atom/SimpleSwitch.js
harukin-expo-dev-env e2e302c00c 大規模引っ越し
2024-03-13 10:53:37 +00:00

55 lines
1.1 KiB
JavaScript

import {
useWindowDimensions,
View,
TouchableOpacity,
Text,
Image,
} 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={() => 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>
);
};