No Description

App.js 3.8KB

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