2018-02-19 22:52:21 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-03-22 09:02:57 +00:00
|
|
|
import React from 'react';
|
2022-03-01 15:41:45 +00:00
|
|
|
import { View } from 'react-native';
|
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2022-03-01 15:41:45 +00:00
|
|
|
import { Platform } from '../../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2019-01-13 19:34:38 +00:00
|
|
|
import { ChatButton } from '../../../chat';
|
2021-07-13 06:50:08 +00:00
|
|
|
import { ReactionsMenuButton } from '../../../reactions/components';
|
2021-08-31 11:00:27 +00:00
|
|
|
import { isReactionsEnabled } from '../../../reactions/functions.any';
|
2021-03-22 09:02:57 +00:00
|
|
|
import { TileViewButton } from '../../../video-layout';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { getMovableButtons, isToolboxVisible } from '../../functions.native';
|
2018-05-10 23:01:55 +00:00
|
|
|
import AudioMuteButton from '../AudioMuteButton';
|
|
|
|
import HangupButton from '../HangupButton';
|
2020-05-20 10:57:03 +00:00
|
|
|
import VideoMuteButton from '../VideoMuteButton';
|
2019-01-30 17:19:40 +00:00
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
import HangupMenuButton from './HangupMenuButton';
|
2018-05-15 11:18:42 +00:00
|
|
|
import OverflowMenuButton from './OverflowMenuButton';
|
2021-07-22 10:17:42 +00:00
|
|
|
import RaiseHandButton from './RaiseHandButton';
|
2022-09-26 20:33:27 +00:00
|
|
|
import ScreenSharingButton from './ScreenSharingButton';
|
2019-01-22 10:35:28 +00:00
|
|
|
import styles from './styles';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2018-04-18 14:34:40 +00:00
|
|
|
/**
|
|
|
|
* The type of {@link Toolbox}'s React {@code Component} props.
|
|
|
|
*/
|
|
|
|
type Props = {
|
2018-02-06 10:41:23 +00:00
|
|
|
|
2022-08-26 18:25:04 +00:00
|
|
|
/**
|
|
|
|
* Whether the end conference feature is supported.
|
|
|
|
*/
|
|
|
|
_endConferenceSupported: boolean,
|
|
|
|
|
2022-03-01 15:41:45 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the reactions feature is enabled.
|
|
|
|
*/
|
|
|
|
_reactionsEnabled: boolean,
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
*/
|
|
|
|
_styles: StyleType,
|
|
|
|
|
2018-02-19 22:52:21 +00:00
|
|
|
/**
|
2018-05-15 11:18:42 +00:00
|
|
|
* The indicator which determines whether the toolbox is visible.
|
2018-02-19 22:52:21 +00:00
|
|
|
*/
|
2018-05-15 11:18:42 +00:00
|
|
|
_visible: boolean,
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2023-02-14 15:24:38 +00:00
|
|
|
/**
|
|
|
|
* Whether we are in visitors mode.
|
|
|
|
*/
|
|
|
|
_visitorsModeEnabled: boolean,
|
|
|
|
|
2021-03-22 09:02:57 +00:00
|
|
|
/**
|
|
|
|
* The width of the screen.
|
|
|
|
*/
|
2022-03-01 15:41:45 +00:00
|
|
|
_width: number
|
2018-05-15 11:18:42 +00:00
|
|
|
};
|
|
|
|
|
2018-02-19 22:52:21 +00:00
|
|
|
/**
|
2021-03-22 09:02:57 +00:00
|
|
|
* Implements the conference Toolbox on React Native.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The props of the component.
|
|
|
|
* @returns {React$Element}.
|
2018-02-19 22:52:21 +00:00
|
|
|
*/
|
2021-03-22 09:02:57 +00:00
|
|
|
function Toolbox(props: Props) {
|
2023-02-14 15:24:38 +00:00
|
|
|
const { _endConferenceSupported, _reactionsEnabled, _styles, _visible, _visitorsModeEnabled, _width } = props;
|
2022-03-01 15:41:45 +00:00
|
|
|
|
|
|
|
if (!_visible) {
|
2021-03-22 09:02:57 +00:00
|
|
|
return null;
|
2017-10-19 18:29:34 +00:00
|
|
|
}
|
2018-05-16 21:49:03 +00:00
|
|
|
|
2022-03-01 15:41:45 +00:00
|
|
|
const bottomEdge = Platform.OS === 'ios' && _visible;
|
2022-08-26 18:25:04 +00:00
|
|
|
const { buttonStylesBorderless, hangupButtonStyles, hangupMenuButtonStyles, toggledButtonStyles } = _styles;
|
2021-03-22 09:02:57 +00:00
|
|
|
const additionalButtons = getMovableButtons(_width);
|
|
|
|
const backgroundToggledStyle = {
|
|
|
|
...toggledButtonStyles,
|
|
|
|
style: [
|
|
|
|
toggledButtonStyles.style,
|
|
|
|
_styles.backgroundToggle
|
|
|
|
]
|
|
|
|
};
|
2019-01-22 10:35:28 +00:00
|
|
|
|
2021-03-22 09:02:57 +00:00
|
|
|
return (
|
|
|
|
<View
|
|
|
|
pointerEvents = 'box-none'
|
|
|
|
style = { styles.toolboxContainer }>
|
|
|
|
<SafeAreaView
|
|
|
|
accessibilityRole = 'toolbar'
|
2022-03-01 15:41:45 +00:00
|
|
|
edges = { [ bottomEdge && 'bottom' ].filter(Boolean) }
|
2021-03-22 09:02:57 +00:00
|
|
|
pointerEvents = 'box-none'
|
|
|
|
style = { styles.toolbox }>
|
2023-02-14 15:24:38 +00:00
|
|
|
{!_visitorsModeEnabled && <AudioMuteButton
|
2021-03-22 09:02:57 +00:00
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
2023-02-14 15:24:38 +00:00
|
|
|
}
|
|
|
|
{!_visitorsModeEnabled && <VideoMuteButton
|
2021-03-22 09:02:57 +00:00
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
2023-02-14 15:24:38 +00:00
|
|
|
}
|
|
|
|
{!_visitorsModeEnabled && additionalButtons.has('chat')
|
2021-03-22 09:02:57 +00:00
|
|
|
&& <ChatButton
|
|
|
|
styles = { buttonStylesBorderless }
|
2021-10-20 19:29:21 +00:00
|
|
|
toggledStyles = { backgroundToggledStyle } />
|
|
|
|
}
|
2023-02-14 15:24:38 +00:00
|
|
|
{!_visitorsModeEnabled && additionalButtons.has('screensharing')
|
|
|
|
&& <ScreenSharingButton styles = { buttonStylesBorderless } />}
|
|
|
|
{ !_visitorsModeEnabled && additionalButtons.has('raisehand') && (_reactionsEnabled
|
2021-07-22 10:17:42 +00:00
|
|
|
? <ReactionsMenuButton
|
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
toggledStyles = { backgroundToggledStyle } />
|
|
|
|
: <RaiseHandButton
|
2021-07-13 06:50:08 +00:00
|
|
|
styles = { buttonStylesBorderless }
|
2021-07-22 10:17:42 +00:00
|
|
|
toggledStyles = { backgroundToggledStyle } />)}
|
2021-03-22 09:02:57 +00:00
|
|
|
{additionalButtons.has('tileview') && <TileViewButton styles = { buttonStylesBorderless } />}
|
2023-02-14 15:24:38 +00:00
|
|
|
{!_visitorsModeEnabled && <OverflowMenuButton
|
2021-03-22 09:02:57 +00:00
|
|
|
styles = { buttonStylesBorderless }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
2023-02-14 15:24:38 +00:00
|
|
|
}
|
2022-08-26 18:25:04 +00:00
|
|
|
{ _endConferenceSupported
|
|
|
|
? <HangupMenuButton
|
|
|
|
styles = { hangupMenuButtonStyles }
|
|
|
|
toggledStyles = { toggledButtonStyles } />
|
|
|
|
: <HangupButton
|
|
|
|
styles = { hangupButtonStyles } />
|
|
|
|
}
|
2021-03-22 09:02:57 +00:00
|
|
|
</SafeAreaView>
|
|
|
|
</View>
|
|
|
|
);
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
2018-04-18 14:34:40 +00:00
|
|
|
* Maps parts of the redux state to {@link Toolbox} (React {@code Component})
|
2018-02-19 22:52:21 +00:00
|
|
|
* props.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
2018-04-18 14:34:40 +00:00
|
|
|
* @param {Object} state - The redux state of which parts are to be mapped to
|
|
|
|
* {@code Toolbox} props.
|
2018-05-11 02:10:26 +00:00
|
|
|
* @private
|
2020-04-29 07:35:18 +00:00
|
|
|
* @returns {Props}
|
2017-02-16 23:02:40 +00:00
|
|
|
*/
|
2018-04-18 14:34:40 +00:00
|
|
|
function _mapStateToProps(state: Object): Object {
|
2022-08-26 18:25:04 +00:00
|
|
|
const { conference } = state['features/base/conference'];
|
|
|
|
const endConferenceSupported = conference?.isEndConferenceSupported();
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
return {
|
2022-08-26 18:25:04 +00:00
|
|
|
_endConferenceSupported: Boolean(endConferenceSupported),
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Toolbox'),
|
2021-03-22 09:02:57 +00:00
|
|
|
_visible: isToolboxVisible(state),
|
2023-02-14 15:24:38 +00:00
|
|
|
_visitorsModeEnabled: state['features/visitors'].enabled,
|
2021-07-22 10:17:42 +00:00
|
|
|
_width: state['features/base/responsive-ui'].clientWidth,
|
2021-08-31 11:00:27 +00:00
|
|
|
_reactionsEnabled: isReactionsEnabled(state)
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-29 19:04:05 +00:00
|
|
|
export default connect(_mapStateToProps)(Toolbox);
|