File size: 2,424 Bytes
0bedb61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React, { useEffect } from 'react';
import { StyleSheet, Text, Pressable, View } from 'react-native';
import Animated, {
  useAnimatedStyle,
  useSharedValue,
  withRepeat,
  withTiming,
  withSpring,
  interpolate,
  Easing,
} from 'react-native-reanimated';
import { COLORS } from '../constants/colors';

export const ShareButton: React.FC = () => {
  const shimmerProgress = useSharedValue(0);
  const scale = useSharedValue(1);

  useEffect(() => {
    shimmerProgress.value = withRepeat(
      withTiming(1, { duration: 3000, easing: Easing.linear }),
      -1,
      false
    );
  }, []);

  const buttonStyle = useAnimatedStyle(() => ({
    transform: [{ scale: scale.value }],
  }));

  const shimmerStyle = useAnimatedStyle(() => ({
    transform: [
      { translateX: interpolate(shimmerProgress.value, [0, 1], [-200, 400]) },
    ],
  }));

  return (
    <Animated.View style={[styles.container, buttonStyle]}>

      <Pressable

        onPressIn={() => {

          scale.value = withSpring(0.94, { damping: 10, stiffness: 200 });

        }}

        onPressOut={() => {

          scale.value = withSpring(1, { damping: 10, stiffness: 200 });

        }}

        onPress={() => {}}

        style={styles.button}

      >

        <Text style={styles.text}>SHARE RESULT</Text>



        {/* Shimmer Effect */}

        <View style={styles.shimmerContainer}>

          <Animated.View style={[styles.shimmer, shimmerStyle]}>

            <View style={styles.shimmerGradient} />

          </Animated.View>

        </View>

      </Pressable>

    </Animated.View>
  );
};

const styles = StyleSheet.create({
  container: {
    marginVertical: 6,
  },
  button: {
    backgroundColor: COLORS.primaryMuted,
    borderRadius: 24,
    borderWidth: 1,
    borderColor: COLORS.primaryBorder,
    paddingVertical: 14,
    paddingHorizontal: 32,
    alignItems: 'center',
    justifyContent: 'center',
    overflow: 'hidden',
  },
  text: {
    color: COLORS.primary,
    fontSize: 13,
    fontWeight: '800',
    letterSpacing: 2,
  },
  shimmerContainer: {
    ...StyleSheet.absoluteFillObject,
    overflow: 'hidden',
    borderRadius: 24,
  },
  shimmer: {
    width: 80,
    height: '100%',
    transform: [{ skewX: '-20deg' }],
  },
  shimmerGradient: {
    flex: 1,
    backgroundColor: 'rgba(163, 230, 53, 0.08)',
  },
});