-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
127 lines (125 loc) · 3.11 KB
/
App.js
File metadata and controls
127 lines (125 loc) · 3.11 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { StatusBar } from "expo-status-bar";
import React, { useRef } from "react";
import { StyleSheet, Text, View, Dimensions, Animated } from "react-native";
const { width, height } = Dimensions.get("window");
const circleWidth = width / 2;
export default function App() {
const move = useRef(new Animated.Value(0)).current;
const textOpacity = useRef(new Animated.Value(1)).current;
Animated.loop(
Animated.sequence([
Animated.parallel([
Animated.timing(textOpacity, {
toValue: 1,
duration: 300,
useNativeDriver: true,
}),
Animated.timing(move, {
toValue: 1,
duration: 4000,
useNativeDriver: true,
}),
]),
Animated.parallel([
Animated.timing(textOpacity, {
delay: 100,
toValue: 0,
duration: 300,
useNativeDriver: true,
}),
Animated.timing(move, {
delay: 1000,
toValue: 0,
duration: 4000,
useNativeDriver: true,
}),
]),
])
).start();
const translate = move.interpolate({
inputRange: [0, 1],
outputRange: [0, circleWidth / 6],
});
const exhale = textOpacity.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
});
return (
<View style={styles.container}>
<Animated.View
style={{
width: circleWidth,
height: circleWidth,
...StyleSheet.absoluteFill,
alignItems: "center",
justifyContent: "center",
opacity: textOpacity,
}}
>
<Text
style={{
fontSize: 20,
fontWeight: "600",
}}
>
Inhale
</Text>
</Animated.View>
<Animated.View
style={{
width: circleWidth,
height: circleWidth,
...StyleSheet.absoluteFill,
alignItems: "center",
justifyContent: "center",
opacity: exhale,
}}
>
<Text
style={{
fontSize: 20,
fontWeight: "600",
}}
>
Exhale
</Text>
</Animated.View>
{[0, 1, 2, 3, 4, 5, 6, 7].map((item) => {
const rotation = move.interpolate({
inputRange: [0, 1],
outputRange: [`${item * 45}deg`, `${item * 45 + 180}deg`],
});
return (
<Animated.View
key={item}
style={{
opacity: 0.1,
backgroundColor: "purple",
width: circleWidth,
height: circleWidth,
borderRadius: circleWidth / 2,
...StyleSheet.absoluteFill,
transform: [
{
rotateZ: rotation,
},
{ translateX: translate },
{ translateY: translate },
],
}}
></Animated.View>
);
})}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
left: width / 4,
top: height / 4,
},
});