-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
155 lines (131 loc) · 5.01 KB
/
App.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
import React, { Component } from 'react';
import 'expo-asset';
import { Image } from 'react-native'
import * as firebase from 'firebase'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import rootReducer from './redux/reducers'
import thunk from 'redux-thunk'
import { getFocusedRouteNameFromRoute } from '@react-navigation/native';
import { container } from './components/styles'
const store = createStore(rootReducer, applyMiddleware(thunk))
import { YellowBox } from 'react-native';
import _ from 'lodash';
YellowBox.ignoreWarnings(['Setting a timer']);
const _console = _.clone(console);
console.warn = message => {
if (message.indexOf('Setting a timer') <= -1) {
_console.warn(message);
}
};
const firebaseConfig = {
apiKey: "AIzaSyB39LrUqvbn1Pnk5_etFe7rTDa86FCUHQA",
authDomain: "peersupport-191f2.firebaseapp.com",
databaseURL: "https://peersupport-191f2-default-rtdb.firebaseio.com",
projectId: "peersupport-191f2",
storageBucket: "peersupport-191f2.appspot.com",
messagingSenderId: "230319955069",
appId: "1:230319955069:web:a4186980ae4cd66e666514",
measurementId: "G-NYWYLBJY6X"
};
const logo = require('./assets/logo.png')
if (firebase.apps.length === 0) {
firebase.initializeApp(firebaseConfig)
}
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import RegisterScreen from './components/auth/Register'
import LoginScreen from './components/auth/Login'
import MainScreen from './components/Main'
import SaveScreen from './components/main/add/Save'
import EditScreen from './components/main/profile/Edit'
import ChatScreen from './components/main/chat/Chat'
import ChatListScreen from './components/main/chat/List'
import ProfileScreen from './components/main/profile/Profile'
import BlockedScreen from './components/main/random/Blocked'
const Stack = createStackNavigator();
export class App extends Component {
constructor(props) {
super()
this.state = {
loaded: false,
}
}
componentDidMount() {
firebase.auth().onAuthStateChanged((user) => {
if (!user) {
this.setState({
loggedIn: false,
loaded: true,
})
} else {
this.setState({
loggedIn: true,
loaded: true,
})
}
})
}
render() {
const { loggedIn, loaded } = this.state;
if (!loaded) {
return (
<Image style={container.splash} source={logo} />
)
}
if (!loggedIn) {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Login">
<Stack.Screen name="Register" component={RegisterScreen} navigation={this.props.navigation} options={{ headerShown: false }} />
<Stack.Screen name="Login" navigation={this.props.navigation} component={LoginScreen} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
);
}
return (
<Provider store={store}>
<NavigationContainer >
<Stack.Navigator initialRouteName="Main">
<Stack.Screen key={Date.now()} name="Main" component={MainScreen} navigation={this.props.navigation} options={({ route }) => {
const routeName = getFocusedRouteNameFromRoute(route) ?? 'EMA';
switch (routeName) {
case 'chat': {
return {
headerTitle: 'Chat',
};
}
case 'Profile': {
return {
headerTitle: 'Profile',
};
}
case 'Search': {
return {
headerTitle: 'Search',
};
}
case 'EMA':
default: {
return {
headerTitle: 'PeerSupport',
};
}
}
}}
/>
<Stack.Screen key={Date.now()} name="Save" component={SaveScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="video" component={SaveScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="Chat" component={ChatScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="ChatList" component={ChatListScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="Edit" component={EditScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="Profile" component={ProfileScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="ProfileOther" component={ProfileScreen} navigation={this.props.navigation} />
<Stack.Screen key={Date.now()} name="Blocked" component={BlockedScreen} navigation={this.props.navigation} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
</Provider>
)
}
}
export default App