diff --git a/App.tsx b/App.tsx
index 5d69b5f..392327a 100644
--- a/App.tsx
+++ b/App.tsx
@@ -4,6 +4,7 @@ import AppNavigator from "./src/navigation/app-navigator";
import { DEV_USER_ID } from "@env";
import AsyncStorage from "@react-native-async-storage/async-storage";
+import Loading from "./src/lib/loading";
// TODO: move to different file?
const SetAuthHeaderBasedOnEnv = () => {
@@ -33,8 +34,10 @@ const SetAuthHeaderBasedOnEnv = () => {
const App: React.FC = () => {
return (
-
-
+
+
+
+
);
};
diff --git a/package.json b/package.json
index b9b2cbd..e267be4 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "NODE_ENV=development && expo start",
+ "start:test": "NODE_ENV=test && expo start",
"start:android": "expo start --android",
"start:ios": "expo start --ios",
"android": "expo run:android",
@@ -11,7 +12,7 @@
"android:test": "node ./start.js test",
"ios": "expo run:ios",
"ios:dev": "NODE_ENV=development expo run:ios",
- "ios:prod": "NODE_ENV=production expo run:ios",
+ "ios:test": "NODE_ENV=test expo run:ios",
"web": "expo start --web",
"lint": "eslint . --ext .js,.ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
diff --git a/src/lib/loading/index.tsx b/src/lib/loading/index.tsx
new file mode 100644
index 0000000..ebf72dc
--- /dev/null
+++ b/src/lib/loading/index.tsx
@@ -0,0 +1,36 @@
+import React, { createContext, useEffect, useState } from 'react';
+import { ActivityIndicator, StyleSheet, View } from 'react-native';
+
+import { colors } from '../../styles';
+import AsyncStorage from '@react-native-async-storage/async-storage';
+
+const LoadingContext = createContext(false);
+
+export default function Loading({ children }) {
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ const checkHasToken = async () => {
+ const hasToken = await AsyncStorage.getItem('token');
+ // needs to connect to app state
+ return hasToken
+ }
+
+ checkHasToken()
+ .then(() => setLoading(false))
+ }, []);
+
+ if (!loading) {
+ return {children};
+ }
+
+ return (
+
+
+
+ );
+}
+
+const s = StyleSheet.create({
+ container: { flex: 1, justifyContent: 'center', alignItems: 'center' }
+});
\ No newline at end of file
diff --git a/src/navigation/app-navigator.tsx b/src/navigation/app-navigator.tsx
index 32ea4ce..4935613 100644
--- a/src/navigation/app-navigator.tsx
+++ b/src/navigation/app-navigator.tsx
@@ -8,6 +8,7 @@ import { useColorScheme } from "react-native";
import Login from "../screens/login";
import Tabs from "./tab-navigator";
+import AsyncStorage from "@react-native-async-storage/async-storage";
const Stack = createNativeStackNavigator();
@@ -18,11 +19,6 @@ const ScreensStack = () => (
component={Tabs}
options={{ headerShown: false }}
/>
-
);
/**
@@ -35,11 +31,27 @@ const ScreensStack = () => (
export default function AppNavigator(): React.JSX.Element {
// useColorScheme get's the theme from device settings
const scheme = useColorScheme();
+ const getToken = async () => {
+ const token = await AsyncStorage.getItem('token')
+ console.log('token', token)
+ return token
+ }
+
return (
-
+ {getToken ? (
+
+ ) : (
+
+ )}
+
+
);