소스 검색

[RN] Implement web's CircularLabel component for mobile

master
Bettenbuk Zoltan 7 년 전
부모
커밋
9eb9306e87

+ 17
- 0
react/features/base/label/components/AbstractCircularLabel.js 파일 보기

@@ -0,0 +1,17 @@
1
+// @flow
2
+import { Component } from 'react';
3
+
4
+export type Props = {
5
+
6
+    /**
7
+     * String that will be rendered as the label itself.
8
+     */
9
+    label: string
10
+};
11
+
12
+/**
13
+ * Abstract class for the {@code CircularLabel} component.
14
+ */
15
+export default class AbstractCircularLabel<P: Props> extends Component<P> {
16
+
17
+}

+ 44
- 0
react/features/base/label/components/CircularLabel.native.js 파일 보기

@@ -0,0 +1,44 @@
1
+// @flow
2
+import React from 'react';
3
+import { Text, View } from 'react-native';
4
+
5
+import { combineStyles, type StyleType } from '../../styles';
6
+
7
+import AbstractCircularLabel, {
8
+    type Props as AbstractProps
9
+} from './AbstractCircularLabel';
10
+import styles from './styles';
11
+
12
+type Props = AbstractProps & {
13
+
14
+    /**
15
+     * Style of the label.
16
+     */
17
+    style?: ?StyleType
18
+};
19
+
20
+/**
21
+ * Renders a circular indicator to be used for status icons, such as recording
22
+ * on, audio-only conference, video quality and similar.
23
+ */
24
+export default class CircularLabel extends AbstractCircularLabel<Props> {
25
+    /**
26
+     * Implements React {@link Component}'s render.
27
+     *
28
+     * @inheritdoc
29
+     */
30
+    render() {
31
+        const { label, style } = this.props;
32
+
33
+        return (
34
+            <View
35
+                style = {
36
+                    combineStyles(styles.indicatorContainer, style)
37
+                }>
38
+                <Text style = { styles.indicatorText }>
39
+                    { label }
40
+                </Text>
41
+            </View>
42
+        );
43
+    }
44
+}

+ 9
- 10
react/features/base/label/components/CircularLabel.web.js 파일 보기

@@ -1,13 +1,12 @@
1 1
 // @flow
2 2
 
3
-import React, { Component } from 'react';
3
+import React from 'react';
4 4
 
5
-type Props = {
5
+import AbstractCircularLabel, {
6
+    type Props as AbstractProps
7
+} from './AbstractCircularLabel';
6 8
 
7
-    /**
8
-     * The children to be displayed within {@code CircularLabel}.
9
-     */
10
-    children: React$Node,
9
+type Props = AbstractProps & {
11 10
 
12 11
     /**
13 12
      * Additional CSS class names to add to the root of {@code CircularLabel}.
@@ -26,7 +25,7 @@ type Props = {
26 25
  *
27 26
  * @extends Component
28 27
  */
29
-export default class CircularLabel extends Component<Props> {
28
+export default class CircularLabel extends AbstractCircularLabel<Props> {
30 29
     /**
31 30
      * Default values for {@code CircularLabel} component's properties.
32 31
      *
@@ -44,16 +43,16 @@ export default class CircularLabel extends Component<Props> {
44 43
      */
45 44
     render() {
46 45
         const {
47
-            children,
48 46
             className,
49
-            id
47
+            id,
48
+            label
50 49
         } = this.props;
51 50
 
52 51
         return (
53 52
             <div
54 53
                 className = { `circular-label ${className}` }
55 54
                 id = { id }>
56
-                { children }
55
+                { label }
57 56
             </div>
58 57
         );
59 58
     }

+ 30
- 0
react/features/base/label/components/styles.js 파일 보기

@@ -0,0 +1,30 @@
1
+// @flow
2
+
3
+import { ColorPalette, createStyleSheet } from '../../styles';
4
+
5
+/**
6
+ * The styles of the native base/label feature.
7
+ */
8
+export default createStyleSheet({
9
+
10
+    /**
11
+     * The outermost view.
12
+     */
13
+    indicatorContainer: {
14
+        alignItems: 'center',
15
+        backgroundColor: '#808080',
16
+        borderRadius: 18,
17
+        borderWidth: 0,
18
+        flex: 0,
19
+        height: 36,
20
+        justifyContent: 'center',
21
+        margin: 5,
22
+        opacity: 0.6,
23
+        width: 36
24
+    },
25
+
26
+    indicatorText: {
27
+        color: ColorPalette.white,
28
+        fontSize: 12
29
+    }
30
+});

+ 3
- 3
react/features/recording/components/RecordingLabel.web.js 파일 보기

@@ -189,9 +189,9 @@ class RecordingLabel extends Component<Props, State> {
189 189
                     ? <div>
190 190
                         { this.props.t(messageKey) }
191 191
                     </div>
192
-                    : <CircularLabel className = { circularLabelClass }>
193
-                        { this.props.t(circularLabelKey) }
194
-                    </CircularLabel> }
192
+                    : <CircularLabel
193
+                        className = { circularLabelClass }
194
+                        label = { this.props.t(circularLabelKey) } /> }
195 195
             </div>
196 196
         );
197 197
     }

+ 2
- 3
react/features/video-quality/components/VideoQualityLabel.web.js 파일 보기

@@ -109,9 +109,8 @@ export class VideoQualityLabel extends Component {
109 109
                 position = { 'left' }>
110 110
                 <CircularLabel
111 111
                     className = { className }
112
-                    id = 'videoResolutionLabel'>
113
-                    { labelContent }
114
-                </CircularLabel>
112
+                    id = 'videoResolutionLabel'
113
+                    label = { labelContent } />
115 114
             </Tooltip>
116 115
         );
117 116
     }

Loading…
취소
저장