123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import React, { Component } from 'react';
- import firebase from 'firebase'
- import thunk from 'redux-thunk';
- import { NavigationContainer } from '@react-navigation/native';
- import { createStackNavigator } from '@react-navigation/stack';
- import { createDrawerNavigator } from '@react-navigation/drawer';
- import { Provider } from 'react-redux';
- import { createStore, applyMiddleware } from 'redux';
-
- import AvailabilityScreen from './screens/AvailabilityScreen';
- import MailScreen from './screens/MailScreen';
- //import RegisterScreen from './screens/RegisterScreen';
- import RegisterScreen from './screens/auth/RegisterScreen';
- //import LoginScreen from './screens/LoginScreen';
- import LoginScreen from './screens/auth/LoginScreen';
- import HomeScreen from './screens/HomeScreen';
- //import Loading from './components/Loading';
- import Loading from './screens/main/Loading';
- import { firebaseConfig } from './config/firebaseConfig';
- <<<<<<< HEAD
- =======
- import { Text, View } from 'react-native';
- import { styles } from './config/styles';
-
- import HomeScreen from './screens/main/Home_page';
- import RoomScreen from './screens/main/RoomScreen'
- import { Provider} from 'react-redux'
- import { createStore, applyMiddleware } from 'redux';
- >>>>>>> devErnesto
- import rootReducer from './redux/reducers'
-
-
-
- if (firebase.apps.length === 0) {
- firebase.initializeApp(firebaseConfig)
- }
-
- const Stack = createStackNavigator();
- const Drawer = createDrawerNavigator();
- const store = createStore(rootReducer, applyMiddleware(thunk));
-
- export default class App extends Component {
- constructor(props){
- super(props);
- this.state = {
- loaded: false,
- }
- }
-
- componentDidMount(){
- firebase.auth().onAuthStateChanged((user) => {
- if (!user){
- this.setState({
- loggedIn: false,
- loaded: true,
- })
- }
- else{
- this.setState({
- loggedIn: true,
- loaded: true,
- })
- }
- });
- }
-
- createHomeStack = () =>
- <Stack.Navigator>
- <Stack.Screen name={"Home"} options={{headerShown: false}} component={HomeScreen}/>
- <Stack.Screen name={"Mail"} options={{ headerStatusBarHeight: 100, headerTransparent: true, headerBackTitle: " ", headerTitle: " "}} component={MailScreen}/>
- <Stack.Screen name={"Availability"} options={{ headerStatusBarHeight: 100, headerTransparent: true, headerBackTitle: " ", headerTitle: " "}} component={AvailabilityScreen}/>
- </Stack.Navigator>
-
- render() {
-
- const { loggedIn, loaded } = this.state
-
- if(!loaded){
- return(
- <Loading/>
- );
- }
-
- if(!loggedIn){
- return (
- <NavigationContainer>
- <Stack.Navigator>
- <Stack.Screen name={"Login"} options={{headerShown: false}} component={LoginScreen}/>
- <Stack.Screen name={"Register"} options={{headerTransparent: true, headerTitle: " "}} component={RegisterScreen}/>
- </Stack.Navigator>
- </NavigationContainer>
- );
- }
-
- return(
- <Provider store={store}>
- <NavigationContainer>
- <<<<<<< HEAD
- <Drawer.Navigator>
- <Drawer.Screen name={" "} options={{drawerLabel: "Home", headerTransparent: true}} children={this.createHomeStack}/>
- </Drawer.Navigator>
- =======
- <Stack.Navigator initialRouteName="Home">
- <Stack.Screen name="Home" component={HomeScreen} />
- <Stack.Screen name="Room" component={RoomScreen} options={({ route }) => ({ title: route.params.thread.name })} />
- </Stack.Navigator>
- >>>>>>> devErnesto
- </NavigationContainer>
- </Provider>
- );
- }
- }
|