1- import { bounce , ping , pulse , spin } from 'react-native-css-animations' ;
1+ import {
2+ bounce ,
3+ ping ,
4+ pulse ,
5+ shimmer ,
6+ spin ,
7+ } from 'react-native-css-animations' ;
28
3- import { SafeAreaView , StyleSheet , Text , View } from 'react-native' ;
9+ import { Platform , SafeAreaView , StyleSheet , Text , View } from 'react-native' ;
410import { LinearGradient } from 'expo-linear-gradient' ;
511import Animated from 'react-native-reanimated' ;
612import Fontisto from '@expo/vector-icons/Fontisto' ;
@@ -10,15 +16,6 @@ import MaskedView from '@react-native-masked-view/masked-view';
1016
1117const AnimatedLinearGradient = Animated . createAnimatedComponent ( LinearGradient ) ;
1218
13- const shimmer = {
14- from : {
15- transform : [ { translateX : '-25%' } ] ,
16- } ,
17- to : {
18- transform : [ { translateX : '25%' } ] ,
19- } ,
20- } ;
21-
2219export default function App ( ) {
2320 return (
2421 < SafeAreaView style = { styles . container } >
@@ -46,45 +43,38 @@ export default function App() {
4643 </ View >
4744
4845 < Text style = { styles . label } > Bounce</ Text >
46+ { /* Bounce animation ⬇️ */ }
4947 < Animated . View style = { [ styles . arrow , bounce ] } >
5048 < Entypo name = "chevron-down" size = { 24 } color = "black" />
5149 </ Animated . View >
5250
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 >
51+ { ( Platform . OS === 'ios' || Platform . OS === 'android' ) && (
52+ < >
53+ < Text style = { styles . label } > Shimmer</ Text >
54+ < View style = { styles . shimmerContainer } >
55+ < MaskedView
56+ style = { styles . mask }
57+ maskElement = {
58+ < View style = { styles . skeletonContainer } >
59+ < Animated . View style = { styles . skeletonAvatar } />
60+ < Animated . View style = { styles . skeletonText } />
61+ </ View >
62+ }
63+ >
64+ { /* Shimmer animation ⬇️ */ }
65+ < Animated . View style = { [ styles . gradientContainer , shimmer ] } >
66+ < AnimatedLinearGradient
67+ colors = { [ '#e2e8f0' , '#f8fafc' , '#e2e8f0' ] }
68+ locations = { [ 0.46 , 0.5 , 0.54 ] }
69+ start = { { x : 0 , y : - 5 } }
70+ end = { { x : 1 , y : 5 } }
71+ style = { styles . gradient }
72+ />
73+ </ Animated . View >
74+ </ MaskedView >
75+ </ View >
76+ </ >
77+ ) }
8878 </ SafeAreaView >
8979 ) ;
9080}
@@ -172,4 +162,17 @@ const styles = StyleSheet.create({
172162 alignItems : 'center' ,
173163 justifyContent : 'center' ,
174164 } ,
165+ mask : {
166+ height : 48 ,
167+ width : 210 ,
168+ } ,
169+ gradientContainer : {
170+ flex : 1 ,
171+ width : '300%' ,
172+ marginHorizontal : '-100%' ,
173+ } ,
174+ gradient : {
175+ flex : 1 ,
176+ width : '100%' ,
177+ } ,
175178} ) ;
0 commit comments