-
Notifications
You must be signed in to change notification settings - Fork 0
/
Devices.js
100 lines (82 loc) · 2.61 KB
/
Devices.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
90
91
92
93
94
95
96
97
98
99
100
import AsyncStorage from '@react-native-async-storage/async-storage';
import {SafeAreaView, ScrollView, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import Top from './Top';
import React, {Component} from 'react';
import { RefreshControl} from 'react-native'
class Devices extends Component<{ navigation: any }> {
constructor() {
super();
this.state = {
table: [],
loaded: false,
refreshing:false,
};
}
loadFromAsyncStorage() {
AsyncStorage.getItem('Tablica')
.then(data => {
console.log(data);
if (data !== null) {
this.setState({
table: JSON.parse(data),
loaded: true,
}, console.log(data));
}
});
}
componentDidMount() {
//AsyncStorage.removeItem("Tablica");
this.loadFromAsyncStorage();
}
componentDidUpdate() {
}
render() {
let {navigation} = this.props;
let data;
if (this.state.loaded && this.state.table !== null) {
data = this.state.table.map((val, key) => {
console.log(val);
return (
<View key={key}>
<TouchableOpacity style={styles.button}>
<Text style={{fontSize: 24}}>{val.name}</Text>
<Text style={{fontSize: 16}}>{val.place}</Text>
</TouchableOpacity>
</View>
);
});
} else {
data = <></>;
}
return (
<SafeAreaView style={{flex:1,marginBottom:12,}}>
<Top title="Devices"/>
<ScrollView>
<View style={styles.scrol}>
<TouchableOpacity style={styles.button} onPress={() => navigation.navigate('MyModal')}
title="Open Modal"><Text style={{fontSize: 50}}>+</Text></TouchableOpacity>
{data}
</View>
</ScrollView>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
button: {
width: 150,
height: 150,
borderWidth: 1,
backgroundColor: '#00BFFF',
marginTop: 30,
alignItems: 'center',
justifyContent: 'space-evenly',
},
scrol: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
paddingHorizontal: 35,
},
});
export default Devices;