-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListScreen.js
119 lines (110 loc) · 3.25 KB
/
ListScreen.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import React from 'react';
import {View, Text, StyleSheet, TouchableOpacity, Linking, WebView} from 'react-native';
// Dummy data to show in list
export default class ListScreen extends React.Component {
constructor(props) {
super(props);
this.state ={
data : []
}
this.showList = this.showList.bind(this);
this._onPressButton = this._onPressButton.bind(this);
}
componentDidMount(){
var thisobj = this;
fetch('https://phpq09tvz7.execute-api.us-east-1.amazonaws.com/prod',{
headers: {
'Accept':'application/json'
},
}).then(async function(resp){
const responseData = await resp.json();
console.log('msg list'+JSON.stringify(responseData.body));
var temp = JSON.stringify(responseData.body.Items);
var parseData = JSON.parse(temp);
thisobj.setState({data:parseData});
console.log('response data'+ JSON.parse(temp));
});
}
_onPressButton(parm){
this.props.navigation.navigate(
'UrlPage',
{ parm },
);
}
showList() {
console.log('showlist called', this.state.data);
var data = this.state.data;
let a = [];
console.log('type of', typeof data);
console.log('type of', typeof a);
if(data.length>0){
return data.map((list, i) => {
//<TouchableOpacity onPress={()=>{Linking.openURL('https://'+list.message.S)}} style={styles.touchable}></TouchableOpacity>
return(
<View key={i} style={styles.list}>
<TouchableOpacity onPress={() => {this._onPressButton(list.message.S)}} style={styles.touchable}>
<View style={styles.title}>
<Text style={styles.heading}>{list.message.S}</Text>
<Text style={styles.subhead}>{list.createdAt.S}</Text>
</View>
<View style={styles.dateSection}>
<Text style={styles.subhead}>
</Text>
</View>
</TouchableOpacity>
</View>
);
});
}
}
render() {
return (
<View style={styles.main}>
{this.showList()}
</View>
)}
}
const styles = StyleSheet.create({
list: {
padding:5,
alignItems: 'stretch',
backgroundColor: '#fff',
justifyContent: 'center',
margin:10,
marginBottom: 5,
borderColor: '#ffffff',
borderWidth: 1,
borderRadius: 5,
shadowColor: '#fff',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.8,
shadowRadius: 2,
elevation: 1,
},
title: {
marginRight:30,
alignSelf: 'stretch',
},
heading: {
fontSize: 18,
},
main: {
width:'100%',
backgroundColor:'#DDDDDD',
flex:1,
},
touchable: {
width:'100%',
flexDirection: 'row',
display:'flex',
justifyContent: 'space-between',
padding:5,
},
subhead: {
color:'#afafaf',
fontSize:12,
},
dateSection: {
right:0,
}
})