-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
66 lines (57 loc) · 1.43 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
import React, { useEffect, useState } from 'react'
import { observer } from 'mobx-react'
import { DefaultTheme, Colors, Provider as PaperProvider, Theme } from 'react-native-paper'
import { NavigationContainer } from '@react-navigation/native'
import { RootNavigator } from './app/navigation/RootNavigator'
import { Provider, setupRootStore, useStore } from './app/model/Root'
import StorybookUIRoot from './storybook'
function App() {
const [rootStore, setRootStore] = useState(undefined)
useEffect(() => {
setupRootStore().then(setRootStore)
}, [])
if (!rootStore) {
return null
}
return (
<Provider value={rootStore}>
<AppWithTheme />
</Provider>
)
}
export const AppTheme: Theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: Colors.black,
accent: Colors.black,
background: Colors.white,
text: Colors.black,
}
}
export const AppThemeDark: Theme = {
...AppTheme,
dark: true,
colors: {
...AppTheme.colors,
primary: Colors.white,
accent: Colors.white,
background: Colors.black,
text: Colors.white,
}
}
const AppWithTheme = observer(() => {
const { app } = useStore()
const theme = app.theme === 'dark'
? AppThemeDark
: AppTheme
return (
<PaperProvider theme={theme}>
<NavigationContainer>
<RootNavigator />
</NavigationContainer>
</PaperProvider>
)
})
export default App
// export default StorybookUIRoot