This commit is contained in:
Philip Cesar Garay
2025-07-31 21:25:33 +08:00
parent 5cfbc81e3a
commit 84fc719a10
307 changed files with 46470 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
import { Motion } from "@legendapp/motion";
import { Pressable, View } from "react-native";
import { Easing } from "react-native-reanimated";
import { Palette } from "../styles";
export default ({ value, setValue, containerStyle = {} }) => {
const currentColor = value ? Palette.green : Palette.red;
const switchHeight = 28;
const borderWidth = 2;
const internalMargin = 2;
const itemSize = switchHeight - borderWidth * 2 - internalMargin * 2;
return (
<Pressable
onPress={() => setValue(!value)}
style={{
flexDirection: "row",
width: switchHeight * 2,
height: switchHeight,
borderColor: currentColor,
borderWidth: borderWidth,
borderRadius: 25,
...containerStyle,
}}
>
<Motion.View
animate={{
right: value ? 0 : switchHeight,
left: value ? switchHeight : 0,
}}
transition={{
type: "timing",
duration: 300,
easing: Easing.easing,
}}
style={{
position: "absolute",
width: itemSize,
height: itemSize,
margin: internalMargin,
borderRadius: 25,
backgroundColor: currentColor,
}}
/>
</Pressable>
);
};