-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
106 lines (96 loc) · 3.95 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
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
96
97
98
99
100
101
102
103
104
105
106
import Amplify from 'aws-amplify'
import React, { useState } from 'react'
import MainScreen from './src/screens/mainscreen'
import awsconfig from './src/custom-aws-exports'
import {
PausedIdsContext,
ShownIdsContext,
DbContext,
AudioPlayerContext,
FlaggedIdsContext,
} from './store/contexts/contexts'
import { NavigationContainer } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import AudioCardScreen from './src/screens/audiocardscreen'
import PlayerScreen from './src/screens/playerscreen'
import { Auth } from '@aws-amplify/auth'
// Analytics is explicitly disabled to prevent a warning according to following:
// https://github.com/aws-amplify/amplify-js/issues/5918
Amplify.configure({
...awsconfig,
Analytics: {
disabled: true,
},
})
Auth.configure(awsconfig)
// FIXME: Why is this order needed? Does the db has excess dependencies here?
import { withAuthenticator } from 'aws-amplify-react-native/dist/Auth'
import { HocDb } from './src/backend/database'
import { NAVIGATION } from './src/screens/navigationutils'
import { AudioPlayer } from './src/audio/AudioPlayer'
import { ThemeProvider } from 'react-native-elements'
import { sc } from './src/uicomponents/style'
const Stack = createNativeStackNavigator()
const theme = {
Button: {
titleStyle: {
color: 'white',
},
buttonStyle: {
backgroundColor: sc.colors.green,
},
},
}
const App = ({ _signOut, _user }) => {
const [pausedIds, setPausedIds] = useState([])
const [shownIds, setShownIds] = useState([])
const [db, setDb] = useState(new HocDb())
const [audioPlayer, setAudioPlayer] = useState(new AudioPlayer())
const [flaggedIds, setFlaggedIds] = useState([])
return (
<PausedIdsContext.Provider
value={{
pausedIds,
setPausedIds: setPausedIds,
}}
>
<ShownIdsContext.Provider value={{ shownIds, setShownIds }}>
<DbContext.Provider value={{ db, setDb }}>
<AudioPlayerContext.Provider
value={{ audioPlayer, setAudioPlayer }}
>
<FlaggedIdsContext.Provider
value={{ flaggedIds, setFlaggedIds }}
>
<ThemeProvider theme={theme}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name={NAVIGATION.main}
component={MainScreen}
options={{
title: 'Categories',
}}
/>
<Stack.Screen
name={NAVIGATION.audioList}
options={{ title: 'Audio entries' }}
component={AudioCardScreen}
/>
<Stack.Screen
name={NAVIGATION.audioPlayer}
options={{ title: 'Audio player' }}
component={PlayerScreen}
/>
</Stack.Navigator>
</NavigationContainer>
</ThemeProvider>
</FlaggedIdsContext.Provider>
</AudioPlayerContext.Provider>
</DbContext.Provider>
</ShownIdsContext.Provider>
</PausedIdsContext.Provider>
)
}
// export default App
export default withAuthenticator(App)