Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 0 0
  1. import React from "react";
  2. import {
  3. Dimensions,
  4. TouchableOpacity,
  5. Image,
  6. View,
  7. Keyboard
  8. } from "react-native";
  9. import {
  10. createStackNavigator,
  11. createDrawerNavigator,
  12. createSwitchNavigator
  13. } from "react-navigation";
  14. import { Ionicons } from "@expo/vector-icons";
  15. import StackViewStyleInterpolator from "react-navigation-stack/dist/views/StackView/StackViewStyleInterpolator";
  16. import CustomDrawerContentComponent from "./CustomDrawerContentComponent";
  17.  
  18. import ComoFunciona from "../screens/ComoFunciona";
  19. import Destaques from "../screens/Destaques";
  20. import FaleConosco from "../screens/FaleConosco";
  21. import Duvidas from "../screens/Duvidas";
  22. import Favoritos from "../screens/Favoritos";
  23. import Perfil from "../screens/Perfil";
  24. import Filtro from "../screens/Filtro";
  25. import Beneficio from "../screens/Beneficio";
  26. import NaoAssinante from "../screens/NaoAssinante";
  27. import TodosBeneficios from "../screens/TodosBeneficios";
  28. import Login from "../screens/Login";
  29. import Voucher from "../screens/Voucher";
  30. import AuthLoadingScreenVoucher from "./AuthLoadingScreenVoucher";
  31. import AuthLoadingScreenPerfil from "./AuthLoadingScreenPerfil";
  32.  
  33. const { width, height } = Dimensions.get("screen");
  34.  
  35. // Opcao para android, transicao entre telas no stacknav puxando da direta ao inves de fade bottom que eh o default
  36. const transitionConfig = {
  37. transitionConfig: () => ({
  38. screenInterpolator: sceneProps => {
  39. return StackViewStyleInterpolator.forHorizontal(sceneProps);
  40. }
  41. })
  42. };
  43.  
  44. const clickMenu = navigation => {
  45. navigation.openDrawer();
  46. Keyboard.dismiss();
  47. };
  48.  
  49. // NAVIGATION OPTIONS
  50. const filtroNavigationOptions = ({ navigation }) => ({
  51. headerStyle: {
  52. backgroundColor: "#1a1b5a",
  53. color: "white",
  54. height: 60
  55. },
  56. headerLeft: (
  57. <TouchableOpacity
  58. onPress={() => navigation.goBack()}
  59. hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
  60. style={{ padding: 10 }}
  61. >
  62. <Ionicons name="ios-arrow-back" size={40} color="white" />
  63. </TouchableOpacity>
  64. ),
  65. headerRight: (
  66. <TouchableOpacity
  67. onPress={() => clickMenu(navigation)}
  68. style={{ padding: 10 }}
  69. >
  70. <Ionicons name="md-menu" size={40} color="white" />
  71. </TouchableOpacity>
  72. )
  73. });
  74.  
  75. const basicNavigationOptionsWithGoBack = ({ navigation }) => ({
  76. headerStyle: {
  77. backgroundColor: "#1a1b5a",
  78. color: "white",
  79. height: 60
  80. },
  81. headerLeft: (
  82. <TouchableOpacity
  83. onPress={() => navigation.goBack(null)}
  84. hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
  85. style={{ padding: 10 }}
  86. >
  87. <Ionicons name="ios-arrow-back" size={40} color="white" />
  88. </TouchableOpacity>
  89. ),
  90. headerTitle: (
  91. <View style={{ flex: 1, alignItems: "center" }}>
  92. <TouchableOpacity
  93. onPress={() => navigation.navigate("Destaques")}
  94. hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
  95. >
  96. <Image
  97. style={{ height: 35, width: 140 }}
  98. source={require("../assets/images/logo-topo.png")}
  99. />
  100. </TouchableOpacity>
  101. </View>
  102. ),
  103. headerRight: (
  104. <TouchableOpacity
  105. onPress={() => clickMenu(navigation)}
  106. style={{ padding: 10 }}
  107. >
  108. <Ionicons name="md-menu" size={40} color="white" />
  109. </TouchableOpacity>
  110. )
  111. });
  112.  
  113. const basicNavigationOptionsWithName = ({ navigation }) => ({
  114. headerStyle: {
  115. backgroundColor: "#1a1b5a",
  116. color: "white",
  117. height: 60
  118. },
  119. headerRight: (
  120. <TouchableOpacity
  121. onPress={() => clickMenu(navigation)}
  122. style={{ padding: 10 }}
  123. >
  124. <Ionicons name="md-menu" size={40} color="white" />
  125. </TouchableOpacity>
  126. )
  127. });
  128.  
  129. const basicNavigationOptions = ({ navigation }) => ({
  130. headerTitle: (
  131. <View style={{ flex: 1, alignItems: "center" }}>
  132. <TouchableOpacity
  133. onPress={() => navigation.navigate("Destaques")}
  134. hitSlop={{ top: 20, bottom: 20, left: 20, right: 20 }}
  135. >
  136. <Image
  137. style={{ height: 35, width: 140 }}
  138. source={require("../assets/images/logo-topo.png")}
  139. />
  140. </TouchableOpacity>
  141. </View>
  142. ),
  143. headerStyle: {
  144. backgroundColor: "#1a1b5a",
  145. color: "white",
  146. height: 60
  147. },
  148. headerLeft: <View />,
  149. headerRight: (
  150. <TouchableOpacity
  151. onPress={() => clickMenu(navigation)}
  152. style={{ padding: 10 }}
  153. >
  154. <Ionicons name="md-menu" size={40} color="white" />
  155. </TouchableOpacity>
  156. )
  157. });
  158. // FIM NAVIGATION OPTIONS
  159.  
  160. // SEM AUTENTICACAO
  161. const DestaquesStack = createStackNavigator(
  162. {
  163. Destaques: {
  164. screen: Destaques,
  165. navigationOptions: basicNavigationOptions
  166. },
  167. Filtro: {
  168. screen: Filtro,
  169. navigationOptions: filtroNavigationOptions
  170. },
  171. Beneficio: {
  172. screen: Beneficio,
  173. navigationOptions: basicNavigationOptionsWithGoBack
  174. }
  175. },
  176. transitionConfig
  177. );
  178.  
  179. const ComoFuncionaStack = createStackNavigator({
  180. ComoFunciona: {
  181. screen: ComoFunciona,
  182. navigationOptions: basicNavigationOptions
  183. }
  184. });
  185.  
  186. const FaleConoscoStack = createStackNavigator({
  187. FaleConosco: {
  188. screen: FaleConosco,
  189. navigationOptions: basicNavigationOptions
  190. }
  191. });
  192.  
  193. const DuvidasStack = createStackNavigator({
  194. Duvidas: {
  195. screen: Duvidas,
  196. navigationOptions: basicNavigationOptions
  197. }
  198. });
  199.  
  200. const FavoritosStack = createStackNavigator(
  201. {
  202. Favoritos: {
  203. screen: Favoritos,
  204. navigationOptions: basicNavigationOptionsWithName
  205. },
  206. Beneficio: {
  207. screen: Beneficio,
  208. navigationOptions: basicNavigationOptionsWithGoBack
  209. }
  210. },
  211. transitionConfig
  212. );
  213.  
  214. const TodosBeneficiosStack = createStackNavigator(
  215. {
  216. TodosBeneficios: {
  217. screen: TodosBeneficios,
  218. navigationOptions: basicNavigationOptions
  219. },
  220. Filtro: {
  221. screen: Filtro,
  222. navigationOptions: filtroNavigationOptions
  223. },
  224. Beneficio: {
  225. screen: Beneficio,
  226. navigationOptions: basicNavigationOptionsWithGoBack
  227. }
  228. },
  229. transitionConfig
  230. );
  231. // FIM SEM AUTENTICACAO
  232.  
  233. // NECESSARIO AUTENTICACAO
  234. const PerfilStack = createStackNavigator({
  235. Perfil: {
  236. screen: Perfil,
  237. navigationOptions: basicNavigationOptionsWithName
  238. }
  239. });
  240.  
  241. const LoginStack = createStackNavigator({
  242. Login: {
  243. screen: Login,
  244. navigationOptions: basicNavigationOptionsWithGoBack
  245. }
  246. });
  247.  
  248. const NaoAssinanteStack = createStackNavigator({
  249. NaoAssinante: {
  250. screen: NaoAssinante,
  251. navigationOptions: basicNavigationOptionsWithGoBack
  252. }
  253. });
  254.  
  255. const VoucherStack = createStackNavigator({
  256. Voucher: {
  257. screen: Voucher,
  258. navigationOptions: basicNavigationOptionsWithGoBack
  259. }
  260. });
  261.  
  262. const AuthSwitchStackVoucher = createSwitchNavigator(
  263. {
  264. AuthLoading: AuthLoadingScreenVoucher,
  265. Voucher: VoucherStack,
  266. Login: LoginStack,
  267. NaoAssinante: NaoAssinanteStack
  268. },
  269. {
  270. initialRouteName: "AuthLoading"
  271. }
  272. );
  273.  
  274. const AuthSwitchStackPerfil = createSwitchNavigator(
  275. {
  276. AuthLoading: AuthLoadingScreenPerfil,
  277. Login: LoginStack,
  278. Perfil: PerfilStack
  279. },
  280. {
  281. initialRouteName: "Perfil"
  282. }
  283. );
  284. // FIM NECESSARIO AUTENTICACAO
  285.  
  286. // MENU GAVETA/HAMBURGUER
  287. export const DrawerNavigator = createDrawerNavigator(
  288. {
  289. Destaques: {
  290. screen: DestaquesStack
  291. },
  292. TodosBeneficios: {
  293. screen: TodosBeneficiosStack
  294. },
  295. Favoritos: {
  296. screen: FavoritosStack
  297. },
  298. Perfil: {
  299. screen: AuthSwitchStackPerfil
  300. },
  301. ComoFunciona: {
  302. screen: ComoFuncionaStack
  303. },
  304. FaleConosco: {
  305. screen: FaleConoscoStack,
  306. path: "destaques"
  307. },
  308. Duvidas: {
  309. screen: DuvidasStack
  310. },
  311. Voucher: {
  312. screen: AuthSwitchStackVoucher
  313. }
  314. },
  315. {
  316. initialRouteName: "Destaques",
  317. drawerLockMode: "locked-closed",
  318. drawerWidth: width,
  319. drawerPosition: "right",
  320. contentComponent: CustomDrawerContentComponent
  321. }
  322. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement