Skip to content

Commit cc2fc29

Browse files
feat: draft working example on iOS and Android
1 parent 98f155e commit cc2fc29

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

example/src/App.tsx

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import { bounce, ping, pulse, spin } from 'react-native-css-animations';
2+
13
import { SafeAreaView, StyleSheet, Text, View } from 'react-native';
4+
import { LinearGradient } from 'expo-linear-gradient';
25
import Animated from 'react-native-reanimated';
36
import Fontisto from '@expo/vector-icons/Fontisto';
47
import Entypo from '@expo/vector-icons/Entypo';
58
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+
};
721

822
export default function App() {
923
return (
@@ -35,6 +49,42 @@ export default function App() {
3549
<Animated.View style={[styles.arrow, bounce]}>
3650
<Entypo name="chevron-down" size={24} color="black" />
3751
</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>
3888
</SafeAreaView>
3989
);
4090
}
@@ -116,4 +166,10 @@ const styles = StyleSheet.create({
116166
justifyContent: 'center',
117167
borderColor: '#e2e8f0',
118168
},
169+
shimmerContainer: {
170+
width: '100%',
171+
height: 48,
172+
alignItems: 'center',
173+
justifyContent: 'center',
174+
},
119175
});

0 commit comments

Comments
 (0)