Repository navigation
Expand file tree
/
Copy pathApp.tsx
More file actions
69 lines (59 loc) · 1.73 KB
/
Copy pathApp.tsx
File metadata and controls
69 lines (59 loc) · 1.73 KB
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
import { StatusBar } from "expo-status-bar";
import React, { Component } from "react";
import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
import Navigation from "./navigation";
import { ActivityIndicator, LogBox, StyleSheet } from "react-native";
import AuthNavigation from "./navigation/AuthNavigation";
import api from "./api";
import Theme from './constants/Theme'
import firebase from "firebase";
import { enableScreens } from 'react-native-screens';
import * as Permissions from 'expo-permissions';
import Constants from 'expo-constants'
import * as Notifications from 'expo-notifications'
enableScreens();
LogBox.ignoreLogs(['Setting a timer'])
LogBox.ignoreLogs(['VirtualizedLists'])
LogBox.ignoreLogs(['Can\'t perform a React state update'])
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
export default class App extends Component {
state = { user: null, initializing: true }
onAuthStateChanged(user: any) {
this.setState(() => ({ user }));
if (this.state.initializing) this.setState(() => ({ initializing: false }));
}
async componentDidMount() {
api.fetchUser((user: firebase.User | null) => this.onAuthStateChanged(user));
}
render() {
if (this.state.initializing) {
return (<ActivityIndicator />)
}
if (this.state.user) {
return (
<PaperProvider theme={Theme}>
<Navigation />
<StatusBar style={'auto'} />
</PaperProvider>
);
} else {
return (
<PaperProvider theme={Theme}>
<AuthNavigation />
<StatusBar style={'dark'} />
</PaperProvider>
)
}
}
}
const styles = StyleSheet.create({
statusBar: {
backgroundColor: 'red'
}
})