-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
55 lines (48 loc) · 1.49 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
import React from 'react';
import {
View,
Text,
ActivityIndicator
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import * as API from './data/_data'
import Home from './views/Home'
import IndividualDeck from './views/IndividualDeck'
import Quiz from './views/Quiz'
import NewQuestion from './views/NewQuestion'
import Results from './views/Results'
import { getInitialAppPermissions, scheduleNotification } from './utils/notifications'
// create navigation
const Stack = createStackNavigator()
const App = () => {
const [fetching, setFetching] = React.useState(true)
React.useEffect(() => {
API.initStorage()
API.getDecks()
.then(res => {
console.log('[SERVER RES]', res)
setFetching(false)
})
.catch(e => console.error(e))
getInitialAppPermissions()
scheduleNotification()
}, [fetching])
return (
<>
{fetching && <ActivityIndicator size='large' />}
{!fetching && (
<NavigationContainer>
<Stack.Navigator initialRouteName='Home'>
<Stack.Screen name='Home' component={Home} />
<Stack.Screen name='Individual Deck' component={IndividualDeck} />
<Stack.Screen name='Quiz' component={Quiz} />
<Stack.Screen name='Add Question' component={NewQuestion} />
<Stack.Screen name='Results' component={Results} />
</Stack.Navigator>
</NavigationContainer>
)}
</>
)
}
export default App;