Skip to content

Commit ce94a6a

Browse files
committed
Adding in the fullscreen button in the playback controls container
1 parent 49e712f commit ce94a6a

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

app/containers/PlaybackControls.jsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { connect } from 'react-redux';
99
import { isPlaying } from '../actions/isPlaying';
1010
import { hasStopped } from '../actions/hasStopped';
1111
import { setVolume } from '../actions/setVolume';
12+
import { setFullscreen } from '../actions/setFullscreen';
1213

1314
import Button from '../components/Button.jsx';
1415
import Volume from '../components/Volume.jsx';
@@ -23,6 +24,10 @@ export class PlaybackControls extends Component {
2324
this.props.hasStoppedAction(true);
2425
}
2526

27+
_onFullscreenButtonClick() {
28+
this.props.setFullscreenAction(!this.props.fullscreen);
29+
}
30+
2631
_onVolumeChange(event) {
2732
const volumeValue = _.get(event, 'target.value');
2833
this.props.setVolumeAction(volumeValue);
@@ -31,12 +36,14 @@ export class PlaybackControls extends Component {
3136
render() {
3237
const playPauseButtonText = this.props.isPlaying ? 'pause' : 'play';
3338
const stopButtonText = 'stop';
39+
const fullscreenText = 'fullscreen';
3440

3541
return (
3642
<div>
3743
<Progress currentTime={this.props.currentTime} duration={this.props.duration} />
3844
<Button onClick={this._onPlayButtonClick.bind(this)} text={playPauseButtonText} />
3945
<Button onClick={this._onStopButtonClick.bind(this)} text={stopButtonText} />
46+
<Button onClick={this._onFullscreenButtonClick.bind(this)} text={fullscreenText} />
4047
<Volume onChange={this._onVolumeChange.bind(this)} />
4148
</div>
4249
);
@@ -45,26 +52,30 @@ export class PlaybackControls extends Component {
4552

4653
PlaybackControls.propTypes = {
4754
isPlaying: React.PropTypes.bool,
55+
duration: React.PropTypes.number,
56+
currentTime: React.PropTypes.number,
57+
fullscreen: React.PropTypes.bool,
4858
isPlayingAction: React.PropTypes.func,
4959
hasStoppedAction: React.PropTypes.func,
5060
setVolumeAction: React.PropTypes.func,
51-
duration: React.PropTypes.number,
52-
currentTime: React.PropTypes.number
61+
setFullscreenAction: React.PropTypes.func
5362
};
5463

5564
function mapStateToProps(state) {
5665
return {
5766
isPlaying: state.playback.isPlaying,
5867
duration: state.playback.duration,
59-
currentTime: state.playback.currentTime
68+
currentTime: state.playback.currentTime,
69+
fullscreen: state.playback.fullscreen
6070
};
6171
}
6272

6373
function mapDispatchToProps(dispatch) {
6474
return {
6575
isPlayingAction: bindActionCreators(isPlaying, dispatch),
6676
hasStoppedAction: bindActionCreators(hasStopped, dispatch),
67-
setVolumeAction: bindActionCreators(setVolume, dispatch)
77+
setVolumeAction: bindActionCreators(setVolume, dispatch),
78+
setFullscreenAction: bindActionCreators(setFullscreen, dispatch)
6879
};
6980
}
7081

test/containers/PlaybackControls.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import sinon from 'sinon';
88
import { PlaybackControls } from '../../app/containers/PlaybackControls.jsx';
99

1010
describe('<PlaybackControls />', () => {
11-
it('should render 2 <Button /> components', () => {
11+
it('should render 3 <Button /> components', () => {
1212
const wrapper = mount(<PlaybackControls />);
13-
assert.equal(wrapper.find('Button').length, 2);
13+
assert.equal(wrapper.find('Button').length, 3);
1414
});
1515

1616
describe('<Progress />', () => {
@@ -62,6 +62,22 @@ describe('<PlaybackControls />', () => {
6262
});
6363
});
6464

65+
describe('fullscreen <Button />', () => {
66+
it('sets fullscreen as the button text', () => {
67+
const wrapper = mount(<PlaybackControls isPlaying={true} />);
68+
69+
assert.equal(wrapper.find('Button').get(2).props.text, 'fullscreen');
70+
});
71+
72+
it('calls the setFullscreen with true when the button is clicked', () => {
73+
const setFullscreenSpy = sinon.spy();
74+
const wrapper = mount(<PlaybackControls fullscreen={false} setFullscreenAction={setFullscreenSpy} />);
75+
76+
wrapper.find('Button').at(2).simulate('click');
77+
assert(setFullscreenSpy.calledWith(true));
78+
});
79+
});
80+
6581
describe('<Volume />', () => {
6682
it('calls the setVolumeAction', () => {
6783
const setVolumeActionSpy = sinon.spy();

0 commit comments

Comments
 (0)