-
Notifications
You must be signed in to change notification settings - Fork 16
/
AlbumsListScreen.js
49 lines (39 loc) · 1010 Bytes
/
AlbumsListScreen.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
'use strict';
var AlbumsRow = require('./AlbumsRow');
var AlbumDetailScreen = require('./AlbumDetailScreen');
var React = require('react');
import {
ListView
} from 'react-native';
var AlbumsListScreen = React.createClass({
getInitialState() {
var dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
return {
dataSource: dataSource.cloneWithRows(this.props.albums)
};
},
onRowPress(rowID) {
var album = this.props.albums[rowID];
this.props.navigator.push({
title: album.collectionName,
component: AlbumDetailScreen,
passProps: {album: album}
});
},
renderRow(rowData, sectionID, rowID) {
return (
<AlbumsRow
onPress={() => this.onRowPress(rowID)}
rowData={rowData} />
);
},
render() {
return (
<ListView
enableEmptySections={true}
dataSource={this.state.dataSource}
renderRow={this.renderRow} />
);
}
});
module.exports = AlbumsListScreen;