2016-10-05 14:36:59 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View } from 'react-native';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
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-01-28 23:34:57 +00:00
|
|
|
import { AbstractToolbar, _mapStateToProps } from './AbstractToolbar';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { styles } from './styles';
|
|
|
|
import ToolbarButton from './ToolbarButton';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements the conference toolbar on React Native.
|
|
|
|
*
|
|
|
|
* @extends AbstractToolbar
|
|
|
|
*/
|
|
|
|
class Toolbar extends AbstractToolbar {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* Toolbar component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = AbstractToolbar.propTypes
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new Toolbar instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
2016-10-26 20:19:30 +00:00
|
|
|
this._toggleCameraFacingMode
|
|
|
|
= this._toggleCameraFacingMode.bind(this);
|
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 }
|
|
|
|
visible = { this.props.visible }>
|
|
|
|
{
|
|
|
|
this._renderPrimaryToolbar()
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this._renderSecondaryToolbar()
|
|
|
|
}
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 }
|
|
|
|
onClick = { this._toggleAudio }
|
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 }
|
|
|
|
onClick = { this._onHangup }
|
|
|
|
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 }
|
|
|
|
onClick = { this._toggleVideo }
|
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 }>
|
2017-02-21 15:09:07 +00:00
|
|
|
{/* FIXME There are multiple issues with the toggling of the
|
|
|
|
* camera facing more. For example, switching from the user
|
|
|
|
* facing camera to the environment facing camera on iOS may be
|
|
|
|
* very slow or may not work at all. On Android the toggling
|
|
|
|
* either works or does not. The causes of the various problems
|
|
|
|
* have been identified to lie within either
|
|
|
|
* react-native-webrtc or Google's native WebRTC API.
|
|
|
|
*
|
2016-12-11 23:39:31 +00:00
|
|
|
<ToolbarButton
|
2016-12-14 22:15:17 +00:00
|
|
|
iconName = 'switch-camera'
|
2016-12-12 19:49:23 +00:00
|
|
|
iconStyle = { iconStyle }
|
2016-12-11 23:39:31 +00:00
|
|
|
onClick = { this._toggleCameraFacingMode }
|
2016-12-12 19:49:23 +00:00
|
|
|
style = { style }
|
|
|
|
underlayColor = { underlayColor } />
|
2017-02-21 15:09:07 +00:00
|
|
|
*/}
|
2016-12-12 19:49:23 +00:00
|
|
|
<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 }
|
2016-12-13 09:14:04 +00:00
|
|
|
onClick = { this._onRoomLock }
|
2016-12-12 19:49:23 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switches between the front/user-facing and rear/environment-facing
|
|
|
|
* cameras.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2016-10-26 20:19:30 +00:00
|
|
|
_toggleCameraFacingMode() {
|
2016-10-05 14:36:59 +00:00
|
|
|
this.props.dispatch(toggleCameraFacingMode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
Object.assign(Toolbar.prototype, {
|
|
|
|
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-01-28 23:34:57 +00:00
|
|
|
export default connect(_mapStateToProps)(Toolbar);
|