bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/media/container.jsx

65 lines
1.8 KiB
React
Raw Normal View History

2016-04-29 03:02:51 +08:00
import React, { Component, PropTypes } from 'react';
import { createContainer } from 'meteor/react-meteor-data';
import Media from './component';
import MediaService from './service';
import Button from '../button/component';
import WhiteboardContainer from '../whiteboard/container';
import VideoDockContainer from '../video-dock/container';
import DefaultContent from '../whiteboard/default-content/component';
const defaultProps = {
2016-07-11 21:13:55 +08:00
overlay: null, //<VideoDockContainer/>,
content: <WhiteboardContainer/>,
defaultContent: <DefaultContent />,
};
2016-05-03 06:42:54 +08:00
class MediaContainer extends Component {
2016-04-29 03:02:51 +08:00
constructor(props) {
super(props);
const { overlay, content, defaultContent } = this.props;
this.state = {
overlay: overlay,
content: this.props.current_presentation ? content : defaultContent,
};
this.handleToggleLayout = this.handleToggleLayout.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.current_presentation != this.props.current_presentation) {
if (nextProps.current_presentation) {
this.setState({ content: this.props.content });
} else {
this.setState({ content: this.props.defaultContent });
}
}
}
handleToggleLayout() {
const { overlay, content } = this.state;
this.setState({ overlay: content, content: overlay });
2016-04-29 03:02:51 +08:00
}
render() {
/* an example of toggleLayout button
<Button
label="Toggle Layout"
style={{ position: 'absolute', top: '10px', left: '10px' }}
onClick={this.handleToggleLayout} />
*/
return (
<Media overlay={this.state.overlay} content={this.state.content}>
2016-04-29 03:02:51 +08:00
{this.props.children}
2016-05-03 06:42:54 +08:00
</Media>
2016-04-29 03:02:51 +08:00
);
}
}
MediaContainer.defaultProps = defaultProps;
2016-04-29 03:02:51 +08:00
export default createContainer(() => {
const data = MediaService.getPresentationInfo();
return data;
2016-05-03 06:42:54 +08:00
}, MediaContainer);