-
Notifications
You must be signed in to change notification settings - Fork 692
/
ConnectionStatusBarScreen.js
48 lines (44 loc) · 1.22 KB
/
ConnectionStatusBarScreen.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
import React, {Component} from 'react';
import {View, Text, StyleSheet} from 'react-native';
import {ConnectionStatusBar, Typography, Colors} from 'react-native-ui-lib'; //eslint-disable-line
ConnectionStatusBar.registerGlobalOnConnectionLost(() => {
// console.warn('what what?!? connection has been lost');
});
export default class ConnectionStatusBarScreen extends Component {
constructor(props) {
super(props);
this.state = {
isConnected: true,
};
}
render() {
return (
<View style={styles.container}>
<ConnectionStatusBar
onConnectionChange={isConnected => this.setState({isConnected})}
/>
<Text
style={{
textAlign: 'center',
marginBottom: 10,
...Typography.text60,
color: Colors.dark40,
}}
>
Turn your wifi on/off to see the component in action
</Text>
<Text style={{...Typography.text40}}>
{this.state.isConnected ? 'Connected! :)' : 'No connection :('}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 25,
},
});