jiti-meet/react/features/toolbox/components/native/Toolbox.js

159 lines
5.5 KiB
JavaScript
Raw Normal View History

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