forked from CelinaPlatt/amplify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
138 lines (130 loc) · 3.85 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import "react-native-gesture-handler";
import React, { useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { LoginScreen, HomeScreen, RegistrationScreen } from "./src/screens";
import { decode, encode } from "base-64";
import { LogBox } from "react-native";
import { userAppAuth } from "./src/Hooks/userAppAuth";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import Profile from "./src/screens/Profile/Profile";
import { navIcons } from "./src/utils/navIcons";
import NewPostNav from "./src/screens/NewPost/NewPost";
import Inbox from "./src/screens/InboxScreen/InboxScreen";
import { testChat } from "./src/Hooks/testChats";
import { DefaultTheme, Provider as PaperProvider } from "react-native-paper";
import { Button } from "react-native";
import { Constants } from "expo-constants";
import { StatusBar } from "expo-status-bar";
import { SafeAreaView } from "react-native-safe-area-context";
const theme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: "#e05c10",
text: "white",
},
};
if (!global.btoa) {
global.btoa = encode;
}
if (!global.atob) {
global.atob = decode;
}
LogBox.ignoreLogs(["Setting a timer"]);
LogBox.ignoreLogs(["Async Storage has been extracted from react-native core"]);
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
export default function App() {
const { user, setUser, isLoggedIn, setIsLoggedIn } = userAppAuth();
const [updateMap, setUpdateMap] = useState([]);
const { usersArray, chatArray, messagesObject } = testChat(user);
const tabs = () => {
return (
<Tab.Navigator screenOptions={navIcons} tabBarHideOnKeyboard={true}>
<Tab.Screen name="Home">
{(props) => (
<HomeScreen
{...props}
user={user}
updateMap={updateMap}
chatArray={chatArray}
/>
)}
</Tab.Screen>
<Tab.Screen name="Profile">
{(props) => (
<Profile
{...props}
user={user}
setUser={setUser}
setIsLoggedIn={setIsLoggedIn}
/>
)}
</Tab.Screen>
<Tab.Screen name="NewPost">
{(props) => (
<NewPostNav {...props} user={user} setUpdateMap={setUpdateMap} />
)}
</Tab.Screen>
<Tab.Screen
name="Inbox"
screen="Chats"
options={{
header: () => null,
}}
>
{(props) => (
<Inbox
{...props}
chatArray={chatArray}
usersArray={usersArray}
user={user}
messagesObject={messagesObject}
/>
)}
</Tab.Screen>
</Tab.Navigator>
);
};
const loginSignup = () => {
return (
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="Login">
{(props) => (
<LoginScreen
{...props}
setUser={setUser}
setIsLoggedIn={setIsLoggedIn}
/>
)}
</Stack.Screen>
<Stack.Screen name="Registration">
{(props) => (
<RegistrationScreen
{...props}
setUser={setUser}
setIsLoggedIn={setIsLoggedIn}
/>
)}
</Stack.Screen>
</Stack.Navigator>
);
};
return (
<SafeAreaView style={{ flex: 1 }}>
<StatusBar
animated={true}
backgroundColor="#252525"
color="white"
translucent={true}
style="light"
/>
<PaperProvider theme={theme}>
<NavigationContainer>
{isLoggedIn ? tabs() : loginSignup()}
</NavigationContainer>
</PaperProvider>
</SafeAreaView>
);
}