-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
58 lines (52 loc) · 1.45 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
import React, { Component } from "react";
import { StyleSheet, View, Text } from "react-native";
import AppNavigator from "./navigation/AppNavigator";
import { AppLoading } from "expo";
import * as Font from "expo-font";
import NetInfo from "@react-native-community/netinfo";
export default class App extends Component {
state = {
assetsLoaded: false,
isConnected: true,
};
handleConnectionChange = (isConnected) => {
this.setState({ isConnected });
};
componentDidMount() {
NetInfo.addEventListener(this.handleConnectionChange);
}
render() {
if (!this.state.assetsLoaded) {
return (
<AppLoading
startAsync={this._loadFontsAsync}
onFinish={() => this.setState({ assetsLoaded: true })}
/>
);
} else {
return (
<View style={styles.container}>
<AppNavigator />
{!this.state.isConnected ? (
<View style={{ backgroundColor: "red" }}>
<Text style={{ textAlign: "center", color: "white" }}>
Нет соединения с сервером!
</Text>
</View>
) : null}
</View>
);
}
}
async _loadFontsAsync() {
return await Font.loadAsync({
"SF-UI-Text": require("./assets/fonts/SFUIText-Regular.ttf"),
"SF-PRO-Text": require("./assets/fonts/SFProDisplay-Regular.ttf"),
});
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});