-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
95 lines (86 loc) · 2.24 KB
/
App.js
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
import { StatusBar } from "expo-status-bar";
import { View, Platform, SafeAreaView, StyleSheet } from "react-native";
import Animated, { FadeInDown, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
import GameBoard from "./src/components/GameBoard";
import { colors } from "./src/constants";
import BG from "./assets/Screen.svg";
import LottieView from "lottie-react-native";
import { useRef, useState } from "react";
export default function App() {
const lottieRef = useRef(null);
const [_, setPlayCount] = useState(0);
const playConfetti = () => {
replayAnim(true);
};
const replayAnim = (reset) => {
setPlayCount((prevCount) => {
const nextCount = reset ? 0 : prevCount + 1;
if (nextCount < 2) {
lottieRef.current?.play();
}
return nextCount;
});
};
return (
<>
<BG style={styles.backdrop} />
<SafeAreaView style={[styles.container, styles.safeArea]}>
<StatusBar style="auto" />
<Animated.Text
entering={FadeInDown.duration(1000).delay(200)}
style={styles.title}
>
AQUAD
</Animated.Text>
<View style={styles.grid}>
<GameBoard size={5} onWin={playConfetti} />
</View>
{/* <Text style={styles.title}>omg it works-ish</Text> */}
</SafeAreaView>
{Platform.OS !== "web" && (
<LottieView
source={require("./assets/confetti.json")}
// autoPlay
loop={false}
style={styles.backdrop}
ref={lottieRef}
onAnimationFinish={() => replayAnim()}
/>
)}
</>
);
}
const styles = StyleSheet.create({
backdrop: {
position: "absolute",
left: 0,
top: 0,
right: 0,
bottom: 0,
height: "100%",
width: "100%",
pointerEvents: "none",
},
container: {
flex: 1,
alignItems: "center",
justifyContent: 'center',
},
safeArea: {
paddingTop: Platform.OS === "android" ? 25 : 0,
},
title: {
fontSize: 32,
letterSpacing: 7,
fontWeight: "bold",
color: colors.primary,
},
grid: {
// backgroundColor: "#f700ff",
flex: 1,
alignSelf: "stretch",
padding: 30,
justifyContent: "center",
alignItems: "center",
},
});