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';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } 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
|
|
|
|
2018-07-25 04:20:37 +08:00
|
|
|
import PresentationService from '/imports/ui/components/presentation/service';
|
|
|
|
|
2017-09-26 07:45:44 +08:00
|
|
|
const PresentationToolbarContainer = (props) => {
|
2017-08-21 08:16:39 +08:00
|
|
|
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
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
export default withTracker((params) => {
|
2018-04-12 04:05:30 +08:00
|
|
|
const { podId, presentationId } = params;
|
|
|
|
const data = PresentationToolbarService.getSlideData(podId, presentationId);
|
2016-08-06 02:39:24 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
numberOfSlides,
|
|
|
|
} = data;
|
|
|
|
|
|
|
|
return {
|
2018-07-25 04:20:37 +08:00
|
|
|
userIsPresenter: PresentationService.isPresenter(podId),
|
2016-08-06 02:39:24 +08:00
|
|
|
numberOfSlides,
|
|
|
|
actions: {
|
|
|
|
nextSlideHandler: () =>
|
2018-04-12 04:05:30 +08:00
|
|
|
PresentationToolbarService.nextSlide(params.currentSlideNum, numberOfSlides, podId),
|
2016-08-06 02:39:24 +08:00
|
|
|
previousSlideHandler: () =>
|
2018-04-12 04:05:30 +08:00
|
|
|
PresentationToolbarService.previousSlide(params.currentSlideNum, podId),
|
|
|
|
skipToSlideHandler: requestedSlideNum =>
|
|
|
|
PresentationToolbarService.skipToSlide(requestedSlideNum, podId),
|
2018-08-14 03:29:38 +08:00
|
|
|
zoomSlideHandler: value =>
|
|
|
|
PresentationToolbarService.zoomSlide(params.currentSlideNum, podId, value),
|
2016-08-06 02:39:24 +08:00
|
|
|
},
|
|
|
|
};
|
2018-01-08 12:44:42 +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,
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
};
|