-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
58 lines (48 loc) · 1.37 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
import { StatusBar } from 'expo-status-bar';
import React, { useRef } from 'react';
import { StyleSheet, View } from 'react-native';
import Animated, { Clock, Easing, block, cond, not, set, eq } from "react-native-reanimated";
import Logo from "./Logo";
const {timing, useCode, startClock} = Animated;
const runProgress = (clock: Clock) => {
const state = {
finished: new Animated.Value(0),
position: new Animated.Value(0),
frameTime: new Animated.Value(0),
time: new Animated.Value(0)
};
const config = {
toValue: new Animated.Value(1),
duration: 5000,
easing: Easing.inOut(Easing.ease)
};
return block([
timing(clock, state, config),
cond(eq(state.finished, 1), [
set(state.finished, 0),
set(state.frameTime, 0),
set(state.time, 0),
set(config.toValue, not(state.position))
]),
state.position
])
}
export default function App() {
const clock = useRef(new Clock()).current;
const progress = useRef(new Animated.Value(5)).current;
useCode(() => [startClock(clock), set(progress, runProgress(clock))], []);
return (
<View style={styles.container}>
<Logo progress={progress}/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#16181d',
alignItems: 'center',
justifyContent: 'center',
},
});