-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
71 lines (64 loc) · 1.87 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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Font } from 'expo';
import Home from './src/components/Home/Home';
import Login from './src/components/Login/Login';
import { getData } from './src/api/db';
import AppLaunchService from './src/assets/applaunch';
export const applaunchService = new AppLaunchService();
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
fontLoaded: false,
isLoggedIn: false,
};
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
Ionicons: require('@expo/vector-icons/fonts/Ionicons.ttf'),
FontAwesome: require('@expo/vector-icons/fonts/FontAwesome.ttf'),
'Circular-Bold': require('./src/assets/fonts/CircularStd-Bold.otf'),
Circular: require('./src/assets/fonts/CircularStd-Medium.otf'),
'Circular-Light': require('./src/assets/fonts/CircularStd-Book.otf'),
'Calibre-Light': require('./src/assets/fonts/Calibre-Light.ttf'),
});
this.setState({ fontLoaded: true });
}
componentDidMount() {
Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
});
getData('userId', (err, data) => {
if (data && data.name) {
this.setState({
isLoggedIn: true,
});
}
});
this.renderScreens = this.renderScreens.bind(this);
}
renderScreens() {
if (this.state.isLoggedIn) {
return (<Home />);
}
return (<Login />);
}
render() {
return (
<View style={styles.container}>
{this.state.fontLoaded ?
this.renderScreens()
: null}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});