-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
121 lines (115 loc) · 2.89 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
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
120
121
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
Image,
ListView,
StyleSheet,
Text,
View,
} = React;
var REQUEST_URL = 'http://api.marquee.by/releases/?token=r0_1b35a8f473d3cad96a0f4707954b8788ee4413fb'
var MarqueeMobile = React.createClass({
getInitialState: function() {
return {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
loaded: false
}
},
componentDidMount: function() {
this.fetchData();
},
fetchData: function(){
fetch(REQUEST_URL)
.then((response) => response.json())
.then((responseData) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(responseData),
loaded: true,
});
})
.done();
},
_touchEntry: function() {
console.log('ping');
},
_onResponderGrant: function(e){
e.target.style=
}
render: function() {
if(!this.state.dataSource){
return this.renderLoadingView();
}
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRelease}
/>
);
},
renderLoadingView: function() {
return (
<View style={styles.container}>
<Text>Loading Releases</Text>
</View>
);
},
renderRelease: function(release) {
return (
<View
style={styles.container}
onStartShouldSetResponder={this._touchEntryResponder}
>
<Image
source={{uri: release.cover_image.content['640'].url}}
style={styles.thumbnail}
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{release.title}</Text>
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
touchingContainer: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#EAEAEA',
}
rightContainer: {
flex: 1,
},
title: {
fontSize: 20,
marginBottom: 8,
textAlign: 'center',
},
year: {
textAlign: 'center',
},
thumbnail: {
width: 53,
height: 81,
},
listView: {
paddingTop: 20,
backgroundColor: '#F5FCFF',
},
});
AppRegistry.registerComponent('MarqueeMobile', () => MarqueeMobile);