-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
70 lines (63 loc) · 2.52 KB
/
App.js
File metadata and controls
70 lines (63 loc) · 2.52 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
import React, { useState, useEffect } from "react";
import { Text, View, ActivityIndicator } from "react-native";
import { ThemeProvider } from "react-native-rapi-ui";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { Provider } from "react-native-paper";
import { auth } from "./firebase"; // Import Firebase Auth
import { onAuthStateChanged } from "firebase/auth";
import LoginScreen from "./screens/LoginScreen";
import RegisterScreen from "./screens/RegisterScreen";
import ForgotPassword from "./screens/ForgotPassword";
import HomeScreen from "./screens/HomeScreen";
import AddScreen from "./screens/AddScreen";
import UpdateScreen from "./screens/UpdateScreen";
import AllTransactions from "./screens/AllTransactions";
import SettingsScreen from "./screens/SettingsScreen";
const Stack = createStackNavigator();
export default function App() {
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, (authenticatedUser) => {
setTimeout(() => {
setUser(authenticatedUser);
setLoading(false); // Finish loading after auth state check + delay
}, 2000); // **2-second delay**
});
return () => unsubscribe(); // Cleanup listener
}, []);
if (loading) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator size="large" color="#0000ff" />
<Text>Setting Things Up...</Text>
</View>
);
}
return (
<ThemeProvider>
<NavigationContainer>
<Provider>
<Stack.Navigator>
{user ? (
<>
<Stack.Screen name="HomeScreen" component={HomeScreen} />
<Stack.Screen name="AddScreen" component={AddScreen} />
<Stack.Screen name="UpdateScreen" component={UpdateScreen} />
<Stack.Screen name="AllTransactions" component={AllTransactions} />
<Stack.Screen name="SettingsScreen" component={SettingsScreen} />
</>
) : (
<>
<Stack.Screen name="LoginScreen" component={LoginScreen} />
<Stack.Screen name="RegisterScreen" component={RegisterScreen} />
<Stack.Screen name="ForgotPassword" component={ForgotPassword} />
</>
)}
</Stack.Navigator>
</Provider>
</NavigationContainer>
</ThemeProvider>
);
}