-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
104 lines (94 loc) · 2.96 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { StyleSheet } from "react-native";
import React from "react";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import {
SafeAreaProvider,
initialWindowMetrics,
} from "react-native-safe-area-context";
import { Provider as ModalProvider } from "#/modal/ModalProvider";
import { Provider as LightBoxProvider } from "#/lightbox/LightProvider";
import { StatusBar } from "expo-status-bar";
import { ApolloProvider } from "@apollo/client";
import { client } from "#/provider/ClientProvider";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Login from "#/screen/Login";
import More from "#/screen/More";
import Home from "#/screen/Home";
import { BottomBar } from "#/route/BottomBar";
import AppProvider from "#/provider/AppProvider";
import useApp from "#/hooks/useApp";
import Branch from "#/screen/Branch";
import UserDetail from "#/screen/UserDetail";
import { useFonts } from "expo-font";
import Notification from "#/screen/Notification";
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
const App = () => {
const [loaded, error] = useFonts({
"Inter-Black": require("./assets/fonts/Inter-Regular.ttf"),
});
if (!loaded && !error) {
return null;
}
return (
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<GestureHandlerRootView style={styles.gestureHandlerRootView}>
<ApolloProvider client={client}>
<ModalProvider>
<LightBoxProvider>
<StatusBar style={"dark"} />
<AppProvider>
<InnerApp />
</AppProvider>
</LightBoxProvider>
</ModalProvider>
</ApolloProvider>
</GestureHandlerRootView>
</SafeAreaProvider>
);
};
export default App;
function InnerApp() {
const { hasSession } = useApp();
if (!hasSession) {
return <Login />;
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="Main" component={MainStackScreens} />
<Stack.Screen name="Notification" component={Notification} />
<Stack.Screen name="Branch" component={Branch} />
<Stack.Screen name="UserDetail" component={UserDetail} />
</Stack.Navigator>
</NavigationContainer>
);
}
const MainStackScreens = () => {
const tabBar = React.useCallback(
(props: any) => <BottomBar {...props} />,
[]
);
return (
<Tab.Navigator
initialRouteName="HomeTab"
backBehavior="initialRoute"
screenOptions={{ headerShown: false }}
tabBar={tabBar}
>
<Tab.Screen name="HomeTab" component={Home} />
<Tab.Screen name="MoreTab" component={More} />
</Tab.Navigator>
);
};
const styles = StyleSheet.create({
gestureHandlerRootView: {
height: "100%",
},
});