This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
71 lines (65 loc) · 1.51 KB
/
index.ios.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
/* @flow */
import React, { Component } from 'react';
import {
ActivityIndicator,
AppRegistry,
Modal,
StyleSheet,
Text,
View,
} from 'react-native';
import {
Footer,
Header,
Stats,
} from './components/index';
import config from './config/env.js';
import styles from './styles';
export default class sMonitor extends Component {
state = {
loading: false,
}
componentDidMount() {
this.getData();
}
getData = () => {
this.setState({ loading: true });
const { api } = config;
fetch(`${api.server}:${api.port}/status.json`)
.then((response) => response.json())
.then((responseJson) => {
this.setState({ loading: false });
this.setState({ ...responseJson });
})
.catch((error) => {
this.setState({ loading: false });
console.error(error);
});
}
render() {
const { container, indicator, loadingText, modal } = styles;
return (
<View style={container}>
<Modal
animationType='fade'
style={modal}
transparent
visible={this.state.loading}
>
<View
style={indicator}
>
<Text style={loadingText}>Loading Data...</Text>
<ActivityIndicator size='large' />
</View>
</Modal>
<Header>sMonitor v0.1</Header>
<Stats {...this.state} />
<Footer
onPressReloadData={this.getData}
/>
</View>
);
}
}
AppRegistry.registerComponent('sMonitor', () => sMonitor);