Skip to content

Commit

Permalink
[refacto]: replace expo-router by react navigation (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
llucasspot authored Jan 21, 2024
1 parent fc57766 commit f400121
Show file tree
Hide file tree
Showing 37 changed files with 474 additions and 584 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Branchement au backend :

```
├── ...
├── app/ : points d'entrée pour la navigation expo-router
└── src
├── api/
├── assets/
Expand Down
64 changes: 64 additions & 0 deletions expo-boomboomapp/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import FontAwesome from "@expo/vector-icons/FontAwesome";
import { NavigationContainer } from "@react-navigation/native";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useFonts } from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import * as React from "react";
import { useEffect } from "react";

import { useInitializedApp } from "./src/hooks/useInitializedApp";
import { AuthStackNavigator } from "./src/navigation/AuthStack/AuthStackNavigator";
import { RegisterStackNavigator } from "./src/navigation/RegisterStackScreenNavigator/RegisterStackNavigator";
import { RootStackNavigator } from "./src/navigation/RootStackScreenNavigator/RootStackNavigator";
import ServiceInterface from "./src/tsyringe/ServiceInterface";
import { getGlobalInstance } from "./src/tsyringe/diUtils";

import "./src/tsyringe/tsyringe.config";
import AppService from "./src/services/AppService/AppService";

const queryClient = new QueryClient();

export default function WrappedApp() {
return (
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
);
}

function App() {
const [loaded, error] = useFonts({
SpaceMono: require("./assets/fonts/SpaceMono-Regular.ttf"),
...FontAwesome.font,
});
const { isAppInitialized } = useInitializedApp();
const appService = getGlobalInstance<AppService>(ServiceInterface.AppService);
const app = appService.useApp();

const Stack = () => {
if (!app.isAuthenticated) {
return <AuthStackNavigator />;
}
if (app.isProfileComplete) {
return <RootStackNavigator />;
}
return <RegisterStackNavigator />;
};

useEffect(() => {
if (!loaded || !isAppInitialized) {
return;
}
SplashScreen.hideAsync();
}, [loaded, isAppInitialized]);

if (!loaded || !isAppInitialized) {
return null;
}

return (
<NavigationContainer>
<Stack />
</NavigationContainer>
);
}
4 changes: 1 addition & 3 deletions expo-boomboomapp/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router"
],
"plugins": [],
"experiments": {
"typedRoutes": true
}
Expand Down
65 changes: 0 additions & 65 deletions expo-boomboomapp/app/(splash)/index.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions expo-boomboomapp/app/+html.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions expo-boomboomapp/app/NoneScreen.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions expo-boomboomapp/app/Registration.tsx

This file was deleted.

40 changes: 0 additions & 40 deletions expo-boomboomapp/app/[...missing].tsx

This file was deleted.

72 changes: 0 additions & 72 deletions expo-boomboomapp/app/_layout.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions expo-boomboomapp/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module.exports = function (api) {
return {
presets: ["babel-preset-expo"],
plugins: [
// Required for expo-router
"expo-router/babel",
// Required for tsyringe
"babel-plugin-transform-typescript-metadata",
["@babel/plugin-proposal-decorators", { legacy: true }],
Expand Down
2 changes: 1 addition & 1 deletion expo-boomboomapp/fix.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require("fs");
const path = require("path");

const FILE_PATH = path.join(__dirname, "./node_modules/expo-router/entry.js");
const FILE_PATH = path.join(__dirname, "./node_modules/expo/AppEntry.js");

const checkFileExists = (filePath: string) => {
if (!fs.existsSync(filePath)) {
Expand Down
Loading

0 comments on commit f400121

Please sign in to comment.