import { Image, type ImageProps, type ImageSource } from "expo-image"; import { StyleSheet, View } from "react-native"; import Animated, { useAnimatedStyle, type DerivedValue } from "react-native-reanimated"; import { Label } from "./Label"; type PassThroughImageProps = Omit; interface BeforeClipProps { source: ImageSource | number; contentFit?: ImageProps["contentFit"]; imageProps?: PassThroughImageProps; measuredWidth: number; splitPx: DerivedValue; beforeLabel?: string; } export function BeforeClip(props: BeforeClipProps) { const { measuredWidth, splitPx, source, contentFit, imageProps, beforeLabel } = props; const clipStyle = useAnimatedStyle(() => ({ width: splitPx.get() })); return ( {measuredWidth > 0 && ( <> {beforeLabel && ( )} )} ); } const styles = StyleSheet.create({ clip: { position: "absolute", left: 0, top: 0, bottom: 0, overflow: "hidden", }, leftImage: { position: "absolute", left: 0, top: 0, height: "100%", }, });