-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
113 lines (105 loc) · 4.21 KB
/
App.tsx
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
import "react-native-gesture-handler";
import * as React from "react";
import { LogBox, Platform, UIManager } from "react-native";
import "./global";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { AppStackParamList } from "common/types/navigationTypes";
import { AppContextProvider } from "contexts/appContext";
import { ProfileContextProvider } from "contexts/profileContext";
import { useFonts } from "expo-font";
import { jsErrorHandler } from "lib/errors";
import { setJSExceptionHandler } from "react-native-exception-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { enableScreens } from "react-native-screens";
import { WalletTopUpScreen } from "screens/onboarding";
import { Confirmation, DepositSuccessful } from "screens/payments";
import { NavigationScreens } from "tabs/NavigationScreens";
import { OnboardingScreens } from "tabs/OnboardingScreens";
import { UserRegistrationScreens } from "tabs/UserRegistrationScreens";
import { useAppLogin } from "lib/hooks/useAppLogin";
// import { LogIn } from "screens/LogIn";
import AppLoading from "expo-app-loading";
// Ignore all log notifications:
// LogBox.ignoreAllLogs();
setJSExceptionHandler(jsErrorHandler, true); // true - enables the error in dev mode
enableScreens(); // enable native screens for navigation instead of using Views
// this will enable LayoutAnimation API
if (Platform.OS === "android") {
if (UIManager.setLayoutAnimationEnabledExperimental) {
UIManager.setLayoutAnimationEnabledExperimental(true);
}
}
const Stack = createStackNavigator<AppStackParamList>();
function App() {
const { isAuthorized, isAuthLoaded, user } = useAppLogin();
const [fontsLoadaed] = useFonts({
"Roboto-Thin": require("./assets/fonts/Roboto-Thin.ttf"),
"Roboto-Light": require("./assets/fonts/Roboto-Light.ttf"),
"Roboto-Regular": require("./assets/fonts/Roboto-Regular.ttf"),
"Roboto-Medium": require("./assets/fonts/Roboto-Medium.ttf"),
"Roboto-Bold": require("./assets/fonts/Roboto-Bold.ttf"),
"Roboto-Black": require("./assets/fonts/Roboto-Black.ttf"),
});
if (!fontsLoadaed || !isAuthLoaded) {
return <AppLoading />;
} else {
return (
<SafeAreaProvider>
<AppContextProvider>
<ProfileContextProvider>
<NavigationContainer>
<Stack.Navigator
initialRouteName={
isAuthorized ? "Navigation Screens" : "Onboarding Screens"
}
headerMode="screen">
{/*<Stack.Screen
name="Log In"
component={LogIn}
options={{ headerShown: false }}
/>*/}
<Stack.Screen
name="Onboarding Screens"
component={OnboardingScreens}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="User Registration Screens"
component={UserRegistrationScreens}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Navigation Screens"
component={NavigationScreens}
options={{ headerShown: false }}
initialParams={user}
/>
<Stack.Screen
name="Deposit Successful"
options={{ headerShown: false, gestureEnabled: false }}
component={DepositSuccessful}
/>
<Stack.Screen
name="Confirmation"
options={{ headerShown: false, gestureEnabled: false }}
component={Confirmation}
/>
<Stack.Screen
name="Add Funds"
options={{ headerShown: false, gestureEnabled: false }}
component={WalletTopUpScreen}
/>
</Stack.Navigator>
</NavigationContainer>
</ProfileContextProvider>
</AppContextProvider>
</SafeAreaProvider>
);
}
}
export default App;