Last active
July 5, 2018 18:19
-
-
Save ryanashcraft/6628691b636f426f60331d8db4d06dab to your computer and use it in GitHub Desktop.
AmpliTunes without react-amplitude
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Fragment } from "react"; | |
class NowPlayingView extends React.Component { | |
componentDidMount() { | |
this.props.logViewNowPlayingScreen(); | |
} | |
componentDidUpdate = prevProps => { | |
if (prevProps.songId !== this.props.songId) { | |
this.props.logChangeSong(songId); | |
} | |
}; | |
render() { | |
return ( | |
<PlayControls | |
songId={this.props.songId} | |
genreId={this.props.genreId} | |
playlistId={this.props.playlistId} | |
isFavorited={this.props.isFavorited} | |
getTimeElapsed={this.props.getTimeElapsed} | |
/> | |
); | |
} | |
} | |
class PlayControls extends React.Component { | |
render() { | |
const commonProps = { | |
songId: this.props.songId, | |
genreId: this.props.genreId, | |
playlistId: this.props.playlistId, | |
isFavorited: this.props.isFavorited, | |
getTimeElapsed: this.props.getTimeElapsed | |
}; | |
return ( | |
<div> | |
<Seeker {...commonProps} /> | |
<div> | |
<RewindButton {...commonProps} /> | |
<PlayPauseButton {...commonProps} /> | |
<FastForwardButton {...commonProps} /> | |
</div> | |
<div> | |
<ShareMenu {...commonProps} /> | |
</div> | |
</div> | |
); | |
} | |
} | |
class FastForwardButton extends React.Component { | |
fastForward = () => { | |
this.props.logFastForward({ | |
songId: this.props.songId, | |
genreId: this.props.genreId, | |
playlistId: this.props.playlistId, | |
isFavorited: this.props.isFavorited, | |
timeElapsed: this.props.getTimeElapsed() | |
}); | |
this.props.fastForward(); | |
} | |
render() { | |
return ( | |
<Button onClick={this.fastForward}> | |
<Icon name="FAST_FORWARD" /> | |
</Button> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment