-
Notifications
You must be signed in to change notification settings - Fork 15
/
App.js
41 lines (36 loc) · 995 Bytes
/
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
import React, {useEffect, useState} from 'react';
import {SafeAreaView, StatusBar, View, StyleSheet} from 'react-native';
import ChatScreen from './screens/chatScreen';
import auth from '@react-native-firebase/auth';
import LoginScreen from './screens/loginScreen';
const App = () => {
const [user, setUser] = useState(null);
useEffect(() => {
// Auth listener
const unsubscribe = auth().onAuthStateChanged(user => {
user ? setUser(user) : setUser(null);
});
return () => {
unsubscribe();
};
}, []);
return (
<SafeAreaView style={styles.backgroundStyle}>
<StatusBar barStyle={'dark-content'} />
<View style={styles.viewStyle}>
{user ? <ChatScreen /> : <LoginScreen />}
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
backgroundStyle: {
backgroundColor: '#151718',
},
viewStyle: {
height: '100%',
alignItems: 'center',
backgroundColor: '#151718',
},
});
export default App;