Sin descripción

App.js 3.5KB

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