-
Notifications
You must be signed in to change notification settings - Fork 1
/
Guidelines.js
105 lines (96 loc) · 2.16 KB
/
Guidelines.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
101
102
103
104
105
import React, { Component } from "react";
import {
Text,
StyleSheet,
View,
ListView,
ActivityIndicator,
AsyncStorage
} from "react-native";
export default class Guidelines extends Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
text: ""
};
}
componentDidMount() {
return AsyncStorage.getItem("token").then(token => {
fetch("http://139.59.67.104:4001/core/api/material-list/2/", {
method: "GET",
headers: {
Authorization: "token " + token
}
})
.then(response => response.json())
.then(responseJson => {
let ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
// Alert.alert(responseJson.data.username+'');
this.setState({
isLoading: false,
dataSource: ds.cloneWithRows(
responseJson.map(each => each.category)
)
});
})
.catch(error => {
console.error(error);
});
});
}
ListViewItemSeparator = () => {
return (
<View
style={{
height: 0.5,
width: "100%",
backgroundColor: "#000"
}}
/>
);
};
render() {
if (this.state.isLoading) {
return (
<View style={{ flex: 1, paddingTop: 20 }}>
<ActivityIndicator />
</View>
);
}
return (
<View style={styles.MainContainer}>
<ListView
dataSource={this.state.dataSource}
renderSeparator={this.ListViewItemSeparator}
renderRow={rowData => (
<Text style={styles.rowViewContainer}>{rowData.category}</Text>
)}
enableEmptySections={true}
style={{ marginTop: 10 }}
/>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer: {
justifyContent: "center",
flex: 1,
margin: 7
},
rowViewContainer: {
fontSize: 17,
padding: 10
},
TextInputStyleClass: {
textAlign: "center",
height: 40,
borderWidth: 1,
borderColor: "#009688",
borderRadius: 7,
backgroundColor: "#FFFFFF"
}
});