ソースを参照

React (Native) optimizations/performance

Remove toolbar button and icon style literals from the render method of
Toolbox.native.js.

Additionally, comply w/ coding style.
j8
Lyubo Marinov 8年前
コミット
1ec06f4bf0

+ 9
- 14
react/features/toolbox/components/Toolbox.native.js ファイルの表示

120
     _getMuteButtonStyles(mediaType) {
120
     _getMuteButtonStyles(mediaType) {
121
         let iconName;
121
         let iconName;
122
         let iconStyle;
122
         let iconStyle;
123
-        let style = styles.primaryToolbarButton;
123
+        let style;
124
 
124
 
125
         if (this.props[`_${mediaType}Muted`]) {
125
         if (this.props[`_${mediaType}Muted`]) {
126
             iconName = this[`${mediaType}MutedIcon`];
126
             iconName = this[`${mediaType}MutedIcon`];
127
-            iconStyle = styles.whiteIcon;
128
-            style = {
129
-                ...style,
130
-                backgroundColor: ColorPalette.buttonUnderlay
131
-            };
127
+            iconStyle = styles.whitePrimaryToolbarButtonIcon;
128
+            style = styles.whitePrimaryToolbarButton;
132
         } else {
129
         } else {
133
             iconName = this[`${mediaType}Icon`];
130
             iconName = this[`${mediaType}Icon`];
134
-            iconStyle = styles.icon;
131
+            iconStyle = styles.primaryToolbarButtonIcon;
132
+            style = styles.primaryToolbarButton;
135
         }
133
         }
136
 
134
 
137
         return {
135
         return {
163
                     style = { audioButtonStyles.style } />
161
                     style = { audioButtonStyles.style } />
164
                 <ToolbarButton
162
                 <ToolbarButton
165
                     iconName = 'hangup'
163
                     iconName = 'hangup'
166
-                    iconStyle = { styles.whiteIcon }
164
+                    iconStyle = { styles.whitePrimaryToolbarButtonIcon }
167
                     onClick = { this.props._onHangup }
165
                     onClick = { this.props._onHangup }
168
-                    style = {{
169
-                        ...styles.primaryToolbarButton,
170
-                        backgroundColor: ColorPalette.red
171
-                    }}
166
+                    style = { styles.hangup }
172
                     underlayColor = { ColorPalette.buttonUnderlay } />
167
                     underlayColor = { ColorPalette.buttonUnderlay } />
173
                 <ToolbarButton
168
                 <ToolbarButton
174
                     iconName = { videoButtonStyles.iconName }
169
                     iconName = { videoButtonStyles.iconName }
189
      * @returns {ReactElement}
184
      * @returns {ReactElement}
190
      */
185
      */
191
     _renderSecondaryToolbar() {
186
     _renderSecondaryToolbar() {
192
-        const iconStyle = styles.secondaryToolbarIcon;
187
+        const iconStyle = styles.secondaryToolbarButtonIcon;
193
         const style = styles.secondaryToolbarButton;
188
         const style = styles.secondaryToolbarButton;
194
         const underlayColor = 'transparent';
189
         const underlayColor = 'transparent';
195
 
190
 
213
                     underlayColor = { underlayColor } />
208
                     underlayColor = { underlayColor } />
214
                 <ToolbarButton
209
                 <ToolbarButton
215
                     iconName = 'hangup'
210
                     iconName = 'hangup'
216
-                    iconStyle = { styles.audioOnlyIcon }
211
+                    iconStyle = { styles.toggleAudioOnlyIcon }
217
                     onClick = { this.props._onToggleAudioOnly }
212
                     onClick = { this.props._onToggleAudioOnly }
218
                     style = { style }
213
                     style = { style }
219
                     underlayColor = { underlayColor } />
214
                     underlayColor = { underlayColor } />

+ 83
- 63
react/features/toolbox/components/styles.js ファイルの表示

1
 import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
1
 import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
2
 
2
 
3
 /**
3
 /**
4
- * The base style for (toolbar) buttons.
4
+ * The base style for toolbars.
5
  *
5
  *
6
  * @type {Object}
6
  * @type {Object}
7
  */
7
  */
8
-const button = {
9
-    borderRadius: 30,
10
-    borderWidth: 0,
11
-    flex: 0,
12
-    flexDirection: 'row',
13
-    height: 60,
14
-    justifyContent: 'center',
15
-    margin: BoxModel.margin,
16
-    width: 60
8
+const _toolbar = {
9
+    flex: 1,
10
+    position: 'absolute'
17
 };
11
 };
18
 
12
 
19
 /**
13
 /**
20
- * Small toolbar button.
14
+ * The base style of toolbar buttons (in primaryToolbar and secondaryToolbar).
21
  *
15
  *
22
- * @type {{borderRadius: number, flex: number, flexDirection: string,
23
- * height: number, justifyContent: string, margin: number, width: number}}
16
+ * @type {Object}
24
  */
17
  */
25
-const smallButton = {
26
-    borderRadius: 20,
18
+const _toolbarButton = {
27
     flex: 0,
19
     flex: 0,
28
-    flexDirection: 'column',
29
-    height: 40,
30
     justifyContent: 'center',
20
     justifyContent: 'center',
31
-    margin: BoxModel.margin / 2,
32
-    width: 40
21
+    opacity: 0.7
33
 };
22
 };
34
 
23
 
35
 /**
24
 /**
36
- * The base style for icons.
25
+ * The base icon style of toolbar buttons (in primaryToolbar and
26
+ * secondaryToolbar).
37
  *
27
  *
38
  * @type {Object}
28
  * @type {Object}
39
  */
29
  */
40
-const icon = {
41
-    alignSelf: 'center',
42
-    color: ColorPalette.darkGrey,
43
-    fontSize: 24
30
+const _toolbarButtonIcon = {
31
+    alignSelf: 'center'
32
+};
33
+
34
+/**
35
+ * The style of toolbar buttons in primaryToolbar.
36
+ */
37
+const primaryToolbarButton = {
38
+    ..._toolbarButton,
39
+    backgroundColor: ColorPalette.white,
40
+    borderRadius: 30,
41
+    borderWidth: 0,
42
+    flexDirection: 'row',
43
+    height: 60,
44
+    margin: BoxModel.margin,
45
+    width: 60
44
 };
46
 };
45
 
47
 
46
 /**
48
 /**
47
- * Small toolbar button icon.
49
+ * The icon style of the toolbar buttons in primaryToolbar.
48
  *
50
  *
49
- * @type {{fontSize: number}}
51
+ * @type {Object}
50
  */
52
  */
51
-const smallIcon = {
52
-    ...icon,
53
-    fontSize: 18
53
+const primaryToolbarButtonIcon = {
54
+    ..._toolbarButtonIcon,
55
+    color: ColorPalette.darkGrey,
56
+    fontSize: 24
54
 };
57
 };
55
 
58
 
56
 /**
59
 /**
57
- * The base style for toolbars.
60
+ * The icon style of the toolbar buttons in secondaryToolbar.
58
  *
61
  *
59
  * @type {Object}
62
  * @type {Object}
60
  */
63
  */
61
-const toolbar = {
62
-    flex: 1,
63
-    position: 'absolute'
64
+const secondaryToolbarButtonIcon = {
65
+    ..._toolbarButtonIcon,
66
+    color: ColorPalette.white,
67
+    fontSize: 18
64
 };
68
 };
65
 
69
 
66
 /**
70
 /**
68
  */
72
  */
69
 export const styles = createStyleSheet({
73
 export const styles = createStyleSheet({
70
     /**
74
     /**
71
-     * The audio only (secondary) toolbar icon style.
75
+     * The style of the toolbar button in {@link #primaryToolbar} which
76
+     * hangs the current conference up.
72
      */
77
      */
73
-    audioOnlyIcon: {
74
-        ...smallIcon,
75
-        color: ColorPalette.white,
76
-        transform: [ { rotate: '135deg' } ]
78
+    hangup: {
79
+        ...primaryToolbarButton,
80
+        backgroundColor: ColorPalette.red
77
     },
81
     },
78
 
82
 
79
-    /**
80
-     * The toolbar button icon style.
81
-     */
82
-    icon,
83
-
84
     /**
83
     /**
85
      * The style of the toolbar which contains the primary buttons such as
84
      * The style of the toolbar which contains the primary buttons such as
86
      * hangup, audio and video mute.
85
      * hangup, audio and video mute.
87
      */
86
      */
88
     primaryToolbar: {
87
     primaryToolbar: {
89
-        ...toolbar,
88
+        ..._toolbar,
90
         bottom: 3 * BoxModel.margin,
89
         bottom: 3 * BoxModel.margin,
91
         flexDirection: 'row',
90
         flexDirection: 'row',
92
         justifyContent: 'center',
91
         justifyContent: 'center',
95
     },
94
     },
96
 
95
 
97
     /**
96
     /**
98
-     * The style of button in primaryToolbar.
97
+     * The style of toolbar buttons in {@link #primaryToolbar}.
99
      */
98
      */
100
-    primaryToolbarButton: {
101
-        ...button,
102
-        backgroundColor: ColorPalette.white,
103
-        opacity: 0.7
104
-    },
99
+    primaryToolbarButton,
100
+
101
+    /**
102
+     * The icon style of the toolbar buttons in {@link #primaryToolbar}.
103
+     */
104
+    primaryToolbarButtonIcon,
105
 
105
 
106
     /**
106
     /**
107
      * The style of the toolbar which contains the secondary buttons such as
107
      * The style of the toolbar which contains the secondary buttons such as
108
      * toggle camera facing mode.
108
      * toggle camera facing mode.
109
      */
109
      */
110
     secondaryToolbar: {
110
     secondaryToolbar: {
111
-        ...toolbar,
111
+        ..._toolbar,
112
         bottom: 0,
112
         bottom: 0,
113
         flexDirection: 'column',
113
         flexDirection: 'column',
114
         right: BoxModel.margin,
114
         right: BoxModel.margin,
116
     },
116
     },
117
 
117
 
118
     /**
118
     /**
119
-     * The style of button in secondaryToolbar.
119
+     * The style of toolbar buttons in {@link #secondaryToolbar}.
120
      */
120
      */
121
     secondaryToolbarButton: {
121
     secondaryToolbarButton: {
122
-        ...smallButton,
122
+        ..._toolbarButton,
123
         backgroundColor: ColorPalette.darkGrey,
123
         backgroundColor: ColorPalette.darkGrey,
124
-        opacity: 0.7
124
+        borderRadius: 20,
125
+        flexDirection: 'column',
126
+        height: 40,
127
+        margin: BoxModel.margin / 2,
128
+        width: 40
125
     },
129
     },
126
 
130
 
127
     /**
131
     /**
128
-     * The secondary toolbar icon style.
132
+     * The icon style of the toolbar buttons in {@link #secondaryToolbar}.
129
      */
133
      */
130
-    secondaryToolbarIcon: {
131
-        ...smallIcon,
132
-        color: ColorPalette.white
134
+    secondaryToolbarButtonIcon,
135
+
136
+    /**
137
+     * The icon style of the toolbar button in {@link #secondaryToolbar} which
138
+     * toggles the audio-only mode of the current conference.
139
+     */
140
+    toggleAudioOnlyIcon: {
141
+        ...secondaryToolbarButtonIcon,
142
+        transform: [ { rotate: '135deg' } ]
133
     },
143
     },
134
 
144
 
135
     /**
145
     /**
136
-     * The style of the root/top-level Container of Toolbar that contains
137
-     * toolbars.
146
+     * The style of the root/top-level {@link Container} of {@link Toolbox}
147
+     * which contains {@link Toolbar}s.
138
      */
148
      */
139
     toolbarContainer: {
149
     toolbarContainer: {
140
         bottom: 0,
150
         bottom: 0,
145
     },
155
     },
146
 
156
 
147
     /**
157
     /**
148
-     * The toolbar white button icon style.
158
+     * The style of toolbar buttons in {@link #primaryToolbar} which display
159
+     * white icons.
160
+     */
161
+    whitePrimaryToolbarButton: {
162
+        ...primaryToolbarButton,
163
+        backgroundColor: ColorPalette.buttonUnderlay
164
+    },
165
+
166
+    /**
167
+     * The icon style of toolbar buttons in {@link #primaryToolbar} which
168
+     * display white icons.
149
      */
169
      */
150
-    whiteIcon: {
151
-        ...icon,
170
+    whitePrimaryToolbarButtonIcon: {
171
+        ...primaryToolbarButtonIcon,
152
         color: ColorPalette.white
172
         color: ColorPalette.white
153
     }
173
     }
154
 });
174
 });

読み込み中…
キャンセル
保存