StudE-Frontend/App.tsx

79 lines
2.7 KiB
TypeScript
Raw Normal View History

import "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import { createDrawerNavigator } from "@react-navigation/drawer";
2023-07-03 21:22:31 +08:00
import { Provider } from "react-redux";
import store from "./src/features/redux/Store/Store";
import "react-native-reanimated";
import "react-native-gesture-handler";
2023-07-04 16:08:24 +08:00
import * as Linking from "expo-linking";
import CustomDrawerContent from "./src/components/DrawerSettings/CustomDrawerContent";
import DrawerScreenSettings from "./src/components/DrawerSettings/DrawerScreenSettings";
import Home from "./src/routes/Home/Home";
import Login from "./src/routes/Login/Login";
import Register from "./src/routes/Register/Register";
2023-07-03 23:19:36 +08:00
import Onboarding from "./src/routes/Onboarding/Onboarding";
import Revalidation from "./src/routes/Revalidation/Revalidation";
2023-07-04 16:08:24 +08:00
import Activation from "./src/routes/Activation/Activation";
2023-07-16 14:14:54 +08:00
import UserInfo from "./src/routes/UserInfo/UserInfo";
2023-07-04 16:08:24 +08:00
import { useState, useEffect } from "react";
2023-07-17 15:10:44 +08:00
import { QueryClientProvider, QueryClient } from "react-query";
2023-07-17 17:52:41 +08:00
import { StatusBar } from "expo-status-bar";
const Drawer = createDrawerNavigator();
2023-07-04 16:08:24 +08:00
const linking = {
prefixes: [Linking.makeUrl("/")],
config: {
screens: {
Home: "home",
Login: "login",
Register: "register",
Onboarding: "onboarding",
Revalidation: "revalidation",
Activation: "activation/:uid?/:token?",
NotFound: "*",
},
},
};
const queryClient = new QueryClient();
export default function App() {
2023-07-04 16:08:24 +08:00
const [initialRoute, setInitialRoute] = useState<string | null>(null);
useEffect(() => {
async function getInitialURL() {
const url = await Linking.getInitialURL();
if (url) {
setInitialRoute(url);
}
}
if (!initialRoute) {
getInitialURL();
}
}, [initialRoute]);
return (
2023-07-03 21:22:31 +08:00
<Provider store={store}>
2023-07-17 17:52:41 +08:00
<StatusBar style="light" />
<QueryClientProvider client={queryClient}>
<NavigationContainer linking={linking}>
<Drawer.Navigator
initialRouteName="Revalidation"
drawerContent={CustomDrawerContent}
screenOptions={DrawerScreenSettings}
>
<Drawer.Screen name="Home" component={Home} />
<Drawer.Screen name="Login" component={Login} />
<Drawer.Screen name="Register" component={Register} />
<Drawer.Screen name="Onboarding" component={Onboarding} />
<Drawer.Screen name="Revalidation" component={Revalidation} />
<Drawer.Screen name="Activation" component={Activation} />
2023-07-17 15:48:51 +08:00
<Drawer.Screen name="User Info" component={UserInfo} />
</Drawer.Navigator>
</NavigationContainer>
</QueryClientProvider>
2023-07-03 21:22:31 +08:00
</Provider>
);
}