import React, { useEffect, useRef } from "react"; import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native"; import Svg, { Defs, LinearGradient, Path, Stop } from "react-native-svg"; import { useTheme } from "../theme"; const { width: screenWidth } = Dimensions.get("window"); const SkeletonItem = () => { const theme = useTheme(); const width = useRef(Math.floor(screenWidth / 2.5 + Math.random() * (screenWidth / 2.5))).current; const alignSelf = useRef( Math.floor(Math.random() * 2) == 0 ? ("flex-end" as const) : ("flex-start" as const) ).current; const animatedValue = useRef(new Animated.Value(0)).current; useEffect(() => { const startShimmer = () => { animatedValue.setValue(0); Animated.loop( Animated.timing(animatedValue, { toValue: 1, duration: theme.conversationStyles.skeletonStyle.speed * 1000, easing: Easing.linear, useNativeDriver: false, }) ).start(); }; startShimmer(); }, [animatedValue]); const shimmerTranslateX = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [-screenWidth, screenWidth], }); return ( ); }; export const MessageSkeleton = () => { return ( {new Array(10).fill(0).map((_, i) => { return ; })} ); }; const styles = StyleSheet.create({ animatedView: { width: "40%", top: 0, bottom: 0, position: "absolute", }, });