-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
64 lines (56 loc) · 1.37 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
import React, { Component } from 'react';
import { StatusBar, View, Text, StyleSheet } from 'react-native';
import { Provider } from 'react-redux';
import configureStore from './src/store/configureStore';
import Navigation from './src/screens/Navigation';
import { PersistGate } from 'redux-persist/integration/react';
import NetInfo from "@react-native-community/netinfo";
const store = configureStore();
export default class App extends Component {
state = {
isConnected: true,
};
componentDidMount()
{
this.toggleInternetStatus();
}
componentWillUnmount()
{
this.toggleInternetStatus();
}
toggleInternetStatus = () => NetInfo.addEventListener(state => {
this.setState({
isConnected: state.isConnected,
});
});
render() {
return (
<Provider store={store.store}>
<PersistGate loading={null} persistor={store.persistor}>
<StatusBar backgroundColor="#1775C2" barStyle="light-content" />
<Navigation />
{ this.state.isConnected ? null :
<View style={styles.bg}>
<Text style={styles.text}>Sin conexión</Text>
</View>
}
</PersistGate>
</Provider>
);
}
}
const styles = StyleSheet.create({
bg: {
position: 'absolute',
height: '100%',
width: '100%',
flex: 1,
backgroundColor: 'rgba(0,0,0,0.1)',
justifyContent: 'flex-end',
alignItems: 'center'
},
text: {
color: '#E51212',
marginBottom: 35
}
});