import * as ProgressPrimitive from "@rn-primitives/progress"; import { Platform, View } from "react-native"; import Animated, { Extrapolation, interpolate, useAnimatedStyle, useDerivedValue, withSpring, } from "react-native-reanimated"; import { cn } from "@turbostarter/ui"; function Progress({ className, value, indicatorClassName, ...props }: ProgressPrimitive.RootProps & React.RefAttributes & { indicatorClassName?: string; }) { return ( ); } export { Progress }; const Indicator = Platform.select({ web: WebIndicator, native: NativeIndicator, default: NullIndicator, }); interface IndicatorProps { value: number | undefined | null; className?: string; } function WebIndicator({ value, className }: IndicatorProps) { if (Platform.OS !== "web") { return null; } return ( ); } function NativeIndicator({ value, className }: IndicatorProps) { const progress = useDerivedValue(() => value ?? 0); const indicator = useAnimatedStyle(() => { return { width: withSpring( `${interpolate(progress.value, [0, 100], [1, 100], Extrapolation.CLAMP)}%`, { overshootClamping: true }, ), }; }, [value]); if (Platform.OS === "web") { return null; } return ( ); } function NullIndicator(_props: IndicatorProps) { return null; }