-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
49 lines (43 loc) · 1.56 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
import NetInfo from "@react-native-community/netinfo";
import { NavigationContainer } from "@react-navigation/native";
import React, { useState } from "react";
import { SafeAreaView, SafeAreaProvider } from "react-native-safe-area-context";
import { registerRootComponent } from "expo";
import { NativeWindStyleSheet } from "nativewind";
import RootNagivator from "./navigators";
import { Text } from "react-native";
// TODO: Write down the API keys on eas.json and configure proper private keys
// TODO: Add animations using React native reanimated
// Setting Native wind as default CSS Style - including for web
NativeWindStyleSheet.setOutput({
default: "native",
});
export default function App() {
// Handles Network Change
const [network, setNetwork] = useState<boolean>(true);
const unsubscribe = NetInfo.addEventListener((state) => {
if (state.isConnected) {
// Have Internet
if (network === false) setNetwork(true);
} else {
// Don't have Internet
if (network === true) setNetwork(false);
}
});
return (
<SafeAreaProvider className=" h-full w-full bg-gray-100">
<SafeAreaView className="h-full w-full bg-gray-100">
<NavigationContainer>
{/* TODO: Add an Absolute Badge when network is disconnected */}
{!network && (
<Text className="absolute z-50 mt-12 bg-red-500/80 font-bold p-2">
No Internet
</Text>
)}
<RootNagivator />
</NavigationContainer>
</SafeAreaView>
</SafeAreaProvider>
);
}
registerRootComponent(App);