瀏覽代碼

ref(Conference.native): move notifications container

Moves NotificationContainer to the toolbox and filmstrip container, so
that there's no need to manually calculate the positions.
master
paweldomas 7 年之前
父節點
當前提交
eac069c930

+ 56
- 4
react/features/conference/components/Conference.native.js 查看文件

@@ -11,10 +11,14 @@ import { connect, disconnect } from '../../base/connection';
11 11
 import { DialogContainer } from '../../base/dialog';
12 12
 import { getParticipantCount } from '../../base/participants';
13 13
 import { Container, LoadingIndicator, TintedView } from '../../base/react';
14
+import {
15
+    isNarrowAspectRatio,
16
+    makeAspectRatioAware
17
+} from '../../base/responsive-ui';
14 18
 import { TestConnectionInfo } from '../../base/testing';
15 19
 import { createDesiredLocalTracks } from '../../base/tracks';
16 20
 import { ConferenceNotification } from '../../calendar-sync';
17
-import { Filmstrip } from '../../filmstrip';
21
+import { FILMSTRIP_SIZE, Filmstrip, isFilmstripVisible } from '../../filmstrip';
18 22
 import { LargeVideo } from '../../large-video';
19 23
 import { CalleeInfoContainer } from '../../invite';
20 24
 import { NotificationsContainer } from '../../notifications';
@@ -37,6 +41,13 @@ type Props = {
37 41
      */
38 42
     _connecting: boolean,
39 43
 
44
+    /**
45
+     * Set to {@code true} when the filmstrip is currently visible.
46
+     *
47
+     * @private
48
+     */
49
+    _filmstripVisible: boolean,
50
+
40 51
     /**
41 52
      * Current conference's full URL.
42 53
      *
@@ -272,6 +283,14 @@ class Conference extends Component<Props> {
272 283
                 <View
273 284
                     pointerEvents = 'box-none'
274 285
                     style = { styles.toolboxAndFilmstripContainer }>
286
+                    {
287
+
288
+                        /**
289
+                         * Notifications are rendered on the very top of other
290
+                         * components like subtitles, toolbox and filmstrip.
291
+                         */
292
+                        this._renderNotificationsContainer()
293
+                    }
275 294
                     {/*
276 295
                       * The Toolbox is in a stacking layer bellow the Filmstrip.
277 296
                       */}
@@ -293,8 +312,6 @@ class Conference extends Component<Props> {
293 312
                     this._renderConferenceNotification()
294 313
                 }
295 314
 
296
-                <NotificationsContainer />
297
-
298 315
                 {/*
299 316
                   * The dialogs are in the topmost stacking layers.
300 317
                   */
@@ -350,6 +367,35 @@ class Conference extends Component<Props> {
350 367
                 ? <ConferenceNotification />
351 368
                 : undefined);
352 369
     }
370
+
371
+    /**
372
+     * Renders a container for notifications to be displayed by
373
+     * the base/notifications feature.
374
+     *
375
+     * @returns {React$Element}
376
+     * @private
377
+     */
378
+    _renderNotificationsContainer() {
379
+        const notificationsStyle = { };
380
+
381
+        /**
382
+         * In the landscape mode (wide) there's problem with notifications being
383
+         * shadowed by the filmstrip rendered on the right. This makes the "x"
384
+         * button not clickable. In order to avoid that a margin of
385
+         * the filmstrip's size is added to the right.
386
+         *
387
+         * Pawel: after many attempts I failed to make notifications adjust to
388
+         * their contents width because of column and rows being used in
389
+         * the flex layout. The only option that seemed to limit
390
+         * the notification's size was explicit 'width' value which is not
391
+         * better than the margin added here.
392
+         */
393
+        if (!isNarrowAspectRatio(this) && this.props._filmstripVisible) {
394
+            notificationsStyle.marginRight = FILMSTRIP_SIZE;
395
+        }
396
+
397
+        return <NotificationsContainer style = { notificationsStyle } />;
398
+    }
353 399
 }
354 400
 
355 401
 /**
@@ -423,6 +469,7 @@ function _mapDispatchToProps(dispatch) {
423 469
  * @private
424 470
  * @returns {{
425 471
  *     _connecting: boolean,
472
+ *     _filmstripVisible: boolean,
426 473
  *     _locationURL: URL,
427 474
  *     _participantCount: number,
428 475
  *     _reducedUI: boolean,
@@ -467,6 +514,11 @@ function _mapStateToProps(state) {
467 514
          */
468 515
         _connecting: Boolean(connecting_),
469 516
 
517
+        /**
518
+         * Is {@code true} when the filmstrip is currently visible.
519
+         */
520
+        _filmstripVisible: isFilmstripVisible(state),
521
+
470 522
         /**
471 523
          * Current conference's full URL.
472 524
          *
@@ -520,4 +572,4 @@ function _mapStateToProps(state) {
520 572
 
521 573
 // $FlowFixMe
522 574
 export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
523
-    Conference);
575
+    makeAspectRatioAware(Conference));

+ 10
- 84
react/features/notifications/components/NotificationsContainer.native.js 查看文件

@@ -4,14 +4,6 @@ import React from 'react';
4 4
 import { View } from 'react-native';
5 5
 import { connect } from 'react-redux';
6 6
 
7
-import {
8
-    isNarrowAspectRatio,
9
-    makeAspectRatioAware
10
-} from '../../base/responsive-ui';
11
-import { BoxModel } from '../../base/styles';
12
-import { FILMSTRIP_SIZE, isFilmstripVisible } from '../../filmstrip';
13
-import { HANGUP_BUTTON_SIZE } from '../../toolbox';
14
-
15 7
 import AbstractNotificationsContainer, {
16 8
     _abstractMapStateToProps,
17 9
     type Props as AbstractProps
@@ -22,21 +14,11 @@ import styles from './styles';
22 14
 type Props = AbstractProps & {
23 15
 
24 16
     /**
25
-     * True if the {@code Filmstrip} is visible, false otherwise.
26
-     */
27
-    _filmstripVisible: boolean,
28
-
29
-    /**
30
-     * True if the {@ćode Toolbox} is visible, false otherwise.
17
+     * Any custom styling applied to the notifications container.
31 18
      */
32
-    _toolboxVisible: boolean
19
+    style: Object
33 20
 };
34 21
 
35
-/**
36
- * The margin of the container to be kept from other components.
37
- */
38
-const CONTAINER_MARGIN = BoxModel.margin;
39
-
40 22
 /**
41 23
  * Implements a React {@link Component} which displays notifications and handles
42 24
  * automatic dismissmal after a notification is shown for a defined timeout
@@ -44,7 +26,8 @@ const CONTAINER_MARGIN = BoxModel.margin;
44 26
  *
45 27
  * @extends {Component}
46 28
  */
47
-class NotificationsContainer extends AbstractNotificationsContainer<Props> {
29
+class NotificationsContainer
30
+    extends AbstractNotificationsContainer<Props> {
48 31
 
49 32
     /**
50 33
      * Implements React's {@link Component#render()}.
@@ -64,79 +47,22 @@ class NotificationsContainer extends AbstractNotificationsContainer<Props> {
64 47
                 pointerEvents = 'box-none'
65 48
                 style = { [
66 49
                     styles.notificationContainer,
67
-                    this._getContainerStyle()
68
-                ] }>
50
+                    this.props.style
51
+                ] } >
69 52
                 {
70
-                    _notifications.map(notification => {
71
-                        const { props, uid } = notification;
72
-
73
-                        return (
53
+                    _notifications.map(
54
+                        ({ props, uid }) => (
74 55
                             <Notification
75 56
                                 { ...props }
76 57
                                 key = { uid }
77 58
                                 onDismissed = { this._onDismissed }
78
-                                uid = { uid } />
79
-
80
-                        );
81
-                    })
59
+                                uid = { uid } />))
82 60
                 }
83 61
             </View>
84 62
         );
85 63
     }
86 64
 
87
-    /**
88
-     * Generates a style object that is to be used for the notification
89
-     * container.
90
-     *
91
-     * @private
92
-     * @returns {?Object}
93
-     */
94
-    _getContainerStyle() {
95
-        const { _filmstripVisible, _toolboxVisible } = this.props;
96
-
97
-        // The filmstrip only affects the position if we're on a narrow view.
98
-        const _narrow = isNarrowAspectRatio(this);
99
-
100
-        let bottom = 0;
101
-        let right = 0;
102
-
103
-        // The container needs additional distance from bottom when the
104
-        // filmstrip or the toolbox is visible.
105
-        _filmstripVisible && !_narrow && (right += FILMSTRIP_SIZE);
106
-        _filmstripVisible && _narrow && (bottom += FILMSTRIP_SIZE);
107
-        _toolboxVisible && (bottom += HANGUP_BUTTON_SIZE);
108
-
109
-        bottom += CONTAINER_MARGIN;
110
-
111
-        return {
112
-            bottom,
113
-            right
114
-        };
115
-    }
116
-
117 65
     _onDismissed: number => void;
118 66
 }
119 67
 
120
-/**
121
- * Maps (parts of) the Redux state to the associated NotificationsContainer's
122
- * props.
123
- *
124
- * @param {Object} state - The Redux state.
125
- * @private
126
- * @returns {{
127
- *     _filmstripVisible: boolean,
128
- *     _notifications: Array,
129
- *     _showNotifications: boolean,
130
- *     _toolboxVisible: boolean
131
- * }}
132
- */
133
-export function _mapStateToProps(state: Object) {
134
-    return {
135
-        ..._abstractMapStateToProps(state),
136
-        _filmstripVisible: isFilmstripVisible(state),
137
-        _toolboxVisible: state['features/toolbox'].visible
138
-    };
139
-}
140
-
141
-export default connect(_mapStateToProps)(
142
-    makeAspectRatioAware(NotificationsContainer));
68
+export default connect(_abstractMapStateToProps)(NotificationsContainer);

+ 3
- 4
react/features/notifications/components/styles.js 查看文件

@@ -1,7 +1,5 @@
1 1
 // @flow
2 2
 
3
-import { StyleSheet } from 'react-native';
4
-
5 3
 import { BoxModel, createStyleSheet, ColorPalette } from '../../base/styles';
6 4
 
7 5
 /**
@@ -48,9 +46,10 @@ export default createStyleSheet({
48 46
      * Outermost container of a list of notifications.
49 47
      */
50 48
     notificationContainer: {
51
-        ...StyleSheet.absoluteFillObject,
49
+        flexGrow: 0,
52 50
         justifyContent: 'flex-end',
53
-        padding: 2 * BoxModel.padding
51
+        padding: 2 * BoxModel.padding,
52
+        paddingBottom: BoxModel.padding
54 53
     },
55 54
 
56 55
     /**

+ 2
- 11
react/features/toolbox/components/native/Toolbox.js 查看文件

@@ -5,10 +5,6 @@ import { View } from 'react-native';
5 5
 import { connect } from 'react-redux';
6 6
 
7 7
 import { Container } from '../../../base/react';
8
-import {
9
-    isNarrowAspectRatio,
10
-    makeAspectRatioAware
11
-} from '../../../base/responsive-ui';
12 8
 import { InviteButton } from '../../../invite';
13 9
 
14 10
 import AudioMuteButton from '../AudioMuteButton';
@@ -92,15 +88,10 @@ class Toolbox extends Component<Props, State> {
92 88
      * @returns {ReactElement}
93 89
      */
94 90
     render() {
95
-        const toolboxStyle
96
-            = isNarrowAspectRatio(this)
97
-                ? styles.toolboxNarrow
98
-                : styles.toolboxWide;
99
-
100 91
         return (
101 92
             <Container
102 93
                 onLayout = { this._onLayout }
103
-                style = { toolboxStyle }
94
+                style = { styles.toolbox }
104 95
                 visible = { this.props._visible }>
105 96
                 { this._renderToolbar() }
106 97
             </Container>
@@ -244,4 +235,4 @@ function _mapStateToProps(state: Object): Object {
244 235
     };
245 236
 }
246 237
 
247
-export default connect(_mapStateToProps)(makeAspectRatioAware(Toolbox));
238
+export default connect(_mapStateToProps)(Toolbox);

+ 4
- 21
react/features/toolbox/components/native/styles.js 查看文件

@@ -1,6 +1,4 @@
1 1
 // @flow
2
-import { StyleSheet } from 'react-native';
3
-
4 2
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../base/styles';
5 3
 
6 4
 import { HANGUP_BUTTON_SIZE } from '../../constants';
@@ -64,15 +62,11 @@ const styles = createStyleSheet({
64 62
      */
65 63
     toolbar: {
66 64
         alignItems: 'center',
67
-        bottom: 0,
68
-        flex: 0,
69 65
         flexDirection: 'row',
66
+        flexGrow: 0,
70 67
         justifyContent: 'center',
71
-        left: 0,
72 68
         marginBottom: BoxModel.margin / 2,
73
-        paddingHorizontal: BoxModel.margin,
74
-        position: 'absolute',
75
-        right: 0
69
+        paddingHorizontal: BoxModel.margin
76 70
     },
77 71
 
78 72
     /**
@@ -87,21 +81,10 @@ const styles = createStyleSheet({
87 81
 
88 82
     /**
89 83
      * The style of the root/top-level {@link Container} of {@link Toolbox}.
90
-     * This is the narrow layout version which locates the toolbar on top of
91
-     * the filmstrip, at the bottom of the screen.
92 84
      */
93
-    toolboxNarrow: {
85
+    toolbox: {
94 86
         flexDirection: 'column',
95
-        flexGrow: 1
96
-    },
97
-
98
-    /**
99
-     * The style of the root/top-level {@link Container} of {@link Toolbox}.
100
-     * This is the wide layout version which locates the toolbar at the bottom
101
-     * of the screen.
102
-     */
103
-    toolboxWide: {
104
-        ...StyleSheet.absoluteFillObject
87
+        flexGrow: 0
105 88
     },
106 89
 
107 90
     /**

Loading…
取消
儲存