-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthController.js
159 lines (134 loc) · 4.24 KB
/
AuthController.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// import React, {Component} from 'react';
// import {Text, View, ToolbarAndroid, StyleSheet} from 'react-native';
// import {createAppContainer} from 'react-navigation';
// import {createStackNavigator} from 'react-navigation-stack';
// import {createBottomTabNavigator} from 'react-navigation-tabs';
// import Ionicons from 'react-native-vector-icons/Ionicons';
// import MainScreen from './components/MainScreen';
// import Posts from './components/Posts';
// import ViewPost from './components/pages/ViewPost';
// import HomeScreen from './components/pages/HomeScreen';
// import SettingsScreen from './components/pages/SettingsScreen';
// import DetailsScreen from './components/pages/DetailsScreen';
// import ProfileScreen from './components/pages/ProfileScreen';
// import NewPost from './components/pages/NewPost';
// import Signup from './components/pages/Signup';
// import App from './App';
// const SettingsStack = createStackNavigator(
// {
// //Defination of Navigaton from setting screen
// Settings: { screen: SettingsScreen },
// Details: { screen: DetailsScreen },
// Profile: { screen: ProfileScreen },
// },
// {
// defaultNavigationOptions: {
// //Header customization of the perticular Screen
// headerStyle: {
// backgroundColor: '#000000',
// },
// headerTintColor: '#FFFFFF',
// title: 'Settings',
// //Header title
// },
// }
// );
// const HomeStack = createStackNavigator(
// {
// //Defination of Navigaton from home screen
// Login: {screen: Signup},
// Home: { screen: MainScreen },
// ViewPost: { screen: ViewPost },
// },
// {
// defaultNavigationOptions: {
// //Header customization of the perticular Screen
// headerStyle: {
// backgroundColor: '#42f44b',
// },
// headerTintColor: '#FFFFFF',
// title: 'Home',
// //Header title
// },
// }
// );
// // const AuthController = createBottomTabNavigator(
// // {
// // Home: { screen: HomeStack },
// // // NewPost: { screen: NewPost },
// // // Profile: {screen: ProfileScreen}
// // },
// // {
// // defaultNavigationOptions: ({ navigation }) => ({
// // tabBarIcon: ({ focused, horizontal, tintColor }) => {
// // const { routeName } = navigation.state;
// // let IconComponent = Ionicons;
// // let iconName;
// // if (routeName === 'Home') {
// // iconName = `ios-information-circle${focused ? '' : '-outline'}`;
// // } else if (routeName === 'NewPost') {
// // iconName = `ios-add-circle${focused ? '' : '-outline'}`;
// // }
// // else if(routeName === 'Profile'){
// // iconName = `ios-switch`;
// // }
// // return <IconComponent name={iconName} size={25} color={tintColor} />;
// // },
// // }),
// // tabBarOptions: {
// // style:{
// // elevation: 5,
// // backgroundColor: '#000000'
// // },
// // activeTintColor: '#a1887f',
// // inactiveTintColor: 'gray',
// // },
// // }
// //);
// const MainNavigator = createStackNavigator({
// Login: {screen: Signup},
// Home: { screen: MainScreen },
// ViewPost: { screen: ViewPost },
// //header: <View></View>,
// });
// const styles = StyleSheet.create({
// title: {
// flex: 1,
// elevation: 10,
// },
// });
// export default createAppContainer(MainNavigator);
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import firebase, { firestore } from 'react-native-firebase';
import App from './App';
import Signup from './components/pages/Signup';
export default class AuthController extends Component {
constructor(props) {
super(props);
this.state = {
user: false
};
firebase.auth().onAuthStateChanged((user) => {
if (user) {
const {navigate} = this.props.navigation;
console.log('user is logged');
console.log(user.email);
navigate('Home')
this.setState({
user: true
})
}
else{
}
});
}
render() {
let view;
if (this.state.user) view = <App/>
else view = <Signup/>
return (
view
);
}
}