-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
119 lines (100 loc) · 3.04 KB
/
App.js
File metadata and controls
119 lines (100 loc) · 3.04 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
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
import './src/I18n/I18n';
import React, { Component } from 'react';
import { Platform, StatusBar, Text, View } from 'react-native';
import { Provider } from 'react-redux';
import { persistStore } from 'redux-persist';
import I18n from 'react-native-i18n';
import firebase from 'firebase';
import color from 'color';
import RouteDescription from './src/Route';
import SplashScreen from './src/screens/Splash';
import WelcomeScreen from './src/screens/Welcome';
import AuthScreen from './src/screens/Auth';
import * as baseStyle from './styles';
import { store, persistStoreConfig } from './src/redux/store';
import reducers from './src/redux/reducers';
import { firebaseConfig } from './src/constants';
class App extends Component {
constructor() {
super();
console.ignoredYellowBox = ['Setting a timer'];
console.ignoredYellowBox = ['Remote debugger'];
}
state = {
rehydrated: false,
userLoggedIn: null,
welcomeFinished: false
}
async componentWillMount() {
/* Pour utiliser Native-Base avec Expo, il faut charger la police Roboto_medium */
/* await Expo.Font.loadAsync({
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf')
}); */
persistStore (
store,
persistStoreConfig,
() => {
this.setState({ rehydrated: true });
this.setState({ welcomeFinished: store.getState().settings.welcomeFinished });
}
);//.purge();
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
const self = this;
firebase.auth().languageCode = I18n.currentLocale();
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log('User is logged in.');
self.setState({ userLoggedIn: true })
/* if(!user.emailVerified) {
user.sendEmailVerification()
.then(() => console.log('Sent Email verification'))
.catch(() => console.log('Error, no verification email sent'));
} else { console.log('User mail was already verified'); } */
} else {
console.log('No user is logged in.');
self.setState({ userLoggedIn: false })
}
});
// console.log(`Vérifier que androidStatusBarColor dans app.json vaut bien ${color(baseStyle.COLOR_PRIMARY).darken(0.2).hex()}`); // Si on utilise Expo
}
render() {
if (Platform.OS === 'android') {
StatusBar.setBackgroundColor(baseStyle.statusBarColor());
}
StatusBar.setBarStyle(baseStyle.statusBarStyle);
I18n.locale = store.getState().settings.language;
if(!this.state.rehydrated || (this.state.userLoggedIn === null)) {
return <SplashScreen />
}
if(!this.state.welcomeFinished) {
return(
<View style={{ flex: 1 }}>
<Provider store={store}>
<WelcomeScreen
onFinished={() => this.setState({ welcomeFinished: true })}
/>
</Provider>
</View>
);
}
if(!this.state.userLoggedIn) {
return(
<View style={{ flex: 1 }}>
<Provider store={store}>
<AuthScreen />
</Provider>
</View>
);
}
return (
<View style={{ flex: 1 }}>
<Provider store={store}>
<RouteDescription />
</Provider>
</View>
);
}
}
export default App;