import React, { useEffect, useRef } from "react"; import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native"; import Svg, { Circle, Defs, LinearGradient, Rect, Stop } from "react-native-svg"; import { useTheme } from "../theme"; const { width: screenWidth } = Dimensions.get("window"); // Constants for dimensions const padding = 20; const listItemHeight = 25; // Increased from 15 to 25 const listItemSpacing = 54; // Adjust if necessary const avatarRadius = 25; // Increased from 12 to 20 const listItemCount = 14; const SkeletonItemBottom = () => { const theme = useTheme(); // Calculate the total height needed for the SVG const totalHeight = padding + listItemCount * (listItemHeight + listItemSpacing); return ( {/* List Items */} {Array.from({ length: listItemCount }).map((_, index) => { const itemY = padding + index * (listItemHeight + listItemSpacing) - 20; return ( {/* Avatar Circle */} {/* Username Rectangle */} ); })} {/* Gradient Definition */} ); }; const SkeletonItemTop = () => { const theme = useTheme(); // Calculate the total height needed for the SVG const totalHeight = padding + listItemCount * (listItemHeight + listItemSpacing); return ( {/* List Items */} {Array.from({ length: listItemCount }).map((_, index) => { const itemY = padding + index * (listItemHeight + listItemSpacing) - 20; return ( {/* Avatar Circle */} {/* Username Rectangle */} ); })} ); }; 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.groupMemberStyle.skeletonStyle.speed) * 1000, easing: Easing.linear, useNativeDriver: false, }) ).start(); }; startShimmer(); }, [animatedValue, theme.groupMemberStyle.skeletonStyle.speed]); const shimmerTranslateX = animatedValue.interpolate({ inputRange: [0, 1], outputRange: [-screenWidth * 2, screenWidth], }); return ( ); }; const styles = StyleSheet.create({ animatedView: { width: "25%", top: 0, bottom: 0, position: "absolute", }, });