import React, { useEffect } from 'react'; import { StyleSheet, View, ViewStyle } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import Animated, { useSharedValue, useAnimatedStyle, withRepeat, withTiming, withSequence, withDelay, interpolate, Easing, } from 'react-native-reanimated'; import { colors } from '../../theme'; interface ShimmerEffectProps { children: React.ReactNode; style?: ViewStyle; shimmerColor?: string; duration?: number; enabled?: boolean; } export function ShimmerEffect({ children, style, shimmerColor = colors.premium.gold, duration = 4000, enabled = true, }: ShimmerEffectProps) { const glowIntensity = useSharedValue(0); useEffect(() => { if (enabled) { // Gentle breathing glow - slow fade in, hold, slow fade out, pause glowIntensity.value = withRepeat( withSequence( withTiming(1, { duration: duration * 0.4, easing: Easing.out(Easing.cubic), }), withDelay( duration * 0.2, withTiming(0, { duration: duration * 0.4, easing: Easing.in(Easing.cubic), }) ) ), -1, false ); } else { glowIntensity.value = 0; } }, [enabled, duration]); const glowStyle = useAnimatedStyle(() => { return { opacity: interpolate(glowIntensity.value, [0, 1], [0, 0.6]), }; }); return ( {children} {enabled && ( {/* Top edge glow */} {/* Bottom edge glow */} {/* Left edge glow */} {/* Right edge glow */} {/* Corner accents for refined look */} )} ); } const styles = StyleSheet.create({ container: { overflow: 'hidden', }, glowContainer: { ...StyleSheet.absoluteFill, }, edgeGlowTop: { position: 'absolute', top: 0, left: 0, right: 0, height: 24, }, edgeGlowBottom: { position: 'absolute', bottom: 0, left: 0, right: 0, height: 16, }, edgeGlowLeft: { position: 'absolute', top: 0, left: 0, bottom: 0, width: 16, }, edgeGlowRight: { position: 'absolute', top: 0, right: 0, bottom: 0, width: 16, }, cornerTopLeft: { position: 'absolute', top: 0, left: 0, width: 40, height: 40, }, cornerTopRight: { position: 'absolute', top: 0, right: 0, width: 40, height: 40, }, }); export default ShimmerEffect;