-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
63 lines (52 loc) · 1.75 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
import React from 'react';
import { configureFonts, Provider as PaperProvider } from 'react-native-paper';
import { Provider as StoreProvider } from 'react-redux';
import { NavigationContainer } from '@react-navigation/native';
import { StatusBar } from 'expo-status-bar';
import { useNetInfo } from '@react-native-community/netinfo';
import {
Ubuntu_300Light,
Ubuntu_400Regular,
Ubuntu_500Medium,
Ubuntu_700Bold,
useFonts,
} from '@expo-google-fonts/ubuntu';
import AppLoading from 'expo-app-loading';
import Toast from 'react-native-toast-message';
import numbro from 'numbro';
import { store } from './app/src/store';
import { appTheme, navigationTheme } from './app/src/core/configs/theme';
import fontConfig from './app/src/core/configs/fonts';
import OfflineNotice from './app/src/views/common/OfflineNotice';
import NavigatorsMediator from './app/src/views/navigators/NavigatorsMediator';
numbro.setLanguage('en-US');
const App: React.FC = () => {
const netInfo = useNetInfo();
const [fontsLoaded, error] = useFonts({
Ubuntu_300Light,
Ubuntu_400Regular,
Ubuntu_500Medium,
Ubuntu_700Bold,
});
if (error) {
console.error({ fontError: error });
}
const noInternet =
netInfo.type !== 'unknown' && netInfo.isInternetReachable === false;
if (!fontsLoaded) {
return <AppLoading />;
}
return (
<StoreProvider store={store}>
<PaperProvider theme={{ ...appTheme, fonts: configureFonts(fontConfig) }}>
{noInternet && <OfflineNotice />}
<StatusBar style="auto" />
<NavigationContainer theme={navigationTheme}>
<NavigatorsMediator />
</NavigationContainer>
<Toast topOffset={noInternet ? 100 : 40} />
</PaperProvider>
</StoreProvider>
);
};
export default App;