-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathApp.tsx
99 lines (85 loc) · 2.89 KB
/
App.tsx
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
98
99
import React from 'react';
import {
Button,
StyleSheet,
Text,
TouchableWithoutFeedback,
TouchableWithoutFeedbackProps,
View,
} from 'react-native';
import { Icon } from 'react-native-eva-icons';
import GithubIcon from 'react-native-eva-icons/icons/Github';
const Section: React.FC<TouchableWithoutFeedbackProps & { title: string }> = ({ title, ...props }) => (
<View style={styles.showcaseContainer}>
<Text>{title}</Text>
<TouchableWithoutFeedback {...props} />
</View>
);
export default (): React.ReactElement => {
const zoomIconRef = React.useRef<Icon>(null);
const pulseIconRef = React.useRef<Icon>(null);
const shakeIconRef = React.useRef<Icon>(null);
const infiniteAnimationIconRef = React.useRef<Icon>(null);
const onInfiniteAnimationIconPress = (): void => {
if (infiniteAnimationIconRef.current?.isAnimating()) {
infiniteAnimationIconRef.current?.stopAnimation();
} else {
infiniteAnimationIconRef.current?.startAnimation();
}
};
const onTestEndCallbackPress = (): void => {
zoomIconRef.current?.startAnimation(() => {
pulseIconRef.current?.startAnimation(() => {
shakeIconRef.current?.startAnimation();
});
});
};
return (
<View style={styles.container}>
<Section title={'Default Icon\nIcons that are statically imported\nare not animateable'}>
<GithubIcon {...styles.icon}/>
</Section>
<Section
title={'Zoom Animation\nPress to animate. Second press to stop'}
onPress={() => zoomIconRef.current?.startAnimation()}>
<Icon ref={zoomIconRef} {...styles.icon} name='maximize-outline' animation='zoom' />
</Section>
<Section
title={'Pulse Animation\nPress to animate'}
onPress={() => pulseIconRef.current?.startAnimation()}>
<Icon ref={pulseIconRef} {...styles.icon} name='activity-outline' animation='pulse' />
</Section>
<Section
title={'Shake Animation\nPress to animate'}
onPress={() => shakeIconRef.current?.startAnimation()}>
<Icon ref={shakeIconRef} {...styles.icon} name='shake' animation='shake' />
</Section>
<Section
title={'Infinite Animation\nPress to animate'}
onPress={onInfiniteAnimationIconPress}>
<Icon ref={infiniteAnimationIconRef} {...styles.icon} name='star' animationConfig={{ cycles: Infinity, useNativeDriver: true }} />
</Section>
<Section title={'Completion Callback\nPress to test callback for animation end'}>
<Button title='TEST' onPress={onTestEndCallbackPress} />
</Section>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
justifyContent: 'center',
},
showcaseContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginVertical: 8,
},
icon: {
width: 64,
height: 64,
fill: 'black',
},
});