-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
68 lines (62 loc) · 2 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
import { StatusBar } from "expo-status-bar";
import { SafeAreaProvider } from "react-native-safe-area-context";
import useCachedResources from "./hooks/useCachedResources";
import useColorScheme from "./hooks/useColorScheme";
import Navigation from "./navigation";
import React, { useState, useEffect } from "react";
import * as eva from "@eva-design/eva";
import { ApplicationProvider } from "@ui-kitten/components";
import AnimatedSnow from "./screens/AnimatedSnow";
import { StyleSheet, Dimensions } from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import snowWeather from "./constants/snowWeather";
import snowData from "./constants/snowData";
const { height, width } = Dimensions.get("window");
const storagekey = "storage";
export default function App() {
const isLoadingComplete = useCachedResources();
const colorScheme = useColorScheme();
const [showSplash, setShowSplash] = useState(false);
useEffect(() => {
getMyObject();
setTimeout(() => {
setShowSplash(true);
}, 4500);
}, []);
const getMyObject = async () => {
var db;
try {
await AsyncStorage.getItem(storagekey, (error, result) => {
if (result !== null && result !== "[]" && result !== undefined) {
} else {
db = snowData.concat(snowWeather);
AsyncStorage.setItem(storagekey, JSON.stringify(db));
}
});
} catch (e) {
console.log(e);
}
};
if (!isLoadingComplete) {
return null;
} else {
return showSplash == false ? (
<AnimatedSnow data-at="elementTestId" style={styles.snowContainer} />
) : (
<ApplicationProvider data-at="elementTestId" {...eva} theme={eva.dark}>
<SafeAreaProvider>
<Navigation colorScheme={colorScheme} />
<StatusBar />
</SafeAreaProvider>
</ApplicationProvider>
);
}
}
const styles = StyleSheet.create({
snowContainer: {
position: "absolute",
width: width,
height: height,
backgroundColor: "#000000",
},
});