Преглед на файлове

[RN] Fix call/ring overlay

master
Lyubo Marinov преди 8 години
родител
ревизия
ee3cd30b59
променени са 3 файла, в които са добавени 111 реда и са изтрити 7 реда
  1. 60
    7
      react/features/jwt/components/CallOverlay.js
  2. 51
    0
      react/features/jwt/components/styles.native.js
  3. 0
    0
      react/features/jwt/components/styles.web.js

+ 60
- 7
react/features/jwt/components/CallOverlay.js Целия файл

@@ -8,6 +8,8 @@ import { Avatar } from '../../base/participants';
8 8
 import { Container, Text } from '../../base/react';
9 9
 import UIEvents from '../../../../service/UI/UIEvents';
10 10
 
11
+import styles from './styles';
12
+
11 13
 declare var $: Object;
12 14
 declare var APP: Object;
13 15
 declare var interfaceConfig: Object;
@@ -160,17 +162,22 @@ class CallOverlay extends Component {
160 162
 
161 163
         return (
162 164
             <Container
163
-                className = { `ringing ${className || ''}` }
165
+                { ...this._style('ringing', className) }
164 166
                 id = 'ringOverlay'>
165
-                <Container className = 'ringing__content'>
166
-                    { ringing ? <Text>Calling...</Text> : null }
167
+                <Container
168
+                    { ...this._style('ringing__content') }>
169
+                    <Text { ...this._style('ringing__text') }>
170
+                        { ringing ? 'Calling...' : '' }
171
+                    </Text>
167 172
                     <Avatar
168
-                        className = 'ringing__avatar'
173
+                        { ...this._style('ringing__avatar') }
169 174
                         uri = { avatarUrl } />
170
-                    <Container className = 'ringing__caller-info'>
171
-                        <Text>
175
+                    <Container
176
+                        { ...this._style('ringing__caller-info') }>
177
+                        <Text
178
+                            { ...this._style('ringing__text') }>
172 179
                             { name }
173
-                            { ringing ? null : ' isn\'t available' }
180
+                            { ringing ? '' : ' isn\'t available' }
174 181
                         </Text>
175 182
                     </Container>
176 183
                 </Container>
@@ -263,6 +270,52 @@ class CallOverlay extends Component {
263 270
     _setAudio(audio) {
264 271
         this._audio = audio;
265 272
     }
273
+
274
+    /**
275
+     * Attempts to convert specified CSS class names into React
276
+     * {@link Component} props {@code style} or {@code className}.
277
+     *
278
+     * @param {Array<string>} classNames - The CSS class names to convert
279
+     * into React {@code Component} props {@code style} or {@code className}.
280
+     * @returns {{
281
+     *     className: string,
282
+     *     style: Object
283
+     * }}
284
+     */
285
+    _style(...classNames: Array<?string>) {
286
+        let className = '';
287
+        let style;
288
+
289
+        for (const aClassName of classNames) {
290
+            if (aClassName) {
291
+                // Attemp to convert aClassName into style.
292
+                if (styles && aClassName in styles) {
293
+                    // React Native will accept an Array as the value of the
294
+                    // style prop. However, I do not know about React.
295
+                    style = {
296
+                        ...style,
297
+                        ...styles[aClassName]
298
+                    };
299
+                } else {
300
+                    // Otherwise, leave it as className.
301
+                    className += aClassName;
302
+                }
303
+            }
304
+        }
305
+
306
+        // Choose which of the className and/or style props has a value and,
307
+        // consequently, must be returned.
308
+        const props = {};
309
+
310
+        if (className) {
311
+            props.className = className;
312
+        }
313
+        if (style) {
314
+            props.style = style;
315
+        }
316
+
317
+        return props;
318
+    }
266 319
 }
267 320
 
268 321
 /**

+ 51
- 0
react/features/jwt/components/styles.native.js Целия файл

@@ -0,0 +1,51 @@
1
+import { ColorPalette, createStyleSheet } from '../../base/styles';
2
+
3
+export default createStyleSheet({
4
+    // XXX The names bellow were preserved for the purposes of compatibility
5
+    // with the existing CSS class names on Web.
6
+
7
+    /**
8
+     * The style of {@code CallOverlay}.
9
+     */
10
+    ringing: {
11
+        alignItems: 'center',
12
+        backgroundColor: ColorPalette.black,
13
+        bottom: 0,
14
+        flex: 0,
15
+        flexDirection: 'column',
16
+        justifyContent: 'center',
17
+        left: 0,
18
+        opacity: 0.8,
19
+        position: 'absolute',
20
+        right: 0,
21
+        top: 0
22
+    },
23
+
24
+    'ringing__avatar': {
25
+        borderRadius: 50,
26
+        flex: 0,
27
+        height: 100,
28
+        width: 100
29
+    },
30
+
31
+    'ringing__caller-info': {
32
+        alignItems: 'center',
33
+        flex: 0,
34
+        flexDirection: 'row',
35
+        justifyContent: 'center'
36
+    },
37
+
38
+    'ringing__content': {
39
+        alignItems: 'center',
40
+        flex: 0,
41
+        flexDirection: 'column',
42
+        justifyContent: 'center'
43
+    },
44
+
45
+    /**
46
+     * The style of {@code Text} within {@code CallOverlay}.
47
+     */
48
+    'ringing__text': {
49
+        color: ColorPalette.white
50
+    }
51
+});

+ 0
- 0
react/features/jwt/components/styles.web.js Целия файл


Loading…
Отказ
Запис