2017-08-21 08:16:39 +08:00
|
|
|
import React from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2016-08-03 06:55:20 +08:00
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
2017-02-24 04:20:21 +08:00
|
|
|
import PresentationToolbarService from './service';
|
2017-08-21 08:16:39 +08:00
|
|
|
import PresentationToolbar from './component';
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
const PresentationToolbarContainer = ({ ...props }) => {
|
|
|
|
const {
|
|
|
|
currentSlideNum,
|
|
|
|
userIsPresenter,
|
|
|
|
numberOfSlides,
|
|
|
|
actions,
|
|
|
|
} = props;
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
if (userIsPresenter) {
|
|
|
|
// Only show controls if user is presenter
|
|
|
|
return (
|
|
|
|
<PresentationToolbar
|
|
|
|
currentSlideNum={currentSlideNum}
|
|
|
|
numberOfSlides={numberOfSlides}
|
|
|
|
actions={actions}
|
|
|
|
/>
|
|
|
|
);
|
2016-08-03 06:55:20 +08:00
|
|
|
}
|
2017-08-21 08:16:39 +08:00
|
|
|
return null;
|
|
|
|
};
|
2016-08-03 06:55:20 +08:00
|
|
|
|
|
|
|
export default createContainer((params) => {
|
2017-02-24 04:20:21 +08:00
|
|
|
const data = PresentationToolbarService.getSlideData(params);
|
2016-08-06 02:39:24 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
userIsPresenter,
|
|
|
|
numberOfSlides,
|
|
|
|
} = data;
|
|
|
|
|
|
|
|
return {
|
|
|
|
userIsPresenter,
|
|
|
|
numberOfSlides,
|
|
|
|
actions: {
|
|
|
|
nextSlideHandler: () =>
|
2017-02-24 04:20:21 +08:00
|
|
|
PresentationToolbarService.nextSlide(params.currentSlideNum, numberOfSlides),
|
2016-08-06 02:39:24 +08:00
|
|
|
previousSlideHandler: () =>
|
2017-02-24 04:20:21 +08:00
|
|
|
PresentationToolbarService.previousSlide(params.currentSlideNum, numberOfSlides),
|
2017-06-03 03:25:02 +08:00
|
|
|
skipToSlideHandler: event =>
|
2017-02-24 04:20:21 +08:00
|
|
|
PresentationToolbarService.skipToSlide(event),
|
2016-08-06 02:39:24 +08:00
|
|
|
},
|
|
|
|
};
|
2017-02-24 04:20:21 +08:00
|
|
|
}, PresentationToolbarContainer);
|
2016-08-03 06:55:20 +08:00
|
|
|
|
2017-08-21 08:16:39 +08:00
|
|
|
PresentationToolbarContainer.propTypes = {
|
|
|
|
// Number of current slide being displayed
|
|
|
|
currentSlideNum: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// PresentationId of the current presentation
|
|
|
|
presentationId: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
// Is the user a presenter
|
|
|
|
userIsPresenter: PropTypes.bool.isRequired,
|
|
|
|
|
|
|
|
// Total number of slides in this presentation
|
|
|
|
numberOfSlides: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// Actions required for the presenter toolbar
|
|
|
|
actions: PropTypes.shape({
|
|
|
|
nextSlideHandler: PropTypes.func.isRequired,
|
|
|
|
previousSlideHandler: PropTypes.func.isRequired,
|
|
|
|
skipToSlideHandler: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
};
|