-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
98 lines (90 loc) · 2.4 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
import Animated, {
FadeIn,
FadeInLeft,
FadeInRight,
FadeOutLeft,
FadeOutRight,
Layout,
useAnimatedStyle,
useSharedValue,
withTiming,
} from "react-native-reanimated";
import { useEffect, useState } from "react";
import { Button, Pressable, StyleSheet, View } from "react-native";
import { COLORS } from "./constants";
import { LoadingIndicator } from "./components";
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
export default function App() {
const [loading, setLoading] = useState(true);
const rLoading = useSharedValue(true);
useEffect(() => {
rLoading.value = loading;
}, [loading]);
const containerStyle = useAnimatedStyle(() => {
return {
backgroundColor: withTiming(
rLoading.value ? COLORS.lightBlue : COLORS.lightGreen
),
};
}, []);
const textStyle = useAnimatedStyle(() => {
return {
color: withTiming(rLoading.value ? COLORS.darkBlue : COLORS.green),
};
}, []);
return (
<View style={styles.container}>
<AnimatedPressable
onPress={() => setLoading((prev) => !prev)}
layout={Layout.springify().damping(14)}
style={[
{
padding: 16,
borderRadius: 100,
flexDirection: "row",
},
containerStyle,
]}
>
<Animated.View style={{ marginRight: 8 }} entering={FadeIn}>
<LoadingIndicator enabled={loading} />
</Animated.View>
{loading ? (
<Animated.Text
style={[styles.txt, textStyle]}
entering={FadeInLeft.delay(150).duration(150)}
exiting={FadeOutLeft.duration(100)}
>
Analyzing
</Animated.Text>
) : null}
<Animated.Text layout={Layout} style={[styles.txt, textStyle]}>
{" "}
Transaction{" "}
</Animated.Text>
{!loading ? (
<Animated.Text
style={[styles.txt, textStyle]}
entering={FadeInRight.delay(150).duration(150)}
exiting={FadeOutRight.duration(100)}
>
Safe
</Animated.Text>
) : null}
</AnimatedPressable>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
txt: {
fontSize: 18,
fontWeight: "bold",
color: COLORS.darkBlue,
},
});