-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
86 lines (75 loc) · 2.13 KB
/
Copy pathApp.js
File metadata and controls
86 lines (75 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// App.js - Updated with Supabase authentication
import React from 'react';
import {
StyleSheet,
View,
Text,
ActivityIndicator,
LogBox,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import BottomTabNavigator from './navigation/BottomTabNavigator';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { PaperProvider } from 'react-native-paper';
import { AuthProvider, useAuth } from './context/AuthContext';
import AuthScreen from './screens/AuthScreen'; // We'll create this
// Display logs in-app
LogBox.ignoreAllLogs(false);
LogBox.ignoreLogs(['specific warning to ignore']);
console.log('App starting with Supabase authentication');
// Loading component
const LoadingScreen = () => (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" color="#7B5AFF" />
<Text style={styles.loadingText}>Loading DormX...</Text>
</View>
);
// Main navigation component that checks auth state
const AppNavigator = () => {
const { user, loading, initialized, isFullyAuthenticated } = useAuth();
console.log('Auth state:', { user: !!user, isFullyAuthenticated, loading, initialized });
// Show loading screen while initializing
if (!initialized || loading) {
return <LoadingScreen />;
}
// // Show auth screen if not logged in
// if (!isLoggedIn) {
// return <AuthScreen />;
// }
// Show auth screen if not fully authenticated (includes onboarding)
if (!isFullyAuthenticated) {
return <AuthScreen />;
}
// Show main app if logged in
return (
<NavigationContainer>
<BottomTabNavigator />
</NavigationContainer>
);
};
// Root App component
export default function App() {
return (
<PaperProvider>
<SafeAreaProvider>
<AuthProvider>
<AppNavigator />
</AuthProvider>
</SafeAreaProvider>
</PaperProvider>
);
}
const styles = StyleSheet.create({
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f5f5f5',
},
loadingText: {
marginTop: 16,
fontSize: 16,
fontWeight: '500',
color: '#7B5AFF',
},
});