Переглянути джерело

feat(notifications): NotificationsContainer native updates (#13047)

feat(notifications): NotificationsContainer native updates
factor2
Calinteodor 2 роки тому
джерело
коміт
1fc5d6e97e
Аккаунт користувача з таким Email не знайдено

+ 1
- 6
react/features/filmstrip/components/native/Filmstrip.js Переглянути файл

9
 import { connect } from '../../../base/redux';
9
 import { connect } from '../../../base/redux';
10
 import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
10
 import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
11
 import { getHideSelfView } from '../../../base/settings/functions.any';
11
 import { getHideSelfView } from '../../../base/settings/functions.any';
12
-import { areThereNotifications } from '../../../notifications/functions';
13
 import { isToolboxVisible } from '../../../toolbox/functions';
12
 import { isToolboxVisible } from '../../../toolbox/functions';
14
 import { setVisibleRemoteParticipants } from '../../actions';
13
 import { setVisibleRemoteParticipants } from '../../actions';
15
 import {
14
 import {
53
 
52
 
54
     _localParticipantId: string,
53
     _localParticipantId: string,
55
 
54
 
56
-    _notificationsAvailable: boolean,
57
-
58
     /**
55
     /**
59
      * The participants in the conference.
56
      * The participants in the conference.
60
      */
57
      */
252
             _disableSelfView,
249
             _disableSelfView,
253
             _toolboxVisible,
250
             _toolboxVisible,
254
             _localParticipantId,
251
             _localParticipantId,
255
-            _notificationsAvailable,
256
             _participants,
252
             _participants,
257
             _visible
253
             _visible
258
         } = this.props;
254
         } = this.props;
261
             return null;
257
             return null;
262
         }
258
         }
263
 
259
 
264
-        const bottomEdge = Platform.OS === 'ios' && !_toolboxVisible && !_notificationsAvailable;
260
+        const bottomEdge = Platform.OS === 'ios' && !_toolboxVisible;
265
         const isNarrowAspectRatio = _aspectRatio === ASPECT_RATIO_NARROW;
261
         const isNarrowAspectRatio = _aspectRatio === ASPECT_RATIO_NARROW;
266
         const filmstripStyle = isNarrowAspectRatio ? styles.filmstripNarrow : styles.filmstripWide;
262
         const filmstripStyle = isNarrowAspectRatio ? styles.filmstripNarrow : styles.filmstripWide;
267
         const { height, width } = this._getDimensions();
263
         const { height, width } = this._getDimensions();
335
         _clientWidth: responsiveUI.clientWidth,
331
         _clientWidth: responsiveUI.clientWidth,
336
         _disableSelfView: disableSelfView,
332
         _disableSelfView: disableSelfView,
337
         _localParticipantId: getLocalParticipant(state)?.id,
333
         _localParticipantId: getLocalParticipant(state)?.id,
338
-        _notificationsAvailable: areThereNotifications(state),
339
         _participants: showRemoteVideos ? remoteParticipants : NO_REMOTE_VIDEOS,
334
         _participants: showRemoteVideos ? remoteParticipants : NO_REMOTE_VIDEOS,
340
         _toolboxVisible: isToolboxVisible(state),
335
         _toolboxVisible: isToolboxVisible(state),
341
         _visible: enabled && isFilmstripVisible(state)
336
         _visible: enabled && isFilmstripVisible(state)

react/features/notifications/components/native/NotificationsContainer.js → react/features/notifications/components/native/NotificationsContainer.tsx Переглянути файл

1
-// @flow
1
+/* eslint-disable lines-around-comment  */
2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
+import { WithTranslation } from 'react-i18next';
4
 import { Platform } from 'react-native';
5
 import { Platform } from 'react-native';
5
-import { SafeAreaView } from 'react-native-safe-area-context';
6
+import { Edge, SafeAreaView } from 'react-native-safe-area-context';
6
 
7
 
7
-import { connect } from '../../../base/redux';
8
+import { IReduxState } from '../../../app/types';
9
+import { connect } from '../../../base/redux/functions';
8
 import { hideNotification } from '../../actions';
10
 import { hideNotification } from '../../actions';
9
 import { areThereNotifications } from '../../functions';
11
 import { areThereNotifications } from '../../functions';
10
 import NotificationsTransition from '../NotificationsTransition';
12
 import NotificationsTransition from '../NotificationsTransition';
11
 
13
 
12
 import Notification from './Notification';
14
 import Notification from './Notification';
15
+// @ts-ignore
16
+import styles from './styles';
13
 
17
 
14
 
18
 
15
-type Props = {
19
+interface IProps extends WithTranslation {
16
 
20
 
17
     /**
21
     /**
18
      * The notifications to be displayed, with the first index being the
22
      * The notifications to be displayed, with the first index being the
19
      * notification at the top and the rest shown below it in order.
23
      * notification at the top and the rest shown below it in order.
20
      */
24
      */
21
-    _notifications: Array<Object>,
25
+    _notifications: Array<Object>;
22
 
26
 
23
     /**
27
     /**
24
      * Invoked to update the redux store in order to remove notifications.
28
      * Invoked to update the redux store in order to remove notifications.
25
      */
29
      */
26
-    dispatch: Function,
30
+    dispatch: Function;
27
 
31
 
28
-    toolboxVisible: boolean
29
-};
32
+    /**
33
+     * Checks toolbox visibility.
34
+     */
35
+    toolboxVisible: boolean;
36
+}
30
 
37
 
31
 /**
38
 /**
32
  * Implements a React {@link Component} which displays notifications and handles
39
  * Implements a React {@link Component} which displays notifications and handles
35
  *
42
  *
36
  * @augments {Component}
43
  * @augments {Component}
37
  */
44
  */
38
-class NotificationsContainer extends Component<Props> {
45
+class NotificationsContainer extends Component<IProps> {
39
 
46
 
40
     /**
47
     /**
41
      * A timeout id returned by setTimeout.
48
      * A timeout id returned by setTimeout.
42
      */
49
      */
43
-    _notificationDismissTimeout: ?TimeoutID;
50
+    _notificationDismissTimeout: any;
44
 
51
 
45
     /**
52
     /**
46
      * Initializes a new {@code NotificationsContainer} instance.
53
      * Initializes a new {@code NotificationsContainer} instance.
47
      *
54
      *
48
      * @inheritdoc
55
      * @inheritdoc
49
      */
56
      */
50
-    constructor(props: Props) {
57
+    constructor(props: IProps) {
51
         super(props);
58
         super(props);
52
 
59
 
53
         /**
60
         /**
70
      */
77
      */
71
     componentDidMount() {
78
     componentDidMount() {
72
         // Set the initial dismiss timeout (if any)
79
         // Set the initial dismiss timeout (if any)
80
+        // @ts-ignore
73
         this._manageDismissTimeout();
81
         this._manageDismissTimeout();
74
     }
82
     }
75
 
83
 
78
      *
86
      *
79
      * @inheritdoc
87
      * @inheritdoc
80
      */
88
      */
81
-    componentDidUpdate(prevProps: Props) {
89
+    componentDidUpdate(prevProps: IProps) {
82
         this._manageDismissTimeout(prevProps);
90
         this._manageDismissTimeout(prevProps);
83
     }
91
     }
84
 
92
 
85
     /**
93
     /**
86
      * Sets/clears the dismiss timeout for the top notification.
94
      * Sets/clears the dismiss timeout for the top notification.
87
      *
95
      *
88
-     * @param {P} [prevProps] - The previous properties (if called from
96
+     * @param {IProps} [prevProps] - The previous properties (if called from
89
      * {@code componentDidUpdate}).
97
      * {@code componentDidUpdate}).
90
      * @returns {void}
98
      * @returns {void}
91
      * @private
99
      * @private
92
      */
100
      */
93
-    _manageDismissTimeout(prevProps: ?Props) {
101
+    _manageDismissTimeout(prevProps: IProps) {
94
         const { _notifications } = this.props;
102
         const { _notifications } = this.props;
95
 
103
 
96
         if (_notifications.length) {
104
         if (_notifications.length) {
97
             const notification = _notifications[0];
105
             const notification = _notifications[0];
98
-            const previousNotification
99
-                = prevProps && prevProps._notifications.length
100
-                    ? prevProps._notifications[0]
101
-                    : undefined;
106
+            const previousNotification = prevProps?._notifications.length
107
+                ? prevProps._notifications[0] : undefined;
102
 
108
 
103
             if (notification !== previousNotification) {
109
             if (notification !== previousNotification) {
104
                 this._clearNotificationDismissTimeout();
110
                 this._clearNotificationDismissTimeout();
105
 
111
 
106
-                if (notification && notification.timeout) {
107
-                    const {
108
-                        timeout,
109
-                        uid
110
-                    } = notification;
112
+                // @ts-ignore
113
+                if (notification?.timeout) {
111
 
114
 
115
+                    // @ts-ignore
116
+                    const { timeout, uid } = notification;
117
+
118
+                    // @ts-ignore
112
                     this._notificationDismissTimeout = setTimeout(() => {
119
                     this._notificationDismissTimeout = setTimeout(() => {
113
                         // Perform a no-op if a timeout is not specified.
120
                         // Perform a no-op if a timeout is not specified.
114
                         this._onDismissed(uid);
121
                         this._onDismissed(uid);
142
         this._notificationDismissTimeout = null;
149
         this._notificationDismissTimeout = null;
143
     }
150
     }
144
 
151
 
145
-    _onDismissed: number => void;
146
-
147
     /**
152
     /**
148
      * Emits an action to remove the notification from the redux store so it
153
      * Emits an action to remove the notification from the redux store so it
149
      * stops displaying.
154
      * stops displaying.
150
      *
155
      *
151
-     * @param {number} uid - The id of the notification to be removed.
156
+     * @param {Object} uid - The id of the notification to be removed.
152
      * @private
157
      * @private
153
      * @returns {void}
158
      * @returns {void}
154
      */
159
      */
155
-    _onDismissed(uid) {
160
+    _onDismissed(uid: any) {
156
         const { _notifications } = this.props;
161
         const { _notifications } = this.props;
157
 
162
 
158
         // Clear the timeout only if it's the top notification that's being
163
         // Clear the timeout only if it's the top notification that's being
159
         // dismissed (the timeout is set only for the top one).
164
         // dismissed (the timeout is set only for the top one).
165
+        // @ts-ignore
160
         if (!_notifications.length || _notifications[0].uid === uid) {
166
         if (!_notifications.length || _notifications[0].uid === uid) {
161
             this._clearNotificationDismissTimeout();
167
             this._clearNotificationDismissTimeout();
162
         }
168
         }
171
      */
177
      */
172
     render() {
178
     render() {
173
         const { _notifications, toolboxVisible } = this.props;
179
         const { _notifications, toolboxVisible } = this.props;
174
-        const bottomEdge = Platform.OS === 'ios' && !toolboxVisible;
180
+        const notificationsContainerStyle
181
+            = toolboxVisible ? styles.withToolbox : styles.withoutToolbox;
175
 
182
 
176
         return (
183
         return (
177
             <SafeAreaView
184
             <SafeAreaView
178
-                edges = { [ bottomEdge && 'bottom', 'left', 'right' ].filter(Boolean) }>
185
+                edges = { [ Platform.OS === 'ios' && 'bottom', 'left', 'right' ].filter(Boolean) as Edge[] }
186
+                style = { notificationsContainerStyle as any }>
179
                 <NotificationsTransition>
187
                 <NotificationsTransition>
180
                     {
188
                     {
181
-                        _notifications.map((notification, index) => {
189
+                        _notifications.map(notification => {
190
+                            // @ts-ignore
182
                             const { props, uid } = notification;
191
                             const { props, uid } = notification;
183
 
192
 
184
                             return (
193
                             return (
185
                                 <Notification
194
                                 <Notification
186
                                     { ...props }
195
                                     { ...props }
187
-                                    key = { index }
196
+                                    key = { uid }
188
                                     onDismissed = { this._onDismissed }
197
                                     onDismissed = { this._onDismissed }
189
                                     uid = { uid } />
198
                                     uid = { uid } />
190
                             );
199
                             );
194
             </SafeAreaView>
203
             </SafeAreaView>
195
         );
204
         );
196
     }
205
     }
197
-
198
-    _onDismissed: number => void;
199
 }
206
 }
200
 
207
 
201
 /**
208
 /**
206
  * @private
213
  * @private
207
  * @returns {Props}
214
  * @returns {Props}
208
  */
215
  */
209
-export function mapStateToProps(state: Object) {
216
+export function mapStateToProps(state: IReduxState) {
210
     const { notifications } = state['features/notifications'];
217
     const { notifications } = state['features/notifications'];
211
     const _visible = areThereNotifications(state);
218
     const _visible = areThereNotifications(state);
212
 
219
 

+ 11
- 0
react/features/notifications/components/native/styles.js Переглянути файл

105
         display: 'flex',
105
         display: 'flex',
106
         flexDirection: 'row',
106
         flexDirection: 'row',
107
         marginLeft: BaseTheme.spacing[1]
107
         marginLeft: BaseTheme.spacing[1]
108
+    },
109
+
110
+    withToolbox: {
111
+        bottom: 64,
112
+        position: 'absolute',
113
+        width: '100%'
114
+    },
115
+
116
+    withoutToolbox: {
117
+        position: 'absolute',
118
+        width: '100%'
108
     }
119
     }
109
 };
120
 };

Завантаження…
Відмінити
Зберегти