-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathApp.tsx
48 lines (39 loc) · 1.39 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
import 'react-native-get-random-values'; // react native moment
import {useEffect, useState} from 'react';
import {StyleSheet} from 'react-native';
import {ErrorBoundary} from 'react-error-boundary';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {setFunction} from '@clerotri/Generic';
import {MainView} from '@clerotri/MainView';
import {ErrorMessage} from '@clerotri/components/ErrorMessage';
import {initialiseSettings} from '@clerotri/lib/storage/utils';
import {themes, Theme, ThemeContext} from '@clerotri/lib/themes';
export const App = () => {
const [theme, setTheme] = useState<Theme>(themes.Dark);
const localStyles = generateLocalStyles(theme);
setFunction('setTheme', (themeName: string) => {
const newTheme = themes[themeName] ?? themes.Dark;
setTheme(newTheme);
});
useEffect(() => {
initialiseSettings();
}, []);
return (
<GestureHandlerRootView style={localStyles.outer}>
<ThemeContext.Provider
value={{currentTheme: theme, setCurrentTheme: setTheme}}>
{/* <ErrorBoundary fallbackRender={ErrorMessage}> */}
<MainView />
{/* </ErrorBoundary> */}
</ThemeContext.Provider>
</GestureHandlerRootView>
);
};
const generateLocalStyles = (currentTheme: Theme) => {
return StyleSheet.create({
outer: {
flex: 1,
backgroundColor: currentTheme.backgroundPrimary,
},
});
};