You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
import Navigation from './Navigation';
|
|
import { StyleSheet,SafeAreaView } from 'react-native';
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
import StartNavigation from './StartNavigation';
|
|
import { Provider, useDispatch, useSelector } from 'react-redux';
|
|
import store from '../redux/store';
|
|
import { useCallback, useEffect } from 'react';
|
|
import * as SplashScreen from 'expo-splash-screen';
|
|
import { View } from 'react-native';
|
|
import { getRefreshToken } from '../redux/thunk/authThunk';
|
|
|
|
SplashScreen.preventAutoHideAsync();
|
|
|
|
export default function AuthNavigation() {
|
|
//@ts-ignore
|
|
const appIsReady : boolean = useSelector(state => state.userReducer.loading);
|
|
//@ts-ignore
|
|
const isLogin : boolean = useSelector(state => state.userReducer.isLogedIn);
|
|
// const userToken : string = useSelector(state => state.userReducer.userFladToken);
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
useEffect(() => {
|
|
async function prepare() {
|
|
console.log(appIsReady, "1 AuthNav")
|
|
|
|
//@ts-ignore
|
|
await dispatch(getRefreshToken())
|
|
await SplashScreen.hideAsync();
|
|
}
|
|
prepare();
|
|
}, [dispatch]);
|
|
|
|
const onStackRootView = useCallback(async () => {
|
|
if (appIsReady) {
|
|
await SplashScreen.hideAsync();
|
|
}
|
|
}, [appIsReady]);
|
|
|
|
if (appIsReady == false) {
|
|
console.log(appIsReady, "T9 AuthNav")
|
|
return null;
|
|
}
|
|
console.log(appIsReady, "k9 AuthNav")
|
|
// console.log(userToken, "k9 AuthNav")
|
|
return (
|
|
<>
|
|
{isLogin ? (
|
|
/* {userToken != null ? ( */
|
|
<SafeAreaProvider>
|
|
<Navigation/>
|
|
</SafeAreaProvider>
|
|
|
|
) :
|
|
<SafeAreaProvider >
|
|
<StartNavigation/>
|
|
</SafeAreaProvider>
|
|
}
|
|
</>
|
|
)
|
|
}
|