Selaa lähdekoodia

feat: use css to place the toolbox buttons

j8
Bettenbuk Zoltan 6 vuotta sitten
vanhempi
commit
e08aeca28c

+ 1
- 85
react/features/toolbox/components/native/Toolbox.js Näytä tiedosto

20
 import styles from './styles';
20
 import styles from './styles';
21
 import VideoMuteButton from '../VideoMuteButton';
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
  * The type of {@link Toolbox}'s React {@code Component} props.
24
  * The type of {@link Toolbox}'s React {@code Component} props.
34
  */
25
  */
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
      * Constructs the toggled style of the chat button. This cannot be done by
98
      * Constructs the toggled style of the chat button. This cannot be done by
141
      * simple style inheritance due to the size calculation done in this
99
      * simple style inheritance due to the size calculation done in this
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
     _onLayout: (Object) => void;
128
     _onLayout: (Object) => void;
189
 
129
 
190
     /**
130
     /**
208
      */
148
      */
209
     _renderToolbar() {
149
     _renderToolbar() {
210
         const { _chatEnabled, _styles } = this.props;
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
         return (
153
         return (
238
             <View
154
             <View

+ 8
- 6
react/features/toolbox/components/native/styles.js Näytä tiedosto

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { ColorSchemeRegistry, schemeColor } from '../../../base/color-scheme';
3
 import { ColorSchemeRegistry, schemeColor } from '../../../base/color-scheme';
4
-import { BoxModel, ColorPalette, createStyleSheet } from '../../../base/styles';
4
+import { BoxModel, ColorPalette } from '../../../base/styles';
5
+
6
+const BUTTON_SIZE = 50;
5
 
7
 
6
 // Toolbox, toolbar:
8
 // Toolbox, toolbar:
7
 
9
 
10
  */
12
  */
11
 const toolbarButton = {
13
 const toolbarButton = {
12
     backgroundColor: schemeColor('button'),
14
     backgroundColor: schemeColor('button'),
13
-    borderRadius: 20,
15
+    borderRadius: BUTTON_SIZE / 2,
14
     borderWidth: 0,
16
     borderWidth: 0,
15
     flex: 0,
17
     flex: 0,
16
     flexDirection: 'row',
18
     flexDirection: 'row',
17
-    height: 40,
19
+    height: BUTTON_SIZE,
18
     justifyContent: 'center',
20
     justifyContent: 'center',
19
 
21
 
20
     // XXX We probably tested BoxModel.margin and discovered it to be too small
22
     // XXX We probably tested BoxModel.margin and discovered it to be too small
21
     // for our taste.
23
     // for our taste.
22
     marginHorizontal: 7,
24
     marginHorizontal: 7,
23
-    width: 40
25
+    width: BUTTON_SIZE
24
 };
26
 };
25
 
27
 
26
 /**
28
 /**
51
 /**
53
 /**
52
  * The Toolbox and toolbar related styles.
54
  * The Toolbox and toolbar related styles.
53
  */
55
  */
54
-const styles = createStyleSheet({
56
+const styles = {
55
 
57
 
56
     /**
58
     /**
57
      * The style of the toolbar.
59
      * The style of the toolbar.
72
         flexDirection: 'column',
74
         flexDirection: 'column',
73
         flexGrow: 0
75
         flexGrow: 0
74
     }
76
     }
75
-});
77
+};
76
 
78
 
77
 export default styles;
79
 export default styles;
78
 
80
 

Loading…
Peruuta
Tallenna