No Description

App.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import React, { Component } from 'react';
  2. import firebase from 'firebase'
  3. import thunk from 'redux-thunk';
  4. import { NavigationContainer } from '@react-navigation/native';
  5. import { createStackNavigator } from '@react-navigation/stack';
  6. import { createDrawerNavigator } from '@react-navigation/drawer';
  7. import { Provider } from 'react-redux';
  8. import { createStore, applyMiddleware } from 'redux';
  9. import AvailabilityScreen from './screens/main/AvailabilityScreen';
  10. import MailScreen from './screens/MailScreen';
  11. import RegisterScreen from './screens/auth/RegisterScreen';
  12. import LoginScreen from './screens/auth/LoginScreen';
  13. import Loading from './screens/main/Loading';
  14. import { firebaseConfig } from './config/firebaseConfig';
  15. import rootReducer from './redux/reducers'
  16. import HomeScreen from './screens/main/Home_page';
  17. import RoomScreen from './screens/main/RoomScreen';
  18. import Calendario from './screens/main/Calendar';
  19. import Time from './screens/main/StateTime';
  20. import Search from './screens/main/Search';
  21. import Map from './screens/main/Map';
  22. import Confirm from './screens/main/Confirm';
  23. import Cita from './screens/main/Cita';
  24. if (firebase.apps.length === 0) {
  25. firebase.initializeApp(firebaseConfig)
  26. }
  27. const Stack = createStackNavigator();
  28. const Drawer = createDrawerNavigator();
  29. const store = createStore(rootReducer, applyMiddleware(thunk));
  30. export default class App extends Component {
  31. constructor(props){
  32. super(props);
  33. this.state = {
  34. loaded: false,
  35. }
  36. }
  37. componentDidMount(){
  38. firebase.auth().onAuthStateChanged((user) => {
  39. if (!user){
  40. this.setState({
  41. loggedIn: false,
  42. loaded: true,
  43. })
  44. }
  45. else{
  46. this.setState({
  47. loggedIn: true,
  48. loaded: true,
  49. })
  50. }
  51. });
  52. }
  53. createHomeStack = () =>
  54. <Stack.Navigator>
  55. <Stack.Screen name={"Home"} options={{headerShown: false}} component={HomeScreen}/>
  56. <Stack.Screen name={"Mail"} options={{ headerStatusBarHeight: 100, headerTransparent: true, headerBackTitle: " ", headerTitle: " "}} component={MailScreen}/>
  57. <Stack.Screen name={"Availability"} options={{ headerStatusBarHeight: 100, headerTransparent: true, headerBackTitle: " ", headerTitle: " "}} component={AvailabilityScreen}/>
  58. </Stack.Navigator>
  59. render() {
  60. const { loggedIn, loaded } = this.state
  61. if(!loaded){
  62. return(
  63. <Loading/>
  64. );
  65. }
  66. if(!loggedIn){
  67. return (
  68. <NavigationContainer>
  69. <Stack.Navigator>
  70. <Stack.Screen name={"Login"} options={{headerShown: false}} component={LoginScreen}/>
  71. <Stack.Screen name={"Register"} options={{headerTransparent: true, headerTitle: " "}} component={RegisterScreen}/>
  72. </Stack.Navigator>
  73. </NavigationContainer>
  74. );
  75. }
  76. return(
  77. <Provider store={store}>
  78. <NavigationContainer>
  79. <Stack.Navigator initialRouteName="Home">
  80. <Stack.Screen name="Home" options={{headerTransparent: true, headerTitle: " "}} component={HomeScreen} />
  81. <Stack.Screen name="Room" component={RoomScreen} options={({ route }) => ({ title: route.params.thread.name })} />
  82. <Stack.Screen name="Calendar" component={Calendario}/>
  83. <Stack.Screen name = "StateTime" component={Time}/>
  84. <Stack.Screen name = "Search" component={Search}/>
  85. <Stack.Screen name = "Map" component={Map}/>
  86. <Stack.Screen name = "Confirm" component={Confirm}/>
  87. <Stack.Screen name = "Cita" component={Cita}/>
  88. <Stack.Screen name = "Availability" component={AvailabilityScreen}/>
  89. </Stack.Navigator>
  90. </NavigationContainer>
  91. </Provider>
  92. );
  93. }
  94. }