Skip to content

Commit

Permalink
AlbumDetailScreen.js finished
Browse files Browse the repository at this point in the history
  • Loading branch information
asantos committed May 21, 2015
1 parent 9bbf05f commit d97963a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
23 changes: 4 additions & 19 deletions AlbumDetailScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,15 @@ function fullSizeUrl(thumbUrl) {
}

var AlbumDetailScreen = React.createClass({
getInitialState() {
return this.computedState();
},

computedState() {
return {
isFavorite: FavoritesStore.isFavorite(this.props.album)
}
getInitialState() {
return {};
},

componentDidMount() {
// way of calculating relative size:
// https://github.com/facebook/react-native/issues/953
setTimeout(this.measureArtworkContainer);

FavoritesStore.on(FavoritesStore.CHANGE_EVENT, this.onFavoritesChange);
},

measureArtworkContainer() {
Expand All @@ -46,26 +39,18 @@ var AlbumDetailScreen = React.createClass({
});
},

componentWillUnmount() {
FavoritesStore.removeListener(FavoritesStore.CHANGE_EVENT, this.onFavoritesChange);
},

onFavoritesChange() {
this.setState(this.computedState());
},

onShowMoreButtonPressed() {
LinkingIOS.openURL(this.props.album.collectionViewUrl);
},

onFavoriteButtonPressed() {
FavoritesStore.toggleFavorite(this.props.album);

},

render() {
var album = this.props.album;
var year = yearFromReleaseDate(album.releaseDate);
var favoriteButtonText = this.state.isFavorite ? 'Unfavorite' : 'Favorite';
var favoriteButtonText = 'Favorite';
var artworkContainerHeight = this.state.artworkContainerHeight;

return (
Expand Down
2 changes: 1 addition & 1 deletion FavoritesListScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var FavoritesListScreen = React.createClass({
},

componentWillUnmount() {

},

onFavoritesChange() {
Expand Down

0 comments on commit d97963a

Please sign in to comment.