-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.tsx
50 lines (44 loc) · 1.4 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
import "react-native-gesture-handler";
import "expo-dev-client";
import { ThemeProvider, createTheme } from "@rneui/themed";
import { SafeAreaView } from "react-native-safe-area-context";
import { NavigationContainer } from "@react-navigation/native";
import { Routes } from "./src/Routes";
import {
QueryClient,
QueryClientProvider,
focusManager,
} from "@tanstack/react-query";
import { useAppState } from "@/hooks/useAppState";
import { AppStateStatus, Platform } from "react-native";
import { useOnlineManager } from "@/hooks/useOnlineManager";
import { lightColors } from "./src/styles/theme";
import { StatusBar } from "expo-status-bar";
const theme = createTheme({
mode: "light",
lightColors: lightColors,
});
const queryClient = new QueryClient();
function onAppStateChange(status: AppStateStatus) {
// React Query already supports in web browser refetch on window focus by default
if (Platform.OS !== "web") {
focusManager.setFocused(status === "active");
}
}
const App = () => {
useOnlineManager();
useAppState(onAppStateChange);
return (
<QueryClientProvider client={queryClient}>
<NavigationContainer>
<ThemeProvider theme={theme}>
<StatusBar style="dark" />
<SafeAreaView style={{ flex: 1 }}>
<Routes />
</SafeAreaView>
</ThemeProvider>
</NavigationContainer>
</QueryClientProvider>
);
};
export default App;