|
| 1 | +import { bounce, ping, pulse, spin } from 'react-native-css-animations'; |
| 2 | + |
1 | 3 | import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; |
| 4 | +import { LinearGradient } from 'expo-linear-gradient'; |
2 | 5 | import Animated from 'react-native-reanimated'; |
3 | 6 | import Fontisto from '@expo/vector-icons/Fontisto'; |
4 | 7 | import Entypo from '@expo/vector-icons/Entypo'; |
5 | 8 | import EvilIcons from '@expo/vector-icons/EvilIcons'; |
6 | | -import { bounce, ping, pulse, spin } from 'react-native-css-animations'; |
| 9 | +import MaskedView from '@react-native-masked-view/masked-view'; |
| 10 | + |
| 11 | +const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient); |
| 12 | + |
| 13 | +const shimmer = { |
| 14 | + from: { |
| 15 | + transform: [{ translateX: '-25%' }], |
| 16 | + }, |
| 17 | + to: { |
| 18 | + transform: [{ translateX: '25%' }], |
| 19 | + }, |
| 20 | +}; |
7 | 21 |
|
8 | 22 | export default function App() { |
9 | 23 | return ( |
@@ -35,6 +49,42 @@ export default function App() { |
35 | 49 | <Animated.View style={[styles.arrow, bounce]}> |
36 | 50 | <Entypo name="chevron-down" size={24} color="black" /> |
37 | 51 | </Animated.View> |
| 52 | + |
| 53 | + <Text style={styles.label}>Skimmer</Text> |
| 54 | + <View style={styles.shimmerContainer}> |
| 55 | + <MaskedView |
| 56 | + style={{ height: 48, width: 48 + 12 + 150 }} |
| 57 | + maskElement={ |
| 58 | + <View style={styles.skeletonContainer}> |
| 59 | + <Animated.View style={styles.skeletonAvatar} /> |
| 60 | + <Animated.View style={styles.skeletonText} /> |
| 61 | + </View> |
| 62 | + } |
| 63 | + > |
| 64 | + <Animated.View |
| 65 | + style={{ |
| 66 | + flex: 1, |
| 67 | + width: '300%', |
| 68 | + marginHorizontal: '-100%', |
| 69 | + animationName: shimmer, |
| 70 | + animationDuration: '1s', |
| 71 | + animationIterationCount: 'infinite', |
| 72 | + animationTimingFunction: 'linear', |
| 73 | + }} |
| 74 | + > |
| 75 | + <AnimatedLinearGradient |
| 76 | + colors={['#e2e8f0', '#f8fafc', '#e2e8f0']} |
| 77 | + locations={[0.46, 0.5, 0.54]} |
| 78 | + start={{ x: 0, y: -5 }} |
| 79 | + end={{ x: 1, y: 5 }} |
| 80 | + style={{ |
| 81 | + flex: 1, |
| 82 | + width: '100%', |
| 83 | + }} |
| 84 | + /> |
| 85 | + </Animated.View> |
| 86 | + </MaskedView> |
| 87 | + </View> |
38 | 88 | </SafeAreaView> |
39 | 89 | ); |
40 | 90 | } |
@@ -116,4 +166,10 @@ const styles = StyleSheet.create({ |
116 | 166 | justifyContent: 'center', |
117 | 167 | borderColor: '#e2e8f0', |
118 | 168 | }, |
| 169 | + shimmerContainer: { |
| 170 | + width: '100%', |
| 171 | + height: 48, |
| 172 | + alignItems: 'center', |
| 173 | + justifyContent: 'center', |
| 174 | + }, |
119 | 175 | }); |
0 commit comments