瀏覽代碼

Generalize indicators

master
Bettenbuk Zoltan 6 年之前
父節點
當前提交
4e78502c9e

+ 21
- 1
react/features/filmstrip/components/AbstractRaisedHandIndicator.js 查看文件

@@ -15,7 +15,7 @@ export type Props = {
15 15
     /**
16 16
      * True if the hand is raised for this participant.
17 17
      */
18
-    _raisedHand: boolean
18
+    _raisedHand?: boolean
19 19
 }
20 20
 
21 21
 /**
@@ -24,6 +24,26 @@ export type Props = {
24 24
 export default class AbstractRaisedHandIndicator<P: Props>
25 25
     extends Component<P> {
26 26
 
27
+    /**
28
+     * Implements {@code Component#render}.
29
+     *
30
+     * @inheritdoc
31
+     */
32
+    render() {
33
+        if (!this.props._raisedHand) {
34
+            return null;
35
+        }
36
+
37
+        return this._renderIndicator();
38
+    }
39
+
40
+    /**
41
+     * Renders the platform specific indicator element.
42
+     *
43
+     * @returns {React$Element<*>}
44
+     */
45
+    _renderIndicator: () => React$Element<*>
46
+
27 47
 }
28 48
 
29 49
 /**

+ 7
- 7
react/features/filmstrip/components/native/AudioMutedIndicator.js 查看文件

@@ -1,13 +1,13 @@
1
-import React, { Component } from 'react';
1
+// @flow
2 2
 
3
-import { Icon } from '../../../base/font-icons';
3
+import React, { Component } from 'react';
4 4
 
5
-import styles from './styles';
5
+import BaseIndicator from './BaseIndicator';
6 6
 
7 7
 /**
8 8
  * Thumbnail badge for displaying the audio mute status of a participant.
9 9
  */
10
-export default class AudioMutedIndicator extends Component {
10
+export default class AudioMutedIndicator extends Component<{}> {
11 11
     /**
12 12
      * Implements React's {@link Component#render()}.
13 13
      *
@@ -15,9 +15,9 @@ export default class AudioMutedIndicator extends Component {
15 15
      */
16 16
     render() {
17 17
         return (
18
-            <Icon
19
-                name = 'mic-disabled'
20
-                style = { styles.thumbnailIndicator } />
18
+            <BaseIndicator
19
+                highlight = { false }
20
+                icon = 'mic-disabled' />
21 21
         );
22 22
     }
23 23
 }

+ 51
- 0
react/features/filmstrip/components/native/BaseIndicator.js 查看文件

@@ -0,0 +1,51 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { View } from 'react-native';
5
+
6
+import { Icon } from '../../../base/font-icons';
7
+
8
+import styles from './styles';
9
+
10
+type Props = {
11
+
12
+    /**
13
+     * True if a highlighted background has to be applied.
14
+     */
15
+    highlight: boolean,
16
+
17
+    /**
18
+     * The name of the icon to be used as the indicator.
19
+     */
20
+    icon: string
21
+};
22
+
23
+/**
24
+ * Implements a base indicator to be reused across all native indicators on
25
+ * the filmstrip.
26
+ */
27
+export default class BaseIndicator extends Component<Props> {
28
+    /**
29
+     * Implements React's {@link Component#render()}.
30
+     *
31
+     * @inheritdoc
32
+     */
33
+    render() {
34
+        const { highlight, icon } = this.props;
35
+
36
+        const iconElement = (<Icon
37
+            name = { icon }
38
+            style = { styles.indicator } />
39
+        );
40
+
41
+        if (highlight) {
42
+            return (
43
+                <View style = { styles.indicatorBackground }>
44
+                    { iconElement }
45
+                </View>
46
+            );
47
+        }
48
+
49
+        return iconElement;
50
+    }
51
+}

+ 5
- 10
react/features/filmstrip/components/native/DominantSpeakerIndicator.js 查看文件

@@ -1,11 +1,8 @@
1 1
 // @flow
2 2
 
3 3
 import React, { Component } from 'react';
4
-import { View } from 'react-native';
5 4
 
6
-import { Icon } from '../../../base/font-icons';
7
-
8
-import styles from './styles';
5
+import BaseIndicator from './BaseIndicator';
9 6
 
10 7
 /**
11 8
  * Thumbnail badge showing that the participant is the dominant speaker in
@@ -13,17 +10,15 @@ import styles from './styles';
13 10
  */
14 11
 export default class DominantSpeakerIndicator extends Component<{}> {
15 12
     /**
16
-     * Implements React's {@link Component#render()}.
13
+     * Implements {@code Component#render}.
17 14
      *
18 15
      * @inheritdoc
19 16
      */
20 17
     render() {
21 18
         return (
22
-            <View style = { styles.indicatorBackground }>
23
-                <Icon
24
-                    name = 'dominant-speaker'
25
-                    style = { styles.indicator } />
26
-            </View>
19
+            <BaseIndicator
20
+                highlight = { true }
21
+                icon = 'dominant-speaker' />
27 22
         );
28 23
     }
29 24
 }

+ 7
- 7
react/features/filmstrip/components/native/ModeratorIndicator.js 查看文件

@@ -1,13 +1,13 @@
1
-import React, { Component } from 'react';
1
+// @flow
2 2
 
3
-import { Icon } from '../../../base/font-icons';
3
+import React, { Component } from 'react';
4 4
 
5
-import styles from './styles';
5
+import BaseIndicator from './BaseIndicator';
6 6
 
7 7
 /**
8 8
  * Thumbnail badge showing that the participant is a conference moderator.
9 9
  */
10
-export default class ModeratorIndicator extends Component {
10
+export default class ModeratorIndicator extends Component<{}> {
11 11
     /**
12 12
      * Implements React's {@link Component#render()}.
13 13
      *
@@ -15,9 +15,9 @@ export default class ModeratorIndicator extends Component {
15 15
      */
16 16
     render() {
17 17
         return (
18
-            <Icon
19
-                name = 'star'
20
-                style = { styles.moderatorIndicator } />
18
+            <BaseIndicator
19
+                highlight = { false }
20
+                icon = 'star' />
21 21
         );
22 22
     }
23 23
 }

+ 8
- 16
react/features/filmstrip/components/native/RaisedHandIndicator.js 查看文件

@@ -1,9 +1,7 @@
1
-/* @flow */
1
+// @flow
2 2
 
3 3
 import React from 'react';
4
-import { View } from 'react-native';
5 4
 
6
-import { Icon } from '../../../base/font-icons';
7 5
 import { connect } from '../../../base/redux';
8 6
 
9 7
 import AbstractRaisedHandIndicator, {
@@ -11,7 +9,7 @@ import AbstractRaisedHandIndicator, {
11 9
     _mapStateToProps
12 10
 } from '../AbstractRaisedHandIndicator';
13 11
 
14
-import styles from './styles';
12
+import BaseIndicator from './BaseIndicator';
15 13
 
16 14
 /**
17 15
  * Thumbnail badge showing that the participant would like to speak.
@@ -20,21 +18,15 @@ import styles from './styles';
20 18
  */
21 19
 class RaisedHandIndicator extends AbstractRaisedHandIndicator<Props> {
22 20
     /**
23
-     * Implements React's {@link Component#render()}.
21
+     * Renders the platform specific indicator element.
24 22
      *
25
-     * @inheritdoc
23
+     * @returns {React$Element<*>}
26 24
      */
27
-    render() {
28
-        if (!this.props._raisedHand) {
29
-            return null;
30
-        }
31
-
25
+    _renderIndicator() {
32 26
         return (
33
-            <View style = { styles.indicatorBackground }>
34
-                <Icon
35
-                    name = 'raised-hand'
36
-                    style = { styles.indicator } />
37
-            </View>
27
+            <BaseIndicator
28
+                highlight = { true }
29
+                icon = 'raised-hand' />
38 30
         );
39 31
     }
40 32
 }

+ 10
- 6
react/features/filmstrip/components/native/Thumbnail.js 查看文件

@@ -1,6 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import React, { Component } from 'react';
4
+import { View } from 'react-native';
4 5
 import type { Dispatch } from 'redux';
5 6
 
6 7
 import { ColorSchemeRegistry } from '../../../base/color-scheme';
@@ -163,12 +164,15 @@ class Thumbnail extends Component<Props> {
163 164
                     zOrder = { 1 } />
164 165
 
165 166
                 { participant.role === PARTICIPANT_ROLE.MODERATOR
166
-                    && <ModeratorIndicator /> }
167
-
168
-                { participant.dominantSpeaker
169
-                    && <DominantSpeakerIndicator /> }
170
-
171
-                <RaisedHandIndicator participantId = { participant.id } />
167
+                    && <View style = { styles.moderatorIndicatorContainer }>
168
+                        <ModeratorIndicator />
169
+                    </View> }
170
+
171
+                <View style = { styles.thumbnailTopIndicatorContainer }>
172
+                    <RaisedHandIndicator participantId = { participant.id } />
173
+                    { participant.dominantSpeaker
174
+                        && <DominantSpeakerIndicator /> }
175
+                </View>
172 176
 
173 177
                 <Container style = { styles.thumbnailIndicatorContainer }>
174 178
                     { audioMuted

+ 7
- 7
react/features/filmstrip/components/native/VideoMutedIndicator.js 查看文件

@@ -1,13 +1,13 @@
1
-import React, { Component } from 'react';
1
+// @flow
2 2
 
3
-import { Icon } from '../../../base/font-icons';
3
+import React, { Component } from 'react';
4 4
 
5
-import styles from './styles';
5
+import BaseIndicator from './BaseIndicator';
6 6
 
7 7
 /**
8 8
  * Thumbnail badge for displaying the video mute status of a participant.
9 9
  */
10
-export default class VideoMutedIndicator extends Component {
10
+export default class VideoMutedIndicator extends Component<{}> {
11 11
     /**
12 12
      * Implements React's {@link Component#render()}.
13 13
      *
@@ -15,9 +15,9 @@ export default class VideoMutedIndicator extends Component {
15 15
      */
16 16
     render() {
17 17
         return (
18
-            <Icon
19
-                name = 'camera-disabled'
20
-                style = { styles.thumbnailIndicator } />
18
+            <BaseIndicator
19
+                highlight = { false }
20
+                icon = 'camera-disabled' />
21 21
         );
22 22
     }
23 23
 }

+ 21
- 37
react/features/filmstrip/components/native/styles.js 查看文件

@@ -10,18 +10,6 @@ import { FILMSTRIP_SIZE } from '../../constants';
10 10
  */
11 11
 export const AVATAR_SIZE = 50;
12 12
 
13
-/**
14
- * The base/default style of indicators such as audioMutedIndicator,
15
- * moderatorIndicator, and videoMutedIndicator.
16
- */
17
-const indicator = {
18
-    textShadowColor: ColorPalette.black,
19
-    textShadowOffset: {
20
-        height: -1,
21
-        width: 0
22
-    }
23
-};
24
-
25 13
 /**
26 14
  * The styles of the feature filmstrip.
27 15
  */
@@ -30,20 +18,27 @@ export default {
30 18
      * Dominant speaker indicator style.
31 19
      */
32 20
     indicator: {
21
+        backgroundColor: ColorPalette.transparent,
33 22
         color: ColorPalette.white,
34
-        fontSize: 12
23
+        fontSize: 12,
24
+        textShadowColor: ColorPalette.black,
25
+        textShadowOffset: {
26
+            height: -1,
27
+            width: 0
28
+        }
35 29
     },
36 30
 
37 31
     /**
38 32
      * Dominant speaker indicator background style.
39 33
      */
40 34
     indicatorBackground: {
35
+        alignItems: 'center',
41 36
         backgroundColor: ColorPalette.blue,
42 37
         borderRadius: 16,
43
-        left: 4,
44
-        padding: 4,
45
-        position: 'absolute',
46
-        top: 4
38
+        flexDirection: 'row',
39
+        justifyContent: 'center',
40
+        height: 20,
41
+        width: 20
47 42
     },
48 43
 
49 44
     /**
@@ -84,16 +79,10 @@ export default {
84 79
         flexDirection: 'row'
85 80
     },
86 81
 
87
-    /**
88
-     * Moderator indicator style.
89
-     */
90
-    moderatorIndicator: {
91
-        backgroundColor: 'transparent',
82
+    moderatorIndicatorContainer: {
92 83
         bottom: 4,
93
-        color: ColorPalette.white,
94 84
         position: 'absolute',
95
-        right: 4,
96
-        ...indicator
85
+        right: 4
97 86
     },
98 87
 
99 88
     /**
@@ -123,18 +112,6 @@ export default {
123 112
         width: 80
124 113
     },
125 114
 
126
-    /**
127
-     * The thumbnail audio and video muted indicator style.
128
-     */
129
-    thumbnailIndicator: {
130
-        backgroundColor: 'transparent',
131
-        color: ColorPalette.white,
132
-        paddingLeft: 1,
133
-        paddingRight: 1,
134
-        position: 'relative',
135
-        ...indicator
136
-    },
137
-
138 115
     /**
139 116
      * The thumbnails indicator container.
140 117
      */
@@ -147,6 +124,13 @@ export default {
147 124
         position: 'absolute'
148 125
     },
149 126
 
127
+    thumbnailTopIndicatorContainer: {
128
+        left: 0,
129
+        padding: 4,
130
+        position: 'absolute',
131
+        top: 0
132
+    },
133
+
150 134
     tileView: {
151 135
         alignSelf: 'center'
152 136
     },

+ 3
- 7
react/features/filmstrip/components/web/RaisedHandIndicator.js 查看文件

@@ -34,15 +34,11 @@ type Props = AbstractProps & {
34 34
  */
35 35
 class RaisedHandIndicator extends AbstractRaisedHandIndicator<Props> {
36 36
     /**
37
-     * Implements React's {@link Component#render()}.
37
+     * Renders the platform specific indicator element.
38 38
      *
39
-     * @inheritdoc
39
+     * @returns {React$Element<*>}
40 40
      */
41
-    render() {
42
-        if (!this.props._raisedHand) {
43
-            return null;
44
-        }
45
-
41
+    _renderIndicator() {
46 42
         return (
47 43
             <BaseIndicator
48 44
                 className = 'raisehandindicator indicator show-inline'

Loading…
取消
儲存