-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
57 lines (54 loc) · 1.79 KB
/
App.js
File metadata and controls
57 lines (54 loc) · 1.79 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
import React, { useRef, useState } from "react";
import { StatusBar } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import TodoItemsContext from "./contexts/TodoItemsContext";
import { createStackNavigator } from "@react-navigation/stack";
import cuid from "cuid";
import IntroScreen from "./screens/IntroScreen";
import DropdownAlertContext from "./contexts/DropdownAlertContext";
import DropdownAlert from "react-native-dropdownalert";
import UserContext from "./contexts/UserContext";
import RootNavigator from "./navigation/RootNavigator";
const Stack = createStackNavigator();
export default function App() {
const [welcomeScreenDone, setWelcomeScreenDone] = useState(false);
const [user, setUser] = useState({
remainingDeletions: 1,
adPosition: 0,
password: "",
});
const [todos, setTodos] = useState([
{
name: "Example To-do",
id: cuid().slice(-6),
},
{
name: "Delete me!",
id: cuid().slice(-6),
},
{
name: "This is what a todo looks like.",
id: cuid().slice(-6),
},
]);
const dropdownAlertRef = useRef();
return (
<NavigationContainer>
{welcomeScreenDone ? (
<>
<StatusBar barStyle={"dark-content"} backgroundColor={"#ffffff"} />
<DropdownAlertContext.Provider value={{ dropdownAlertRef }}>
<TodoItemsContext.Provider value={{ todos, setTodos }}>
<UserContext.Provider value={{ user, setUser }}>
<RootNavigator />
</UserContext.Provider>
</TodoItemsContext.Provider>
<DropdownAlert ref={dropdownAlertRef} />
</DropdownAlertContext.Provider>
</>
) : (
<IntroScreen onDone={() => setWelcomeScreenDone(true)} />
)}
</NavigationContainer>
);
}