-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
74 lines (67 loc) · 2.54 KB
/
App.js
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
import { StatusBar } from "expo-status-bar";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Restaurant from "./screens/Restaurant";
import { Provider } from "react-redux";
import { store } from "./store";
import Cart from "./screens/Cart";
import BottomTab from "./screens/BottomTab";
import { useEffect, useState } from "react";
import { onAuthStateChanged } from "firebase/auth";
import { auth } from "./firebase";
import Allergy from "./screens/Allergy";
import { StripeProvider } from "@stripe/stripe-react-native";
import Home from "./screens/Home";
import { LogBox } from "react-native";
import Splash from "./screens/Splash";
import Signin from "./screens/Signin";
import Checkout from "./components/Checkout";
import { toggleIsComplete } from "./slices/basketSlice";
export default function App() {
const Stack = createNativeStackNavigator();
const [state, setState] = useState(false);
useEffect(() => {
const subscribe = onAuthStateChanged(auth, (user) => {
if (user) {
setState(true);
return <Home />;
}
});
return subscribe;
}, []);
LogBox.ignoreLogs(["new NativeEventEmitter"]); // Ignore log notification by message LogBox.ignoreAllLogs(); //Ignore all log notifications
return (
<Provider store={store}>
<StripeProvider
publishableKey={process.env.STRIPE_PUBLISHABLE_KEY}
merchantIdentifier="merchant.com.foodDelivery"
>
<NavigationContainer>
<StatusBar style="auto" />
{state ? (
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="BottomTab">
{(props) => <BottomTab {...props} setAppState={setState} />}
</Stack.Screen>
<Stack.Screen name="Restaurant" component={Restaurant} />
<Stack.Screen name="Allergy" component={Allergy} />
<Stack.Screen
name="Checkout"
component={Checkout}
options={{
presentation: "modal",
}}
/>
<Stack.Screen name="Cart" component={Cart} />
</Stack.Navigator>
) : (
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen component={Splash} name="Splash" />
<Stack.Screen component={Signin} name="Signin" />
</Stack.Navigator>
)}
</NavigationContainer>
</StripeProvider>
</Provider>
);
}