-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
77 lines (72 loc) · 2.36 KB
/
App.js
File metadata and controls
77 lines (72 loc) · 2.36 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
import { StatusBar } from "expo-status-bar";
import {
StyleSheet,
Text,
View,
Vibration,
ActivityIndicator,
} from "react-native";
// import { PaperProvider } from "react-native-paper";
import { NavigationContainer } from "@react-navigation/native";
// import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
// import * as Haptics from "expo-haptics";
// import * as Speech from "expo-speech";
// import Ionicons from "react-native-vector-icons/Ionicons";
// import { LocationProvider } from "./context/LocationContext";
// import Home from "./screeens/Home";
// import Contact from "./screeens/Contact";
// import UserProfile from "./screeens/UserProfile";
// import Drivers from "./screeens/Drivers";
// import DriverDetails from "./screeens/DriverDetails";
// import JourneyDetails from "./screeens/JourneyDetails";
// import Register from "./screeens/Register";
// import Login from "./screeens/Login";
// import Welcome from "./screeens/Welcome";
// import Settings from "./screeens/Settings";
import { app, auth } from "./firebaseConfig";
import { onAuthStateChanged } from "firebase/auth";
import WelcomeStackScreen from "./navigation/WelcomeStackScreen";
import TabNavigator from "./navigation/TabNavigator";
import { useEffect, useState } from "react";
const Stack = createNativeStackNavigator();
export default function App() {
const [loading, setLoading] = useState(true);
const [user, setUser] = useState(false);
useEffect(() => {
onAuthStateChanged(auth, (user) => {
if (user) {
setUser(true);
} else {
setUser(false);
}
setLoading(false);
});
}, []);
if (loading) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator size="large" color="#00ff00" />
</View>
);
}
return (
<NavigationContainer>
<Stack.Navigator>
{!user ? (
<Stack.Screen
name="Welcome"
component={WelcomeStackScreen}
options={{ headerShown: false }}
/>
) : (
<Stack.Screen
name="Root"
component={TabNavigator}
options={{ headerShown: false }}
/>
)}
</Stack.Navigator>
</NavigationContainer>
);
}