Explorar el Código

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 hace 7 años
padre
commit
eac069c930

+ 56
- 4
react/features/conference/components/Conference.native.js Ver fichero

11
 import { DialogContainer } from '../../base/dialog';
11
 import { DialogContainer } from '../../base/dialog';
12
 import { getParticipantCount } from '../../base/participants';
12
 import { getParticipantCount } from '../../base/participants';
13
 import { Container, LoadingIndicator, TintedView } from '../../base/react';
13
 import { Container, LoadingIndicator, TintedView } from '../../base/react';
14
+import {
15
+    isNarrowAspectRatio,
16
+    makeAspectRatioAware
17
+} from '../../base/responsive-ui';
14
 import { TestConnectionInfo } from '../../base/testing';
18
 import { TestConnectionInfo } from '../../base/testing';
15
 import { createDesiredLocalTracks } from '../../base/tracks';
19
 import { createDesiredLocalTracks } from '../../base/tracks';
16
 import { ConferenceNotification } from '../../calendar-sync';
20
 import { ConferenceNotification } from '../../calendar-sync';
17
-import { Filmstrip } from '../../filmstrip';
21
+import { FILMSTRIP_SIZE, Filmstrip, isFilmstripVisible } from '../../filmstrip';
18
 import { LargeVideo } from '../../large-video';
22
 import { LargeVideo } from '../../large-video';
19
 import { CalleeInfoContainer } from '../../invite';
23
 import { CalleeInfoContainer } from '../../invite';
20
 import { NotificationsContainer } from '../../notifications';
24
 import { NotificationsContainer } from '../../notifications';
37
      */
41
      */
38
     _connecting: boolean,
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
      * Current conference's full URL.
52
      * Current conference's full URL.
42
      *
53
      *
272
                 <View
283
                 <View
273
                     pointerEvents = 'box-none'
284
                     pointerEvents = 'box-none'
274
                     style = { styles.toolboxAndFilmstripContainer }>
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
                       * The Toolbox is in a stacking layer bellow the Filmstrip.
295
                       * The Toolbox is in a stacking layer bellow the Filmstrip.
277
                       */}
296
                       */}
293
                     this._renderConferenceNotification()
312
                     this._renderConferenceNotification()
294
                 }
313
                 }
295
 
314
 
296
-                <NotificationsContainer />
297
-
298
                 {/*
315
                 {/*
299
                   * The dialogs are in the topmost stacking layers.
316
                   * The dialogs are in the topmost stacking layers.
300
                   */
317
                   */
350
                 ? <ConferenceNotification />
367
                 ? <ConferenceNotification />
351
                 : undefined);
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
  * @private
469
  * @private
424
  * @returns {{
470
  * @returns {{
425
  *     _connecting: boolean,
471
  *     _connecting: boolean,
472
+ *     _filmstripVisible: boolean,
426
  *     _locationURL: URL,
473
  *     _locationURL: URL,
427
  *     _participantCount: number,
474
  *     _participantCount: number,
428
  *     _reducedUI: boolean,
475
  *     _reducedUI: boolean,
467
          */
514
          */
468
         _connecting: Boolean(connecting_),
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
          * Current conference's full URL.
523
          * Current conference's full URL.
472
          *
524
          *
520
 
572
 
521
 // $FlowFixMe
573
 // $FlowFixMe
522
 export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
574
 export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
523
-    Conference);
575
+    makeAspectRatioAware(Conference));

+ 10
- 84
react/features/notifications/components/NotificationsContainer.native.js Ver fichero

4
 import { View } from 'react-native';
4
 import { View } from 'react-native';
5
 import { connect } from 'react-redux';
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
 import AbstractNotificationsContainer, {
7
 import AbstractNotificationsContainer, {
16
     _abstractMapStateToProps,
8
     _abstractMapStateToProps,
17
     type Props as AbstractProps
9
     type Props as AbstractProps
22
 type Props = AbstractProps & {
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
  * Implements a React {@link Component} which displays notifications and handles
23
  * Implements a React {@link Component} which displays notifications and handles
42
  * automatic dismissmal after a notification is shown for a defined timeout
24
  * automatic dismissmal after a notification is shown for a defined timeout
44
  *
26
  *
45
  * @extends {Component}
27
  * @extends {Component}
46
  */
28
  */
47
-class NotificationsContainer extends AbstractNotificationsContainer<Props> {
29
+class NotificationsContainer
30
+    extends AbstractNotificationsContainer<Props> {
48
 
31
 
49
     /**
32
     /**
50
      * Implements React's {@link Component#render()}.
33
      * Implements React's {@link Component#render()}.
64
                 pointerEvents = 'box-none'
47
                 pointerEvents = 'box-none'
65
                 style = { [
48
                 style = { [
66
                     styles.notificationContainer,
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
                             <Notification
55
                             <Notification
75
                                 { ...props }
56
                                 { ...props }
76
                                 key = { uid }
57
                                 key = { uid }
77
                                 onDismissed = { this._onDismissed }
58
                                 onDismissed = { this._onDismissed }
78
-                                uid = { uid } />
79
-
80
-                        );
81
-                    })
59
+                                uid = { uid } />))
82
                 }
60
                 }
83
             </View>
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
     _onDismissed: number => void;
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 Ver fichero

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { StyleSheet } from 'react-native';
4
-
5
 import { BoxModel, createStyleSheet, ColorPalette } from '../../base/styles';
3
 import { BoxModel, createStyleSheet, ColorPalette } from '../../base/styles';
6
 
4
 
7
 /**
5
 /**
48
      * Outermost container of a list of notifications.
46
      * Outermost container of a list of notifications.
49
      */
47
      */
50
     notificationContainer: {
48
     notificationContainer: {
51
-        ...StyleSheet.absoluteFillObject,
49
+        flexGrow: 0,
52
         justifyContent: 'flex-end',
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 Ver fichero

5
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
6
 
6
 
7
 import { Container } from '../../../base/react';
7
 import { Container } from '../../../base/react';
8
-import {
9
-    isNarrowAspectRatio,
10
-    makeAspectRatioAware
11
-} from '../../../base/responsive-ui';
12
 import { InviteButton } from '../../../invite';
8
 import { InviteButton } from '../../../invite';
13
 
9
 
14
 import AudioMuteButton from '../AudioMuteButton';
10
 import AudioMuteButton from '../AudioMuteButton';
92
      * @returns {ReactElement}
88
      * @returns {ReactElement}
93
      */
89
      */
94
     render() {
90
     render() {
95
-        const toolboxStyle
96
-            = isNarrowAspectRatio(this)
97
-                ? styles.toolboxNarrow
98
-                : styles.toolboxWide;
99
-
100
         return (
91
         return (
101
             <Container
92
             <Container
102
                 onLayout = { this._onLayout }
93
                 onLayout = { this._onLayout }
103
-                style = { toolboxStyle }
94
+                style = { styles.toolbox }
104
                 visible = { this.props._visible }>
95
                 visible = { this.props._visible }>
105
                 { this._renderToolbar() }
96
                 { this._renderToolbar() }
106
             </Container>
97
             </Container>
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 Ver fichero

1
 // @flow
1
 // @flow
2
-import { StyleSheet } from 'react-native';
3
-
4
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../base/styles';
2
 import { BoxModel, ColorPalette, createStyleSheet } from '../../../base/styles';
5
 
3
 
6
 import { HANGUP_BUTTON_SIZE } from '../../constants';
4
 import { HANGUP_BUTTON_SIZE } from '../../constants';
64
      */
62
      */
65
     toolbar: {
63
     toolbar: {
66
         alignItems: 'center',
64
         alignItems: 'center',
67
-        bottom: 0,
68
-        flex: 0,
69
         flexDirection: 'row',
65
         flexDirection: 'row',
66
+        flexGrow: 0,
70
         justifyContent: 'center',
67
         justifyContent: 'center',
71
-        left: 0,
72
         marginBottom: BoxModel.margin / 2,
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
 
81
 
88
     /**
82
     /**
89
      * The style of the root/top-level {@link Container} of {@link Toolbox}.
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
         flexDirection: 'column',
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…
Cancelar
Guardar