Files
Final-Year-Project/MobileApp/app/index.tsx

37 lines
778 B
TypeScript

import { Redirect } from 'expo-router';
import React from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
import { useApp } from '@/src/app-context';
export default function IndexRoute() {
const { ready, state } = useApp();
if (!ready) {
return (
<View style={styles.loading}>
<ActivityIndicator color="#60a5fa" size="large" />
</View>
);
}
if (!state.session?.session) {
return <Redirect href={'/auth' as any} />;
}
if (!state.deviceToken) {
return <Redirect href={'/onboarding' as any} />;
}
return <Redirect href="/(tabs)" />;
}
const styles = StyleSheet.create({
loading: {
flex: 1,
backgroundColor: '#0a0a0c',
alignItems: 'center',
justifyContent: 'center',
},
});