-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWrapper.js
More file actions
69 lines (59 loc) · 2.01 KB
/
Copy pathWrapper.js
File metadata and controls
69 lines (59 loc) · 2.01 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
import BottomNavigator from "./components/BottomNavigator/BottomNavigator";
import { NativeBaseProvider } from "native-base";
import AppContext from "./Context/AppContext";
import { createTodayRow } from "./queries/tableSetup";
import React from "react";
import {
checkOnboarding,
setOnboardung,
setGoal,
setUnit,
} from "./utils/asyncStorage";
import FirstLaunch from "./screens/FirstLaunch/FirstLaunch";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
function Wrapper() {
const [firstLaunch, setFirstLaunch] = React.useState(null);
const { appState } = React.useContext(AppContext);
React.useEffect(() => {
async function fetchOnboardingData() {
const onboarding = await checkOnboarding();
await setGoal("2500");
await setUnit();
// Set onboarding === true to false after testing
// if (onboarding === "false") {
if (onboarding === "true") {
setFirstLaunch(false);
await setOnboardung();
createTodayRow();
} else {
setFirstLaunch(false);
}
}
fetchOnboardingData();
}, [appState]);
const { statusBarColor } = React.useContext(AppContext);
return (
firstLaunch != null && (
<Stack.Navigator
screenOptions={{
cardStyle: { backgroundColor: "red" },
}}
>
{firstLaunch && (
<Stack.Screen
options={{ headerShown: false }}
name="Onboarding"
component={FirstLaunch}
/>
)}
<Stack.Screen
name="Home"
options={{ headerShown: false }}
component={BottomNavigator}
/>
</Stack.Navigator>
)
);
}
export default Wrapper;