-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
204 lines (189 loc) · 6.87 KB
/
App.tsx
File metadata and controls
204 lines (189 loc) · 6.87 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import * as Font from "expo-font";
import AppLoading from "expo-app-loading";
import Amplify from "aws-amplify";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { Provider } from "react-redux";
import { useForegroundPermissions } from "expo-location";
import awsconfig from "./src/aws-exports";
import AccountType from "./components/Login/AccountType";
import SignUp from "./components/Login/SignUp";
import Explore from "./components/Explore/Explore";
import Collections from "./components/Collections/Collections";
import Login from "./components/Login/Login";
import ForgotPass from "./components/Login/ForgotPass";
import BizReviewPage from "./components/Review/BizReviewPage";
import ForgotPass2 from "./components/Login/ForgotPass2";
import SignUpCode from "./components/Login/SignUpCode";
import OpenCollection from "./components/Collections/OpenCollection";
import ReviewPage from "./components/Review/ReviewPage";
import {
RootStackParamList,
RootTabBarParamList,
TabBarScreenOptions,
} from "./route-settings";
import Home from "./components/Home/Home";
import store from "./redux/store";
import initializeRedux from "./redux/initialize";
import { useAppDispatch, useAppSelector } from "./redux/hooks";
import Notifications from "./components/OwnershipTransfer/NotificationsPage";
import ProfileSelector from "./components/Profile/ProfileSelector";
import BusinessEditor from "./components/Profile/Business/BusinessEditor";
import CreateEditReview from "./components/Review/CreateEditReview";
import { selectUser } from "./redux/selectors/user";
import notifications from "./redux/thunks/notifications";
import collections from "./redux/thunks/collections";
import verification from "./redux/thunks/verification";
import VerificationRequests from "./components/Moderation/VerificationRequestsPage";
import EditProfile from "./components/Profile/User/EditProfile";
const madaBlack = require("./assets/fonts/Mada/Mada-Black.ttf");
const madaRegular = require("./assets/fonts/Mada/Mada-Regular.ttf");
const madaSemiBold = require("./assets/fonts/Mada/Mada-SemiBold.ttf");
const madaBold = require("./assets/fonts/Mada/Mada-Bold.ttf");
const madaMedium = require("./assets/fonts/Mada/Mada-Medium.ttf");
const poppinsRegular = require("./assets/fonts/Poppins/Poppins-Regular.ttf");
const poppinsSemi = require("./assets/fonts/Poppins/Poppins-SemiBold.ttf");
const fonts = {
"Mada-Black": madaBlack,
"Mada-Regular": madaRegular,
"Mada-SemiBold": madaSemiBold,
"Mada-Bold": madaBold,
"Mada-Medium": madaMedium,
"Poppins-Regular": poppinsRegular,
"Poppins-SemiBold": poppinsSemi,
};
Amplify.configure(awsconfig);
// Stack navigates between login and app, Tab navigates between pages within app
const Stack = createNativeStackNavigator<RootStackParamList>();
const Tab = createBottomTabNavigator<RootTabBarParamList>();
console.disableYellowBox = true;
function AuthenticatedApp() {
const user = useAppSelector(selectUser)!;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [status, requestPermission] = useForegroundPermissions();
const dispatch = useAppDispatch();
React.useEffect(() => {
dispatch(notifications.fetchNotifications(user.id));
dispatch(collections.fetchCollections(user.id));
if (user.isModerator) {
dispatch(verification.fetchRequests());
}
requestPermission();
}, []);
return (
<Tab.Navigator initialRouteName="Home" screenOptions={TabBarScreenOptions}>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="Explore" component={Explore} />
<Tab.Screen name="Collections" component={Collections} />
<Tab.Screen name="Profile" component={ProfileSelector} />
</Tab.Navigator>
);
}
function InnerApp() {
const dispatch = useAppDispatch();
React.useEffect(() => {
initializeRedux(dispatch);
}, []);
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName="Login"
screenOptions={{
headerShown: false,
headerTintColor: "#000000",
headerBackTitle: "Back",
headerBackTitleVisible: true,
headerBackTitleStyle: { fontSize: 18, fontFamily: "Mada-SemiBold" },
}}
>
<Stack.Screen
name="ForgotPass"
component={ForgotPass}
options={{
title: "Forgot Password",
headerShown: true,
}}
/>
<Stack.Screen
name="ForgotPass2"
component={ForgotPass2}
options={{
title: "Reset Password",
headerShown: true,
}}
/>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen
name="ChooseAccountType"
component={AccountType}
options={{
title: "Chose an Account",
headerShown: true,
}}
/>
<Stack.Screen
name="CreateAccount"
component={SignUp}
options={{
title: "Create an Account",
headerShown: true,
}}
/>
<Stack.Screen
name="CreateAccountCode"
component={SignUpCode}
options={{
title: "Input Code",
headerShown: true,
}}
/>
<Stack.Screen name="CreateBusinessProfile" component={BusinessEditor} />
<Stack.Screen name="App" component={AuthenticatedApp} />
<Stack.Screen name="OpenCollection" component={OpenCollection} />
<Stack.Screen name="ReviewPage" component={ReviewPage} />
<Stack.Screen name="BizReviewPage" component={BizReviewPage} />
<Stack.Screen name="CreateEditReview" component={CreateEditReview} />
<Stack.Screen
name="Notifications"
component={Notifications}
options={{ title: "Notifications", headerShown: true }}
/>
<Stack.Screen
name="VerificationRequests"
component={VerificationRequests}
options={{ title: "Verification Requests", headerShown: true }}
/>
<Stack.Screen
name="EditProfile"
component={EditProfile}
options={{
title: "Edit Profile",
headerShown: true,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default function App() {
const [fontsLoaded, setfontsLoaded] = React.useState(false);
async function loadFontsAsync() {
await Font.loadAsync(fonts);
setfontsLoaded(true);
}
React.useEffect(() => {
if (!fontsLoaded) {
loadFontsAsync();
}
}, []);
return (
<Provider store={store}>
<SafeAreaProvider>
{fontsLoaded ? <InnerApp /> : <AppLoading />}
</SafeAreaProvider>
</Provider>
);
}