-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
99 lines (90 loc) · 2.66 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { useEffect } from "react";
import { Text } from "react-native";
import { NavigationContainer, useNavigation } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import ChatList from "./screens/ChatList";
import Settings from "./screens/Settings";
import Chat from "./screens/Chat";
import SignUp from "./screens/SignUp";
import SignIn from "./screens/SignIn";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { Ionicons } from "@expo/vector-icons";
import { Provider, DefaultTheme } from "react-native-paper";
import firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
const firebaseConfig = {
apiKey: "AIzaSyAqae3ENw7GU7I7MEI4AdPyISgFLl1nViM",
authDomain: "chat-app-d523b.firebaseapp.com",
projectId: "chat-app-d523b",
storageBucket: "chat-app-d523b.appspot.com",
messagingSenderId: "22854053012",
appId: "1:22854053012:web:7b93bbdb0b2163f6839881",
};
firebase.initializeApp(firebaseConfig);
const Stack = createNativeStackNavigator();
const Tabs = createBottomTabNavigator();
const TabsNavigator = () => {
const navigation = useNavigation();
useEffect(() => {
firebase.auth().onAuthStateChanged((user) => {
if (!user) {
navigation.navigate("SignUp");
}
});
}, []);
return (
<Tabs.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
return (
<Ionicons
name={route.name === "ChatList" ? "chatbubbles" : "settings"}
color={color}
size={size}
/>
);
},
})}
>
<Tabs.Screen name="ChatList" component={ChatList} />
<Tabs.Screen name="Settings" component={Settings} />
</Tabs.Navigator>
);
};
const theme = {
...DefaultTheme,
roundness: 2,
colors: {
...DefaultTheme.colors,
primary: "#2196f3",
accent: "#e91e63",
},
};
const App = () => {
return (
<NavigationContainer>
<Provider theme={theme}>
<Stack.Navigator>
<Stack.Screen
name="Main"
component={TabsNavigator}
options={{ headerShown: false }}
/>
<Stack.Screen name="Chat" component={Chat} />
<Stack.Screen
name="SignUp"
component={SignUp}
options={{ presentation: "fullScreenModal" }}
/>
<Stack.Screen
name="SignIn"
component={SignIn}
options={{ presentation: "fullScreenModal" }}
/>
</Stack.Navigator>
</Provider>
</NavigationContainer>
);
};
export default App;