You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Toolbar.native.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import React from 'react';
  2. import { View } from 'react-native';
  3. import { connect } from 'react-redux';
  4. import {
  5. MEDIA_TYPE,
  6. toggleCameraFacingMode
  7. } from '../../base/media';
  8. import { Container } from '../../base/react';
  9. import { ColorPalette } from '../../base/styles';
  10. import {
  11. AbstractToolbar,
  12. mapStateToProps
  13. } from './AbstractToolbar';
  14. import { styles } from './styles';
  15. import ToolbarButton from './ToolbarButton';
  16. /**
  17. * Implements the conference toolbar on React Native.
  18. *
  19. * @extends AbstractToolbar
  20. */
  21. class Toolbar extends AbstractToolbar {
  22. /**
  23. * Toolbar component's property types.
  24. *
  25. * @static
  26. */
  27. static propTypes = AbstractToolbar.propTypes
  28. /**
  29. * Initializes a new Toolbar instance.
  30. *
  31. * @param {Object} props - The read-only React Component props with which
  32. * the new instance is to be initialized.
  33. */
  34. constructor(props) {
  35. super(props);
  36. // Bind event handlers so they are only bound once for every instance.
  37. this._toggleCameraFacingMode
  38. = this._toggleCameraFacingMode.bind(this);
  39. }
  40. /**
  41. * Implements React's {@link Component#render()}.
  42. *
  43. * @inheritdoc
  44. * @returns {ReactElement}
  45. */
  46. render() {
  47. const audioButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.AUDIO);
  48. const videoButtonStyles = this._getMuteButtonStyles(MEDIA_TYPE.VIDEO);
  49. const underlayColor = ColorPalette.buttonUnderlay;
  50. // TODO Use correct Jitsi icon for camera switch button when available.
  51. /* eslint-disable react/jsx-handler-names */
  52. return (
  53. <Container
  54. style = { styles.toolbarContainer }
  55. visible = { this.props.visible }>
  56. <View style = { styles.toggleCameraFacingModeContainer }>
  57. <ToolbarButton
  58. iconName = 'reload'
  59. iconstyle = { styles.whiteIcon }
  60. onClick = { this._toggleCameraFacingMode }
  61. style = { styles.toggleCameraFacingModeButton }
  62. underlayColor = 'transparent' />
  63. </View>
  64. <View style = { styles.toolbarButtonsContainer }>
  65. <ToolbarButton
  66. iconName = { audioButtonStyles.iconName }
  67. iconStyle = { audioButtonStyles.iconStyle }
  68. onClick = { this._toggleAudio }
  69. style = { audioButtonStyles.buttonStyle } />
  70. <ToolbarButton
  71. iconName = 'hangup'
  72. iconStyle = { styles.whiteIcon }
  73. onClick = { this._onHangup }
  74. style = {{
  75. ...styles.toolbarButton,
  76. backgroundColor: ColorPalette.red
  77. }}
  78. underlayColor = { underlayColor } />
  79. <ToolbarButton
  80. iconName = { videoButtonStyles.iconName }
  81. iconStyle = { videoButtonStyles.iconStyle }
  82. onClick = { this._toggleVideo }
  83. style = { videoButtonStyles.buttonStyle } />
  84. </View>
  85. </Container>
  86. );
  87. /* eslint-enable react/jsx-handler-names */
  88. }
  89. /**
  90. * Switches between the front/user-facing and rear/environment-facing
  91. * cameras.
  92. *
  93. * @private
  94. * @returns {void}
  95. */
  96. _toggleCameraFacingMode() {
  97. this.props.dispatch(toggleCameraFacingMode());
  98. }
  99. }
  100. /**
  101. * Additional properties for various icons, which are now platform-dependent.
  102. * This is done to have common logic of generating styles for web and native.
  103. * TODO As soon as we have common font sets for web and native, this will no
  104. * longer be required.
  105. */
  106. Object.assign(Toolbar.prototype, {
  107. audioIcon: 'microphone',
  108. audioMutedIcon: 'mic-disabled',
  109. videoIcon: 'webCam',
  110. videoMutedIcon: 'camera-disabled'
  111. });
  112. export default connect(mapStateToProps)(Toolbar);