|
@@ -20,15 +20,6 @@ import OverflowMenuButton from './OverflowMenuButton';
|
20
|
20
|
import styles from './styles';
|
21
|
21
|
import VideoMuteButton from '../VideoMuteButton';
|
22
|
22
|
|
23
|
|
-/**
|
24
|
|
- * The number of buttons to render in
|
25
|
|
- * {@link Toolbox}.
|
26
|
|
- *
|
27
|
|
- * @private
|
28
|
|
- * @type number
|
29
|
|
- */
|
30
|
|
-const _BUTTON_COUNT = 5;
|
31
|
|
-
|
32
|
23
|
/**
|
33
|
24
|
* The type of {@link Toolbox}'s React {@code Component} props.
|
34
|
25
|
*/
|
|
@@ -103,39 +94,6 @@ class Toolbox extends Component<Props, State> {
|
103
|
94
|
);
|
104
|
95
|
}
|
105
|
96
|
|
106
|
|
- /**
|
107
|
|
- * Calculates how large our toolbar buttons can be, given the available
|
108
|
|
- * width. In the future we might want to have a size threshold, and once
|
109
|
|
- * it's passed a completely different style could be used, akin to the web.
|
110
|
|
- *
|
111
|
|
- * @private
|
112
|
|
- * @returns {number}
|
113
|
|
- */
|
114
|
|
- _calculateButtonSize() {
|
115
|
|
- const { _styles } = this.props;
|
116
|
|
- const { width } = this.state;
|
117
|
|
-
|
118
|
|
- if (width <= 0) {
|
119
|
|
- // We don't know how much space is allocated to the toolbar yet.
|
120
|
|
- return width;
|
121
|
|
- }
|
122
|
|
-
|
123
|
|
- const { style } = _styles.buttonStyles;
|
124
|
|
- let buttonSize
|
125
|
|
- = (width
|
126
|
|
-
|
127
|
|
- // Account for the horizontal margins of all buttons:
|
128
|
|
- - (_BUTTON_COUNT * style.marginHorizontal * 2)) / _BUTTON_COUNT;
|
129
|
|
-
|
130
|
|
- // Well, don't return a non-positive button size.
|
131
|
|
- if (buttonSize <= 0) {
|
132
|
|
- buttonSize = style.width;
|
133
|
|
- }
|
134
|
|
-
|
135
|
|
- // Make sure it's an even number.
|
136
|
|
- return 2 * Math.round(buttonSize / 2);
|
137
|
|
- }
|
138
|
|
-
|
139
|
97
|
/**
|
140
|
98
|
* Constructs the toggled style of the chat button. This cannot be done by
|
141
|
99
|
* simple style inheritance due to the size calculation done in this
|
|
@@ -167,24 +125,6 @@ class Toolbox extends Component<Props, State> {
|
167
|
125
|
};
|
168
|
126
|
}
|
169
|
127
|
|
170
|
|
- /**
|
171
|
|
- * Applies the recalculated size to the button style object, if needed.
|
172
|
|
- *
|
173
|
|
- * @param {Object} baseStyle - The base style object of the button.
|
174
|
|
- * @param {Object} extraStyle - The extra style object of the button.
|
175
|
|
- * @returns {Object}
|
176
|
|
- */
|
177
|
|
- _getResizedStyle(baseStyle, extraStyle) {
|
178
|
|
- if (baseStyle.style.width !== extraStyle.width) {
|
179
|
|
- return {
|
180
|
|
- ...baseStyle,
|
181
|
|
- style: [ baseStyle.style, extraStyle ]
|
182
|
|
- };
|
183
|
|
- }
|
184
|
|
-
|
185
|
|
- return baseStyle;
|
186
|
|
- }
|
187
|
|
-
|
188
|
128
|
_onLayout: (Object) => void;
|
189
|
129
|
|
190
|
130
|
/**
|
|
@@ -208,31 +148,7 @@ class Toolbox extends Component<Props, State> {
|
208
|
148
|
*/
|
209
|
149
|
_renderToolbar() {
|
210
|
150
|
const { _chatEnabled, _styles } = this.props;
|
211
|
|
- const buttonSize = this._calculateButtonSize();
|
212
|
|
- let { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
|
213
|
|
-
|
214
|
|
- if (buttonSize > 0) {
|
215
|
|
- const extraButtonStyle = {
|
216
|
|
- borderRadius: buttonSize / 2,
|
217
|
|
- height: buttonSize,
|
218
|
|
- width: buttonSize
|
219
|
|
- };
|
220
|
|
-
|
221
|
|
- // XXX The following width equality checks attempt to minimize
|
222
|
|
- // unnecessary objects and possibly re-renders.
|
223
|
|
- //
|
224
|
|
- // TODO: This needs a refactor!
|
225
|
|
- buttonStyles = this._getResizedStyle(buttonStyles, extraButtonStyle);
|
226
|
|
- buttonStylesBorderless = this._getResizedStyle(buttonStylesBorderless, extraButtonStyle);
|
227
|
|
- hangupButtonStyles = this._getResizedStyle(hangupButtonStyles, extraButtonStyle);
|
228
|
|
- toggledButtonStyles = this._getResizedStyle(toggledButtonStyles, extraButtonStyle);
|
229
|
|
- } else {
|
230
|
|
- // XXX In order to avoid a weird visual effect in which the toolbar
|
231
|
|
- // is (visually) rendered and then visibly changes its size, it is
|
232
|
|
- // rendered only after we've figured out the width available to the
|
233
|
|
- // toolbar.
|
234
|
|
- return null;
|
235
|
|
- }
|
|
151
|
+ const { buttonStyles, buttonStylesBorderless, hangupButtonStyles, toggledButtonStyles } = _styles;
|
236
|
152
|
|
237
|
153
|
return (
|
238
|
154
|
<View
|