-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
187 lines (181 loc) · 4.5 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
import React from "react";
import * as SecureStore from "expo-secure-store";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { TailwindProvider } from "tailwindcss-react-native";
import { useNavigation } from "@react-navigation/native";
import { LogBox, Text, TextInput } from "react-native";
import "react-native-gesture-handler";
import * as Localization from "expo-localization";
import { I18n } from "i18n-js";
LogBox.ignoreLogs(["EventEmitter.removeListener"]);
//Screens
import Home from "./src/pages/Home";
import Otp from "./src/components/Modals/Otp";
import Directions from "./src/pages/Directions";
import Navigation from "./src/pages/Navigation";
import Onboarding from "./src/pages/Onboarding";
import LoginScreen from "./src/components/Modals/Login";
import Profile from "./src/pages/Profile";
import LoginScreenViaPhone from "./src/components/Modals/LoginViaPhone";
import FlashMessage from "react-native-flash-message";
import { translations } from "./translations";
import BankFeedback from "./src/components/Modals/BankFeedback";
import BankFaqs from "./src/pages/BankFaq";
import Bankform from "./src/components/Modals/Bankform";
import ViewPDF from "./src/components/Modals/ViewPDF";
import SavePrivateInfo from "./src/components/Modals/SavePrivateInfo";
const Stack = createNativeStackNavigator();
function App() {
const i18n = new I18n(translations);
const navigation = useNavigation();
i18n.locale = Localization.locale;
React.useEffect(() => {
if (Text.defaultProps == null) Text.defaultProps = {};
Text.defaultProps.allowFontScaling = false;
if (TextInput.defaultProps == null) TextInput.defaultProps = {};
TextInput.defaultProps.allowFontScaling = false;
async function isFirstTime() {
const x = await SecureStore.getItemAsync("isFirstTime");
if (x == null) {
navigation.navigate("Onboarding");
}
}
isFirstTime();
async function checkAuth() {
try {
const token = await SecureStore.getItemAsync("accessToken");
if (!!token) {
return true;
}
return false;
} catch (err) {
console.log(err);
}
}
async function getUser() {
try {
let user = {};
user.token = await SecureStore.getItemAsync("accessToken");
user.name = await SecureStore.getItemAsync("name");
user.phone_number = await SecureStore.getItemAsync("phone");
user.id = await SecureStore.getItemAsync("userId");
} catch (err) {
console.log(err);
}
}
checkAuth()
.then((isAuthenticated) => {
console.log("Authenticated Result ", isAuthenticated);
if (isAuthenticated) {
getUser();
}
})
.catch((err) => console.log(err));
}, []);
return (
<TailwindProvider>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Login"
component={LoginScreen}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="LoginViaPhone"
component={LoginScreenViaPhone}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="OTP"
component={Otp}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Directions"
component={Directions}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Navigate"
component={Navigation}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Onboarding"
component={Onboarding}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="BankFeedback"
component={BankFeedback}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Profile"
component={Profile}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="BankFaqs"
component={BankFaqs}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Bankform"
component={Bankform}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="ViewPDF"
component={ViewPDF}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="SavePrivateInfo"
component={SavePrivateInfo}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
<FlashMessage position="top" />
</TailwindProvider>
);
}
export default function AppWrapper() {
return (
<NavigationContainer>
<App />
</NavigationContainer>
);
}