import React, { useEffect, useRef } from "react"; import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native"; import Svg, { Defs, G, LinearGradient, Path, Stop } from "react-native-svg"; import { useTheme } from "../theme"; const { width: screenWidth } = Dimensions.get("window"); const SkeletonItemBottom = () => { const theme = useTheme(); return ( ); }; const SkeletonItemTop = () => { const theme = useTheme(); return ( ); }; export const Skeleton = () => { const theme = useTheme(); const animatedValue = useRef(new Animated.Value(0)).current; useEffect(() => { const startShimmer = () => { animatedValue.setValue(0); Animated.loop( Animated.timing(animatedValue, { toValue: 1, duration: (1 / theme.messageInformationStyles.skeletonStyle.speed) * 1000, easing: Easing.linear, useNativeDriver: false, }) ).start(); }; startShimmer(); }, [animatedValue]); const shimmerTranslateX = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [-screenWidth * 2, screenWidth], }); return ( {new Array(20).fill(0).map((_, i) => { return ; })} {new Array(20).fill(0).map((_, i) => { return ; })} ); }; const styles = StyleSheet.create({ animatedView: { width: "25%", top: 0, bottom: 0, position: "absolute", }, });