From e08aeca28c9b062d8126f0b341e7b3fed2c5456d Mon Sep 17 00:00:00 2001 From: Bettenbuk Zoltan Date: Tue, 16 Jul 2019 14:13:41 +0100 Subject: [PATCH] feat: use css to place the toolbox buttons --- .../toolbox/components/native/Toolbox.js | 86 +------------------ .../toolbox/components/native/styles.js | 14 +-- 2 files changed, 9 insertions(+), 91 deletions(-) diff --git a/react/features/toolbox/components/native/Toolbox.js b/react/features/toolbox/components/native/Toolbox.js index 387401bc4..7e0db4944 100644 --- a/react/features/toolbox/components/native/Toolbox.js +++ b/react/features/toolbox/components/native/Toolbox.js @@ -20,15 +20,6 @@ import OverflowMenuButton from './OverflowMenuButton'; import styles from './styles'; import VideoMuteButton from '../VideoMuteButton'; -/** - * The number of buttons to render in - * {@link Toolbox}. - * - * @private - * @type number - */ -const _BUTTON_COUNT = 5; - /** * The type of {@link Toolbox}'s React {@code Component} props. */ @@ -103,39 +94,6 @@ class Toolbox extends Component { ); } - /** - * Calculates how large our toolbar buttons can be, given the available - * width. In the future we might want to have a size threshold, and once - * it's passed a completely different style could be used, akin to the web. - * - * @private - * @returns {number} - */ - _calculateButtonSize() { - const { _styles } = this.props; - const { width } = this.state; - - if (width <= 0) { - // We don't know how much space is allocated to the toolbar yet. - return width; - } - - const { style } = _styles.buttonStyles; - let buttonSize - = (width - - // Account for the horizontal margins of all buttons: - - (_BUTTON_COUNT * style.marginHorizontal * 2)) / _BUTTON_COUNT; - - // Well, don't return a non-positive button size. - if (buttonSize <= 0) { - buttonSize = style.width; - } - - // Make sure it's an even number. - return 2 * Math.round(buttonSize / 2); - } - /** * Constructs the toggled style of the chat button. This cannot be done by * simple style inheritance due to the size calculation done in this @@ -167,24 +125,6 @@ class Toolbox extends Component { }; } - /** - * Applies the recalculated size to the button style object, if needed. - * - * @param {Object} baseStyle - The base style object of the button. - * @param {Object} extraStyle - The extra style object of the button. - * @returns {Object} - */ - _getResizedStyle(baseStyle, extraStyle) { - if (baseStyle.style.width !== extraStyle.width) { - return { - ...baseStyle, - style: [ baseStyle.style, extraStyle ] - }; - } - - return baseStyle; - } - _onLayout: (Object) => void; /** @@ -208,31 +148,7 @@ class Toolbox extends Component { */ _renderToolbar() { const { _chatEnabled, _styles } = this.props; - const buttonSize = this._calculateButtonSize(); - let { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles; - - if (buttonSize > 0) { - const extraButtonStyle = { - borderRadius: buttonSize / 2, - height: buttonSize, - width: buttonSize - }; - - // XXX The following width equality checks attempt to minimize - // unnecessary objects and possibly re-renders. - // - // TODO: This needs a refactor! - buttonStyles = this._getResizedStyle(buttonStyles, extraButtonStyle); - buttonStylesBorderless = this._getResizedStyle(buttonStylesBorderless, extraButtonStyle); - hangupButtonStyles = this._getResizedStyle(hangupButtonStyles, extraButtonStyle); - toggledButtonStyles = this._getResizedStyle(toggledButtonStyles, extraButtonStyle); - } else { - // XXX In order to avoid a weird visual effect in which the toolbar - // is (visually) rendered and then visibly changes its size, it is - // rendered only after we've figured out the width available to the - // toolbar. - return null; - } + const { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles; return (