-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
382 lines (372 loc) · 12.9 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
import React from "react";
import { View } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { ActivityIndicator, Title } from "react-native-paper";
import * as eva from "@eva-design/eva";
import { ApplicationProvider, IconRegistry } from "@ui-kitten/components";
import { EvaIconsPack } from "@ui-kitten/eva-icons";
import { ThemeContext } from "./src/configs/theme";
import AppColors from "./src/configs/AppColors";
import AppLogin from "./src/screens/AppLogin";
import AppSignUp from "./src/screens/AppSignUp";
import AppQuickLogin from "./src/screens/AppQuickLogin";
import AppHome from "./src/screens/AppHome";
import AppHelp from "./src/screens/AppHelp";
import AppShop from "./src/screens/AppShop";
import AppStock from "./src/screens/AppStock";
import AppEmployee from "./src/screens/AppEmployee";
import AppSuppliers from "./src/screens/AppSuppliers";
import AppProfile from "./src/screens/AppProfile";
import AppReport from "./src/screens/AppReport";
import AppBanners from "./src/screens/AppBanners";
import AppSupply from "./src/screens/AppSupply";
import AppSupplies from "./src/screens/AppSupplies";
import AppAddSupplies from "./src/screens/AppAddSupplies";
import AppBanner from "./src/screens/AppBanner";
import AppReportExport from "./src/screens/AppReportExport";
import AppSelectShop from "./src/screens/AppSelectShop";
import AppSelectSupplier from "./src/screens/AppSelectSupplier";
import AppSelectSupply from "./src/screens/AppSelectSupply";
import AppAddInvoice from "./src/screens/AppAddInvoice";
import AppAddRequests from "./src/screens/AppAddRequests";
import AppAddBanner from "./src/screens/AppAddBanner";
import AppRequests from "./src/screens/AppRequests";
import AppRequest from "./src/screens/AppRequest";
import AppAddReturn from "./src/screens/AppAddReturn";
import AppAddShop from "./src/screens/AppAddShop";
import AppAddEmployee from "./src/screens/AppAddEmployee";
import AppAddSuppliers from "./src/screens/AppAddSuppliers";
import AppAddStock from "./src/screens/AppAddStock";
import AppEditStock from "./src/screens/AppEditStock";
import AppInvoices from "./src/screens/AppInvoices";
import AppInvoice from "./src/screens/AppInvoice";
import AppDelInvoice from "./src/screens/AppDelInvoice";
import { firebase } from "./src/configs/Database";
const MainStack = createStackNavigator();
export default () => {
const [theme, setTheme] = React.useState("light");
const toggleTheme = () => {
const nextTheme = theme === "light" ? "dark" : "light";
setTheme(nextTheme);
};
const [loading, setLoading] = React.useState(true);
const [user, setUser] = React.useState(null);
React.useEffect(() => {
const usersRef = firebase.firestore().collection("users");
firebase.auth().onAuthStateChanged((user) => {
if (user) {
usersRef
.doc(user.uid)
.get()
.then((document) => {
const userData = document.data();
setLoading(false);
setUser(userData);
})
.catch((error) => {
setLoading(false);
});
} else {
setLoading(false);
}
});
}, []);
if (loading) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator
animating={true}
size="large"
color={AppColors.primary}
/>
<Title style={{ color: AppColors.primary, marginTop: "1%" }}>
Loading
</Title>
</View>
);
}
return (
<>
<IconRegistry icons={EvaIconsPack} />
<ThemeContext.Provider value={{ theme, toggleTheme }}>
<ApplicationProvider {...eva} theme={eva[theme]}>
<NavigationContainer>
<MainStack.Navigator
screenOptions={{
headerStyle: { backgroundColor: AppColors.primary },
headerTintColor: AppColors.background,
headerTitleStyle: {
fontWeight: "bold",
},
}}
>
{user ? (
<>
<MainStack.Screen
name="AppQuickLogin"
component={AppQuickLogin}
options={{
title: "Quick Login",
headerShown: false,
}}
/>
<MainStack.Screen
name="AppHome"
component={AppHome}
options={{
title: "Home",
headerShown: false,
}}
/>
<MainStack.Screen
name="AppHelp"
component={AppHelp}
options={{
title: "Help",
}}
/>
<MainStack.Screen
name="InvoicesScreen"
component={AppInvoices}
options={{
title: "Invoices",
}}
/>
<MainStack.Screen
name="AppInvoice"
component={AppInvoice}
options={({ route }) => ({
title:
route.params.invoice.docID +
" (" +
route.params.invoice.shopName +
") | Posify",
headerShown: false,
})}
/>
<MainStack.Screen
name="AppDelInvoice"
component={AppDelInvoice}
options={{
title: "Remove Invoices",
}}
/>
<MainStack.Screen
name="ProfileScreen"
component={AppProfile}
options={{
title: "Profile",
}}
/>
<MainStack.Screen
name="AddRequestsScreen"
component={AppAddRequests}
options={{
title: "New Request",
headerShown: false,
}}
/>
<MainStack.Screen
name="RequestsScreen"
component={AppRequests}
options={{
title: "Requests",
}}
/>
<MainStack.Screen
name="AppRequest"
component={AppRequest}
options={{
title: "Request",
headerShown: false,
}}
/>
<MainStack.Screen
name="SelectShopScreen"
component={AppSelectShop}
options={{
title: "Select Shop",
}}
/>
<MainStack.Screen
name="AppSelectSupply"
component={AppSelectSupply}
options={{
title: "Select",
}}
/>
<MainStack.Screen
name="SelectSupplierScreen"
component={AppSelectSupplier}
options={{
title: "Select Supplier",
}}
/>
<MainStack.Screen
name="AddInvoiceScreen"
component={AppAddInvoice}
options={{
title: "New Invoice",
headerShown: false,
}}
/>
<MainStack.Screen
name="AddReturnScreen"
component={AppAddReturn}
options={{
title: "Deduct Returns",
headerShown: false,
}}
/>
<MainStack.Screen
name="StockScreen"
component={AppStock}
options={{
title: "Stock",
}}
/>
<MainStack.Screen
name="AddStockScreen"
component={AppAddStock}
options={{
title: "New Items",
}}
/>
<MainStack.Screen
name="EditStockScreen"
component={AppEditStock}
options={{
title: "Edit Items",
headerShown: false,
}}
/>
<MainStack.Screen
name="ShopScreen"
component={AppShop}
options={{
title: "Shops",
}}
/>
<MainStack.Screen
name="AddShopScreen"
component={AppAddShop}
options={{
title: "New Shop",
}}
/>
<MainStack.Screen
name="AppSupply"
component={AppSupply}
options={{
title: "Supply",
headerShown: false,
}}
/>
<MainStack.Screen
name="AppSupplies"
component={AppSupplies}
options={{
title: "Supplies",
}}
/>
<MainStack.Screen
name="AppAddSupplies"
component={AppAddSupplies}
options={{
title: "New Supply Request",
headerShown: false,
}}
/>
<MainStack.Screen
name="AppBanners"
component={AppBanners}
options={{
title: "Banners",
}}
/>
<MainStack.Screen
name="AppBanner"
component={AppBanner}
options={{
title: "Banner",
headerShown: false,
}}
/>
<MainStack.Screen
name="AppAddBanner"
component={AppAddBanner}
options={{
title: "New Banner",
}}
/>
<MainStack.Screen
name="ReportScreen"
component={AppReport}
options={{
title: "Reports",
}}
/>
<MainStack.Screen
name="ReportExport"
component={AppReportExport}
options={{
title: "Report",
}}
/>
<MainStack.Screen
name="EmployeeScreen"
component={AppEmployee}
options={{
title: "Employees",
}}
/>
<MainStack.Screen
name="AddEmployeeScreen"
component={AppAddEmployee}
options={{
title: "New Employees",
}}
/>
<MainStack.Screen
name="SuppliersScreen"
component={AppSuppliers}
options={{
title: "Suppliers",
}}
/>
<MainStack.Screen
name="AddSuppliersScreen"
component={AppAddSuppliers}
options={{
title: "New Supplier",
}}
/>
</>
) : (
<>
<MainStack.Screen
name="LoginScreen"
component={AppLogin}
options={{
title: "Login",
headerShown: false,
}}
/>
<MainStack.Screen
name="SignUpScreen"
component={AppSignUp}
options={{
title: "SignUp",
headerShown: false,
}}
/>
</>
)}
</MainStack.Navigator>
</NavigationContainer>
</ApplicationProvider>
</ThemeContext.Provider>
</>
);
};