-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
59 lines (48 loc) · 1.7 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
import 'react-native-get-random-values';
import { ThemeProvider } from 'styled-components/native'
import { StatusBar } from 'react-native';
import { AppProvider, UserProvider } from '@realm/react'
import { useFonts, Roboto_400Regular, Roboto_700Bold } from '@expo-google-fonts/roboto'
import theme from './src/theme';
import { REALM_APP_ID } from '@env'
import { Loading } from './src/components/Loading';
import { SignIn } from './src/screens/SignIn';
import { Routes } from './src/routes';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { RealmProvider, syncConfig } from './src/libs/realm';
import './src/libs/dayjs';
import { WifiSlash } from 'phosphor-react-native';
import { TopMessage } from './src/components/TopMessage';
import { useNetInfo } from '@react-native-community/netinfo';
export default function App() {
const [fontsLoaded] = useFonts({ Roboto_400Regular, Roboto_700Bold })
const netInfo = useNetInfo();
if (!fontsLoaded) {
return (
<>
<Loading />
</>
)
}
return (
<AppProvider id={REALM_APP_ID}>
<ThemeProvider theme={theme} >
<SafeAreaProvider style={{ backgroundColor: theme.COLORS.GRAY_800 }}>
{
!netInfo.isConnected &&
<TopMessage
title='Você está off-line'
icon={WifiSlash}
/>
}
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent />
<UserProvider fallback={SignIn} >
<RealmProvider sync={syncConfig} fallback={Loading}>
<Routes />
</RealmProvider>
</UserProvider>
</SafeAreaProvider>
</ThemeProvider>
</AppProvider>
);
}