-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.jsx
50 lines (41 loc) · 1.17 KB
/
App.jsx
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
import { useFonts } from 'expo-font';
import { useSnapshot } from 'valtio';
import React, { useEffect } from 'react';
import { Platform, StatusBar } from 'react-native';
import { store } from './store/store';
import NavigationContainer from './components/NavigationContainer';
import { isDarkMode, storage } from './utils/mmkv';
import ThemeWrapper from './components/ThemeWrapper';
if (Platform.OS === 'android') {
StatusBar.setTranslucent(true);
StatusBar.setBackgroundColor('transparent');
}
const App = () => {
const [fontsLoaded] = useFonts({
MontserratRegular: require('./assets/fonts/Montserrat-Regular.ttf'),
MontserratBold: require('./assets/fonts/Montserrat-Bold.ttf'),
});
const { mode, isAnimating } = useSnapshot(store);
const onToggle = () => {
store.isAnimating = !store.isAnimating;
storage.set('isDarkMode', !isDarkMode());
};
useEffect(() => {
if (isDarkMode()) {
store.mode = 'dark';
}
}, []);
if (fontsLoaded) {
return (
<ThemeWrapper mode={mode} isAnimating={isAnimating}>
<NavigationContainer
mode={mode}
isAnimating={isAnimating}
onPress={onToggle}
/>
</ThemeWrapper>
);
}
return null;
};
export default App;