-
Notifications
You must be signed in to change notification settings - Fork 375
/
DeviceInfos.js
89 lines (81 loc) · 1.95 KB
/
DeviceInfos.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import {
Clipboard,
RefreshControl,
ScrollView,
Text,
TouchableOpacity,
} from 'react-native'
import React, { PureComponent } from 'react'
import { DeviceInfos as GetDeviceInfos } from '../../../../graphql/queries'
import { Header } from '../../../Library'
import { colors } from '../../../../constants'
import { padding } from '../../../../styles'
export default class DeviceInfos extends PureComponent {
static navigationOptions = ({ navigation }) => ({
header: (
<Header
navigation={navigation}
title='Device infos'
titleIcon='info'
backBtn
/>
),
})
state = {
infos: {},
refreshing: false,
}
fetch = () => {
this.setState({ refreshing: true }, async () => {
const data = await GetDeviceInfos.fetch()
this.setState({ infos: data.DeviceInfos.infos, refreshing: false })
})
}
componentDidMount () {
this.fetch()
}
render () {
const { infos } = this.state
var fields = []
for (let i = 0; i < infos.length; i++) {
fields.push(
<TouchableOpacity
key={i}
style={[
{
backgroundColor: colors.white,
borderBottomColor: '#bbb',
borderBottomWidth: 1,
},
padding,
]}
onPress={() => Clipboard.setString(infos[i].value)}
>
<Text
color={colors.black}
style={{
fontWeight: 'bold',
marginBottom: 4,
}}
>
{infos[i].key}
</Text>
<Text color={colors.black}>{infos[i].value}</Text>
</TouchableOpacity>
)
}
return (
<ScrollView
style={{ backgroundColor: colors.background }}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this.fetch}
/>
}
>
{fields}
</ScrollView>
)
}
}