Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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