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.

Toolbox.native.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { View } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { Container } from '../../base/react';
  6. import {
  7. isNarrowAspectRatio,
  8. makeAspectRatioAware
  9. } from '../../base/responsive-ui';
  10. import { ColorPalette } from '../../base/styles';
  11. import styles from './styles';
  12. import {
  13. AudioMuteButton,
  14. AudioOnlyButton,
  15. AudioRouteButton,
  16. HangupButton,
  17. PictureInPictureButton,
  18. RoomLockButton,
  19. InviteButton,
  20. ToggleCameraButton,
  21. VideoMuteButton
  22. } from './buttons';
  23. /**
  24. * Styles for the hangup button.
  25. */
  26. const hangupButtonStyles = {
  27. iconStyle: styles.whitePrimaryToolbarButtonIcon,
  28. style: styles.hangup,
  29. underlayColor: ColorPalette.buttonUnderlay
  30. };
  31. /**
  32. * Styles for buttons in the primary toolbar.
  33. */
  34. const primaryToolbarButtonStyles = {
  35. iconStyle: styles.primaryToolbarButtonIcon,
  36. style: styles.primaryToolbarButton
  37. };
  38. /**
  39. * Styles for buttons in the primary toolbar.
  40. */
  41. const primaryToolbarToggledButtonStyles = {
  42. iconStyle: styles.whitePrimaryToolbarButtonIcon,
  43. style: styles.whitePrimaryToolbarButton
  44. };
  45. /**
  46. * Styles for buttons in the secondary toolbar.
  47. */
  48. const secondaryToolbarButtonStyles = {
  49. iconStyle: styles.secondaryToolbarButtonIcon,
  50. style: styles.secondaryToolbarButton,
  51. underlayColor: 'transparent'
  52. };
  53. /**
  54. * The type of {@link Toolbox}'s React {@code Component} props.
  55. */
  56. type Props = {
  57. /**
  58. * The indicator which determines whether the toolbox is enabled.
  59. */
  60. _enabled: boolean,
  61. /**
  62. * Flag showing whether toolbar is visible.
  63. */
  64. _visible: boolean
  65. };
  66. /**
  67. * Implements the conference toolbox on React Native.
  68. */
  69. class Toolbox extends Component<Props> {
  70. /**
  71. * Implements React's {@link Component#render()}.
  72. *
  73. * @inheritdoc
  74. * @returns {ReactElement}
  75. */
  76. render() {
  77. if (!this.props._enabled) {
  78. return null;
  79. }
  80. const toolboxStyle
  81. = isNarrowAspectRatio(this)
  82. ? styles.toolboxNarrow
  83. : styles.toolboxWide;
  84. return (
  85. <Container
  86. style = { toolboxStyle }
  87. visible = { this.props._visible } >
  88. { this._renderToolbars() }
  89. </Container>
  90. );
  91. }
  92. /**
  93. * Renders the toolbar which contains the primary buttons such as hangup,
  94. * audio and video mute.
  95. *
  96. * @private
  97. * @returns {ReactElement}
  98. */
  99. _renderPrimaryToolbar() {
  100. return (
  101. <View
  102. key = 'primaryToolbar'
  103. pointerEvents = 'box-none'
  104. style = { styles.primaryToolbar }>
  105. <AudioMuteButton
  106. styles = { primaryToolbarButtonStyles }
  107. toggledStyles = { primaryToolbarToggledButtonStyles } />
  108. <HangupButton styles = { hangupButtonStyles } />
  109. <VideoMuteButton
  110. styles = { primaryToolbarButtonStyles }
  111. toggledStyles = { primaryToolbarToggledButtonStyles } />
  112. </View>
  113. );
  114. }
  115. /**
  116. * Renders the toolbar which contains the secondary buttons such as toggle
  117. * camera facing mode.
  118. *
  119. * @private
  120. * @returns {ReactElement}
  121. */
  122. _renderSecondaryToolbar() {
  123. return (
  124. <View
  125. key = 'secondaryToolbar'
  126. pointerEvents = 'box-none'
  127. style = { styles.secondaryToolbar }>
  128. <AudioRouteButton styles = { secondaryToolbarButtonStyles } />
  129. <ToggleCameraButton styles = { secondaryToolbarButtonStyles } />
  130. <AudioOnlyButton styles = { secondaryToolbarButtonStyles } />
  131. <RoomLockButton styles = { secondaryToolbarButtonStyles } />
  132. <InviteButton styles = { secondaryToolbarButtonStyles } />
  133. <PictureInPictureButton
  134. styles = { secondaryToolbarButtonStyles } />
  135. </View>
  136. );
  137. }
  138. /**
  139. * Renders the primary and the secondary toolbars.
  140. *
  141. * @private
  142. * @returns {[ReactElement, ReactElement]}
  143. */
  144. _renderToolbars() {
  145. return [
  146. this._renderSecondaryToolbar(),
  147. this._renderPrimaryToolbar()
  148. ];
  149. }
  150. }
  151. /**
  152. * Maps parts of the redux state to {@link Toolbox} (React {@code Component})
  153. * props.
  154. *
  155. * @param {Object} state - The redux state of which parts are to be mapped to
  156. * {@code Toolbox} props.
  157. * @protected
  158. * @returns {{
  159. * _enabled: boolean,
  160. * _visible: boolean
  161. * }}
  162. */
  163. function _mapStateToProps(state: Object): Object {
  164. const { enabled, visible } = state['features/toolbox'];
  165. return {
  166. /**
  167. * The indicator which determines whether the toolbox is enabled.
  168. *
  169. * @private
  170. * @type {boolean}
  171. */
  172. _enabled: enabled,
  173. /**
  174. * Flag showing whether toolbox is visible.
  175. *
  176. * @protected
  177. * @type {boolean}
  178. */
  179. _visible: visible
  180. };
  181. }
  182. export default connect(_mapStateToProps)(makeAspectRatioAware(Toolbox));