2017-02-16 23:02:40 +00:00
|
|
|
import React, { Component } from 'react';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { View } from 'react-native';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-03-29 12:07:05 +00:00
|
|
|
import { toggleAudioOnly } from '../../base/conference';
|
2016-12-11 23:39:31 +00:00
|
|
|
import { MEDIA_TYPE, toggleCameraFacingMode } from '../../base/media';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Container } from '../../base/react';
|
|
|
|
import { ColorPalette } from '../../base/styles';
|
2017-02-16 23:02:40 +00:00
|
|
|
import { beginRoomLockRequest } from '../../room-lock';
|
2017-01-31 09:52:29 +00:00
|
|
|
import { beginShareRoom } from '../../share-room';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
import {
|
|
|
|
abstractMapDispatchToProps,
|
|
|
|
abstractMapStateToProps
|
|
|
|
} from '../functions';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { styles } from './styles';
|
|
|
|
import ToolbarButton from './ToolbarButton';
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Implements the conference toolbox on React Native.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
class Toolbox extends Component {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Toolbox component's property types.
|
2016-12-01 01:52:39 +00:00
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-02-16 23:02:40 +00:00
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* Flag showing that audio is muted.
|
|
|
|
*/
|
|
|
|
_audioMuted: React.PropTypes.bool,
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Flag showing whether room is locked.
|
|
|
|
*/
|
|
|
|
_locked: React.PropTypes.bool,
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Handler for hangup.
|
|
|
|
*/
|
|
|
|
_onHangup: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
2017-03-29 12:07:05 +00:00
|
|
|
* Sets the lock i.e. password protection of the conference/room.
|
2017-02-16 23:02:40 +00:00
|
|
|
*/
|
|
|
|
_onRoomLock: React.PropTypes.func,
|
|
|
|
|
2017-01-31 09:52:29 +00:00
|
|
|
/**
|
|
|
|
* Begins the UI procedure to share the conference/room URL.
|
|
|
|
*/
|
|
|
|
_onShareRoom: React.PropTypes.func,
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Handler for toggle audio.
|
|
|
|
*/
|
|
|
|
_onToggleAudio: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
2017-03-29 12:07:05 +00:00
|
|
|
* Toggles the audio-only flag of the conference.
|
|
|
|
*/
|
|
|
|
_onToggleAudioOnly: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switches between the front/user-facing and back/environment-facing
|
|
|
|
* cameras.
|
2017-02-16 23:02:40 +00:00
|
|
|
*/
|
|
|
|
_onToggleCameraFacingMode: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for toggling video.
|
|
|
|
*/
|
|
|
|
_onToggleVideo: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag showing whether video is muted.
|
|
|
|
*/
|
|
|
|
_videoMuted: React.PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag showing whether toolbar is visible.
|
|
|
|
*/
|
|
|
|
_visible: React.PropTypes.bool
|
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2016-12-11 23:39:31 +00:00
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
style = { styles.toolbarContainer }
|
2017-02-16 23:02:40 +00:00
|
|
|
visible = { this.props._visible }>
|
2016-12-11 23:39:31 +00:00
|
|
|
{
|
|
|
|
this._renderPrimaryToolbar()
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this._renderSecondaryToolbar()
|
|
|
|
}
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the styles for a button that toggles the mute state of a specific
|
|
|
|
* media type.
|
|
|
|
*
|
|
|
|
* @param {string} mediaType - The {@link MEDIA_TYPE} associated with the
|
|
|
|
* button to get styles for.
|
|
|
|
* @protected
|
|
|
|
* @returns {{
|
|
|
|
* iconName: string,
|
|
|
|
* iconStyle: Object,
|
|
|
|
* style: Object
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
_getMuteButtonStyles(mediaType) {
|
|
|
|
let iconName;
|
|
|
|
let iconStyle;
|
|
|
|
let style = styles.primaryToolbarButton;
|
|
|
|
|
|
|
|
if (this.props[`_${mediaType}Muted`]) {
|
|
|
|
iconName = this[`${mediaType}MutedIcon`];
|
|
|
|
iconStyle = styles.whiteIcon;
|
|
|
|
style = {
|
|
|
|
...style,
|
|
|
|
backgroundColor: ColorPalette.buttonUnderlay
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
iconName = this[`${mediaType}Icon`];
|
|
|
|
iconStyle = styles.icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
iconName,
|
|
|
|
iconStyle,
|
|
|
|
style
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-11 23:39:31 +00:00
|
|
|
/**
|
|
|
|
* Renders the toolbar which contains the primary buttons such as hangup,
|
|
|
|
* audio and video mute.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderPrimaryToolbar() {
|
2016-10-05 14:36:59 +00:00
|
|
|
const audioButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.AUDIO);
|
|
|
|
const videoButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.VIDEO);
|
|
|
|
|
|
|
|
/* eslint-disable react/jsx-handler-names */
|
|
|
|
|
|
|
|
return (
|
2016-12-11 23:39:31 +00:00
|
|
|
<View style = { styles.primaryToolbar }>
|
|
|
|
<ToolbarButton
|
|
|
|
iconName = { audioButtonStyles.iconName }
|
|
|
|
iconStyle = { audioButtonStyles.iconStyle }
|
2017-02-16 23:02:40 +00:00
|
|
|
onClick = { this.props._onToggleAudio }
|
2016-12-12 19:49:23 +00:00
|
|
|
style = { audioButtonStyles.style } />
|
2016-12-11 23:39:31 +00:00
|
|
|
<ToolbarButton
|
|
|
|
iconName = 'hangup'
|
|
|
|
iconStyle = { styles.whiteIcon }
|
2017-02-16 23:02:40 +00:00
|
|
|
onClick = { this.props._onHangup }
|
2016-12-11 23:39:31 +00:00
|
|
|
style = {{
|
2016-12-12 19:49:23 +00:00
|
|
|
...styles.primaryToolbarButton,
|
2016-12-11 23:39:31 +00:00
|
|
|
backgroundColor: ColorPalette.red
|
|
|
|
}}
|
|
|
|
underlayColor = { ColorPalette.buttonUnderlay } />
|
|
|
|
<ToolbarButton
|
|
|
|
iconName = { videoButtonStyles.iconName }
|
|
|
|
iconStyle = { videoButtonStyles.iconStyle }
|
2017-02-16 23:02:40 +00:00
|
|
|
onClick = { this.props._onToggleVideo }
|
2016-12-12 19:49:23 +00:00
|
|
|
style = { videoButtonStyles.style } />
|
2016-12-11 23:39:31 +00:00
|
|
|
</View>
|
|
|
|
);
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2016-12-11 23:39:31 +00:00
|
|
|
/* eslint-enable react/jsx-handler-names */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the toolbar which contains the secondary buttons such as toggle
|
|
|
|
* camera facing mode.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderSecondaryToolbar() {
|
2016-12-14 22:15:17 +00:00
|
|
|
const iconStyle = styles.secondaryToolbarIcon;
|
2016-12-12 19:49:23 +00:00
|
|
|
const style = styles.secondaryToolbarButton;
|
|
|
|
const underlayColor = 'transparent';
|
|
|
|
|
|
|
|
/* eslint-disable react/jsx-curly-spacing,react/jsx-handler-names */
|
2016-12-11 23:39:31 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<View style = { styles.secondaryToolbar }>
|
|
|
|
<ToolbarButton
|
2016-12-14 22:15:17 +00:00
|
|
|
iconName = 'switch-camera'
|
2016-12-12 19:49:23 +00:00
|
|
|
iconStyle = { iconStyle }
|
2017-02-16 23:02:40 +00:00
|
|
|
onClick = { this.props._onToggleCameraFacingMode }
|
2016-12-12 19:49:23 +00:00
|
|
|
style = { style }
|
|
|
|
underlayColor = { underlayColor } />
|
|
|
|
<ToolbarButton
|
|
|
|
iconName = {
|
2017-01-28 03:36:20 +00:00
|
|
|
this.props._locked ? 'security-locked' : 'security'
|
2016-12-12 19:49:23 +00:00
|
|
|
}
|
|
|
|
iconStyle = { iconStyle }
|
2017-02-16 23:02:40 +00:00
|
|
|
onClick = { this.props._onRoomLock }
|
2016-12-12 19:49:23 +00:00
|
|
|
style = { style }
|
|
|
|
underlayColor = { underlayColor } />
|
2017-03-29 12:07:05 +00:00
|
|
|
<ToolbarButton
|
|
|
|
iconName = 'star'
|
|
|
|
iconStyle = { iconStyle }
|
|
|
|
onClick = { this.props._onToggleAudioOnly }
|
|
|
|
style = { style }
|
|
|
|
underlayColor = { underlayColor } />
|
2017-01-31 09:52:29 +00:00
|
|
|
<ToolbarButton
|
|
|
|
iconName = 'link'
|
|
|
|
iconStyle = { iconStyle }
|
|
|
|
onClick = { this.props._onShareRoom }
|
|
|
|
style = { style }
|
|
|
|
underlayColor = { underlayColor } />
|
2016-12-11 23:39:31 +00:00
|
|
|
</View>
|
2016-10-05 14:36:59 +00:00
|
|
|
);
|
|
|
|
|
2016-12-12 19:49:23 +00:00
|
|
|
/* eslint-enable react/jsx-curly-spacing,react/jsx-handler-names */
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional properties for various icons, which are now platform-dependent.
|
|
|
|
* This is done to have common logic of generating styles for web and native.
|
|
|
|
* TODO As soon as we have common font sets for web and native, this will no
|
|
|
|
* longer be required.
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
Object.assign(Toolbox.prototype, {
|
2016-10-05 14:36:59 +00:00
|
|
|
audioIcon: 'microphone',
|
|
|
|
audioMutedIcon: 'mic-disabled',
|
2016-12-14 22:15:17 +00:00
|
|
|
videoIcon: 'camera',
|
2016-10-05 14:36:59 +00:00
|
|
|
videoMutedIcon: 'camera-disabled'
|
|
|
|
});
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Maps actions to React component props.
|
|
|
|
*
|
|
|
|
* @param {Function} dispatch - Redux action dispatcher.
|
|
|
|
* @returns {{
|
|
|
|
* _onRoomLock: Function,
|
2017-03-29 12:07:05 +00:00
|
|
|
* _onToggleAudioOnly: Function,
|
2017-02-16 23:02:40 +00:00
|
|
|
* _onToggleCameraFacingMode: Function,
|
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
function _mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
|
|
|
...abstractMapDispatchToProps(dispatch),
|
|
|
|
|
|
|
|
/**
|
2017-03-29 12:07:05 +00:00
|
|
|
* Sets the lock i.e. password protection of the conference/room.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
|
|
|
* @private
|
2017-03-29 12:07:05 +00:00
|
|
|
* @returns {Object} Dispatched action.
|
2017-02-16 23:02:40 +00:00
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onRoomLock() {
|
|
|
|
return dispatch(beginRoomLockRequest());
|
|
|
|
},
|
|
|
|
|
2017-01-31 09:52:29 +00:00
|
|
|
/**
|
|
|
|
* Begins the UI procedure to share the conference/room URL.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void} Dispatched action.
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onShareRoom() {
|
|
|
|
return dispatch(beginShareRoom());
|
|
|
|
},
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
2017-03-29 12:07:05 +00:00
|
|
|
* Toggles the audio-only flag of the conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {Object} Dispatched action.
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onToggleAudioOnly() {
|
|
|
|
return dispatch(toggleAudioOnly());
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switches between the front/user-facing and back/environment-facing
|
2017-02-16 23:02:40 +00:00
|
|
|
* cameras.
|
|
|
|
*
|
|
|
|
* @private
|
2017-03-29 12:07:05 +00:00
|
|
|
* @returns {Object} Dispatched action.
|
2017-02-16 23:02:40 +00:00
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onToggleCameraFacingMode() {
|
|
|
|
return dispatch(toggleCameraFacingMode());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of Redux store to React component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux store.
|
|
|
|
* @returns {{
|
|
|
|
* _locked: boolean
|
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
const conference = state['features/base/conference'];
|
|
|
|
|
|
|
|
return {
|
|
|
|
...abstractMapStateToProps(state),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the conference is
|
|
|
|
* locked/password-protected.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
_locked: conference.locked
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
export default connect(_mapStateToProps, _mapDispatchToProps)(Toolbox);
|