-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
194 lines (180 loc) · 5.93 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
import React from "react";
import { Text } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { useFonts } from "expo-font";
import { AntDesign } from "@expo/vector-icons";
import {
createDrawerNavigator,
DrawerItem,
DrawerContentScrollView,
DrawerItemList,
} from "@react-navigation/drawer";
import HomeScreen from "./src/screens/HomeScreen/HomeScreen";
import LoginScreen from "./src/screens/LoginScreen/LoginScreen";
import InvestingScreen from "./src/screens/InvestingScreen/InvestingScreen";
import OperationsHistoryScreen from "./src/screens/OperationsHistoryScreen/OperationsHistoryScreen";
import PortfolioScreen from "./src/screens/PortfolioScreen/PortfolioScreen";
import MarketsScreen from "./src/screens/MarketsScreen/MarketsScreen";
import StatisticsScreen from "./src/screens/StatisticsScreen/StatisticsScreen";
import LogoutScreen from "./src/screens/LogoutScreen";
import OperationScreen from "./src/screens/OperationScreen/OperationScreen";
import TickerScreen from "./src/screens/TickerScreen/TickerScreen";
import ChartsScreen from "./src/screens/ChartsScreen/ChartsScreen";
import FetchInfoScreen from "./src/screens/FetchInfoScreen/FetchInfoScreen";
import BuySellScreen from "./src/screens/BuySellScreen/BuySellScreen";
import TokenRequestScreen from "./src/screens/TokenRequestScreen";
import { navigationRef } from "./RootNavigation";
import { Provider as AuthProvider } from "./src/context/AuthContext";
import { Provider as FetchProvider } from "./src/context/FetchContext";
const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();
const navigatorOptions = {
headerShown: false,
cardStyle: { backgroundColor: "transparent" },
cardStyleInterpolator: ({ current: { progress } }) => ({
cardStyle: {
opacity: progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
}),
},
overlayStyle: {
opacity: progress.interpolate({
inputRange: [0, 1],
outputRange: [0, 0.5],
extrapolate: "clamp",
}),
},
}),
};
const HomeNavigator = () => {
return (
<Stack.Navigator screenOptions={navigatorOptions}>
<Stack.Screen name="Inicio" component={HomeScreen} />
<Stack.Screen name="Estadisticas" component={StatisticsScreen} />
<Stack.Screen name="FetchInfo" component={FetchInfoScreen} />
</Stack.Navigator>
);
};
const OperationNavigator = () => {
return (
<Stack.Navigator screenOptions={navigatorOptions}>
<Stack.Screen name="Operaciones" component={OperationsHistoryScreen} />
<Stack.Screen name="Operacion" component={OperationScreen} />
</Stack.Navigator>
);
};
const MarketNavigator = () => {
return (
<Stack.Navigator screenOptions={navigatorOptions}>
<Stack.Screen name="Cotizaciones" component={MarketsScreen} />
<Stack.Screen name="Ticker" component={TickerScreen} />
<Stack.Screen name="Grafico" component={ChartsScreen} />
</Stack.Navigator>
);
};
const InvestingNavigator = () => {
return (
<Stack.Navigator screenOptions={navigatorOptions}>
<Stack.Screen name="Operar" component={InvestingScreen} />
<Stack.Screen name="ComprarVender" component={BuySellScreen} />
</Stack.Navigator>
);
};
const CustomDrawerContent = (props) => {
return (
<DrawerContentScrollView
{...props}
contentContainerStyle={{
flex: 1,
}}
>
<DrawerItemList {...props} />
<DrawerItem
label={() => (
<Text style={{ color: "white", fontSize: 22 }}>
<AntDesign name="logout" size={20} color="white" />
Salir
</Text>
)}
style={{
backgroundColor: "rgba(235,77,75,0.8)",
position: "absolute",
bottom: 10,
width: "90%",
}}
onPress={() => props.navigation.navigate("Salir")}
/>
</DrawerContentScrollView>
);
};
const DrawerNavigator = () => {
return (
<Drawer.Navigator
initialRouteName="Home"
hideStatusBar={false}
drawerStyle={{
backgroundColor: "#2b5a7f",
}}
drawerContentOptions={{
activeBackgroundColor: "#193952",
labelStyle: { color: "white", fontSize: 22 },
itemStyle: { borderRadius: 10 },
}}
drawerContent={(props) => <CustomDrawerContent {...props} />}
>
<Drawer.Screen
name="Inicio"
component={HomeNavigator}
options={{ unmountOnBlur: true }}
/>
<Drawer.Screen
name="Portafolio"
component={PortfolioScreen}
options={{ unmountOnBlur: true }}
/>
<Drawer.Screen
name="Operar"
component={InvestingNavigator}
options={{ unmountOnBlur: true }}
/>
<Drawer.Screen
name="Operaciones"
component={OperationNavigator}
options={{ unmountOnBlur: true }}
/>
<Drawer.Screen
name="Cotizaciones"
component={MarketNavigator}
options={{ unmountOnBlur: true }}
/>
</Drawer.Navigator>
);
};
const App = () => {
const [loaded] = useFonts({
SairaBold: require("./assets/fonts/Saira-Bold.ttf"),
SairaLight: require("./assets/fonts/Saira-Light.ttf"),
SairaSemiBold: require("./assets/fonts/Saira-SemiBold.ttf"),
SairaThin: require("./assets/fonts/Saira-Thin.ttf"),
});
if (!loaded) {
return null;
}
return (
<FetchProvider>
<AuthProvider>
<NavigationContainer ref={navigationRef}>
<Stack.Navigator screenOptions={navigatorOptions}>
<Stack.Screen name="SignIn" component={LoginScreen} />
<Stack.Screen name="Home" component={DrawerNavigator} />
<Stack.Screen name="Salir" component={LogoutScreen} />
<Stack.Screen name="Solicitar" component={TokenRequestScreen} />
</Stack.Navigator>
</NavigationContainer>
</AuthProvider>
</FetchProvider>
);
};
export default App;