No Description

App.js 3.6KB

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