2021-03-22 11:02:57 +02:00
|
|
|
import React from 'react';
|
2023-05-02 11:09:38 +03:00
|
|
|
import { View, ViewStyle } from 'react-native';
|
2025-12-02 16:34:57 +02:00
|
|
|
import { Edge, SafeAreaView } from 'react-native-safe-area-context';
|
2025-02-11 16:17:13 +02:00
|
|
|
import { connect, useSelector } from 'react-redux';
|
2016-10-05 09:36:59 -05:00
|
|
|
|
2025-01-23 14:58:22 +02:00
|
|
|
import { IReduxState, IStore } from '../../../app/types';
|
2023-03-31 14:04:33 +03:00
|
|
|
import ColorSchemeRegistry from '../../../base/color-scheme/ColorSchemeRegistry';
|
2023-04-03 16:33:18 +03:00
|
|
|
import Platform from '../../../base/react/Platform.native';
|
2023-02-23 12:43:16 -06:00
|
|
|
import { iAmVisitor } from '../../../visitors/functions';
|
2025-01-23 14:58:22 +02:00
|
|
|
import { customButtonPressed } from '../../actions.native';
|
2025-02-11 16:17:13 +02:00
|
|
|
import { getVisibleNativeButtons, isToolboxVisible } from '../../functions.native';
|
|
|
|
|
import { useNativeToolboxButtons } from '../../hooks.native';
|
|
|
|
|
import { IToolboxNativeButton } from '../../types';
|
2016-10-05 09:36:59 -05:00
|
|
|
|
2025-02-11 16:17:13 +02:00
|
|
|
import styles from './styles';
|
2025-01-23 14:58:22 +02:00
|
|
|
|
2018-04-18 16:34:40 +02:00
|
|
|
/**
|
|
|
|
|
* The type of {@link Toolbox}'s React {@code Component} props.
|
|
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
interface IProps {
|
2018-02-06 11:41:23 +01:00
|
|
|
|
2022-03-01 17:41:45 +02:00
|
|
|
/**
|
2023-05-02 11:09:38 +03:00
|
|
|
* Whether we are in visitors mode.
|
2022-03-01 17:41:45 +02:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_iAmVisitor: boolean;
|
2022-03-01 17:41:45 +02:00
|
|
|
|
2018-02-19 16:52:21 -06:00
|
|
|
/**
|
2023-05-02 11:09:38 +03:00
|
|
|
* The color-schemed stylesheet of the feature.
|
2018-02-19 16:52:21 -06:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_styles: any;
|
2016-10-05 09:36:59 -05:00
|
|
|
|
2023-02-14 09:24:38 -06:00
|
|
|
/**
|
2023-05-02 11:09:38 +03:00
|
|
|
* The indicator which determines whether the toolbox is visible.
|
2023-02-14 09:24:38 -06:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
_visible: boolean;
|
2023-02-14 09:24:38 -06:00
|
|
|
|
2025-01-23 14:58:22 +02:00
|
|
|
/**
|
|
|
|
|
* Redux store dispatch method.
|
|
|
|
|
*/
|
|
|
|
|
dispatch: IStore['dispatch'];
|
2023-05-02 11:09:38 +03:00
|
|
|
}
|
2018-05-15 13:18:42 +02:00
|
|
|
|
2018-02-19 16:52:21 -06:00
|
|
|
/**
|
2021-03-22 11:02:57 +02:00
|
|
|
* Implements the conference Toolbox on React Native.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} props - The props of the component.
|
2024-02-27 12:56:05 +02:00
|
|
|
* @returns {React$Element}
|
2018-02-19 16:52:21 -06:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
function Toolbox(props: IProps) {
|
2025-01-23 14:58:22 +02:00
|
|
|
const {
|
|
|
|
|
_iAmVisitor,
|
|
|
|
|
_styles,
|
|
|
|
|
_visible,
|
|
|
|
|
dispatch
|
|
|
|
|
} = props;
|
2022-03-01 17:41:45 +02:00
|
|
|
|
|
|
|
|
if (!_visible) {
|
2021-03-22 11:02:57 +02:00
|
|
|
return null;
|
2017-10-19 13:29:34 -05:00
|
|
|
}
|
2018-05-16 16:49:03 -05:00
|
|
|
|
2025-02-11 16:17:13 +02:00
|
|
|
const { clientWidth } = useSelector((state: IReduxState) => state['features/base/responsive-ui']);
|
|
|
|
|
const { customToolbarButtons } = useSelector((state: IReduxState) => state['features/base/config']);
|
2025-11-11 18:32:28 +05:30
|
|
|
const toolbarBackgroundColor = useSelector((state: IReduxState) => state['features/base/config'].toolbarConfig?.backgroundColor);
|
2025-02-11 16:17:13 +02:00
|
|
|
const {
|
|
|
|
|
mainToolbarButtonsThresholds,
|
|
|
|
|
toolbarButtons
|
|
|
|
|
} = useSelector((state: IReduxState) => state['features/toolbox']);
|
|
|
|
|
|
|
|
|
|
const allButtons = useNativeToolboxButtons(customToolbarButtons);
|
|
|
|
|
|
|
|
|
|
const { mainMenuButtons } = getVisibleNativeButtons({
|
|
|
|
|
allButtons,
|
|
|
|
|
clientWidth,
|
2025-06-05 16:44:47 -05:00
|
|
|
iAmVisitor: _iAmVisitor,
|
2025-02-11 16:17:13 +02:00
|
|
|
mainToolbarButtonsThresholds,
|
|
|
|
|
toolbarButtons
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-01 17:41:45 +02:00
|
|
|
const bottomEdge = Platform.OS === 'ios' && _visible;
|
2025-02-11 16:17:13 +02:00
|
|
|
const { buttonStylesBorderless, hangupButtonStyles } = _styles;
|
2023-03-28 08:08:56 -05:00
|
|
|
const style = { ...styles.toolbox };
|
|
|
|
|
|
2025-11-11 18:32:28 +05:30
|
|
|
// Allow overriding the toolbox background color from config (configOverwrite/overwriteConfig).
|
|
|
|
|
if (toolbarBackgroundColor) {
|
|
|
|
|
style.backgroundColor = toolbarBackgroundColor as any;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 16:17:13 +02:00
|
|
|
// We have only hangup and raisehand button in _iAmVisitor mode
|
2023-03-28 08:08:56 -05:00
|
|
|
if (_iAmVisitor) {
|
|
|
|
|
style.justifyContent = 'center';
|
|
|
|
|
}
|
2019-01-22 11:35:28 +01:00
|
|
|
|
2025-02-11 16:17:13 +02:00
|
|
|
const renderToolboxButtons = () => {
|
|
|
|
|
if (!mainMenuButtons?.length) {
|
2025-01-23 14:58:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{
|
2025-02-11 16:17:13 +02:00
|
|
|
mainMenuButtons?.map(({ Content, key, text, ...rest }: IToolboxNativeButton) => (
|
|
|
|
|
<Content
|
|
|
|
|
{ ...rest }
|
2025-01-23 14:58:22 +02:00
|
|
|
/* eslint-disable react/jsx-no-bind */
|
2025-02-11 16:17:13 +02:00
|
|
|
handleClick = { () => dispatch(customButtonPressed(key, text)) }
|
2025-02-03 13:34:40 +02:00
|
|
|
isToolboxButton = { true }
|
2025-02-11 16:17:13 +02:00
|
|
|
key = { key }
|
|
|
|
|
styles = { key === 'hangup' ? hangupButtonStyles : buttonStylesBorderless } />
|
2025-01-23 14:58:22 +02:00
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-22 11:02:57 +02:00
|
|
|
return (
|
2023-04-04 13:33:30 +03:00
|
|
|
<View
|
2023-05-02 11:09:38 +03:00
|
|
|
style = { styles.toolboxContainer as ViewStyle }>
|
2021-03-22 11:02:57 +02:00
|
|
|
<SafeAreaView
|
|
|
|
|
accessibilityRole = 'toolbar'
|
2025-12-02 16:34:57 +02:00
|
|
|
edges = { [ bottomEdge && 'bottom' ].filter(Boolean) as Edge[] }
|
2021-03-22 11:02:57 +02:00
|
|
|
pointerEvents = 'box-none'
|
2023-05-02 11:09:38 +03:00
|
|
|
style = { style as ViewStyle }>
|
2025-02-11 16:17:13 +02:00
|
|
|
{ renderToolboxButtons() }
|
2021-03-22 11:02:57 +02:00
|
|
|
</SafeAreaView>
|
2023-04-04 13:33:30 +03:00
|
|
|
</View>
|
2021-03-22 11:02:57 +02:00
|
|
|
);
|
2016-10-05 09:36:59 -05:00
|
|
|
}
|
|
|
|
|
|
2017-02-16 17:02:40 -06:00
|
|
|
/**
|
2018-04-18 16:34:40 +02:00
|
|
|
* Maps parts of the redux state to {@link Toolbox} (React {@code Component})
|
2018-02-19 16:52:21 -06:00
|
|
|
* props.
|
2017-02-16 17:02:40 -06:00
|
|
|
*
|
2018-04-18 16:34:40 +02:00
|
|
|
* @param {Object} state - The redux state of which parts are to be mapped to
|
|
|
|
|
* {@code Toolbox} props.
|
2018-05-10 21:10:26 -05:00
|
|
|
* @private
|
2023-05-02 11:09:38 +03:00
|
|
|
* @returns {IProps}
|
2017-02-16 17:02:40 -06:00
|
|
|
*/
|
2023-05-02 11:09:38 +03:00
|
|
|
function _mapStateToProps(state: IReduxState) {
|
2017-02-16 17:02:40 -06:00
|
|
|
return {
|
2025-02-11 16:17:13 +02:00
|
|
|
_iAmVisitor: iAmVisitor(state),
|
2019-01-22 11:35:28 +01:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Toolbox'),
|
2021-03-22 11:02:57 +02:00
|
|
|
_visible: isToolboxVisible(state),
|
2017-02-16 17:02:40 -06:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-29 14:04:05 -05:00
|
|
|
export default connect(_mapStateToProps)(Toolbox);
|