Browse Source

[RN] Replace red screen with dialog

master
Bettenbuk Zoltan 6 years ago
parent
commit
98c7430b6f

+ 7
- 3
react/features/base/dialog/components/native/ConfirmDialog.js View File

@@ -43,7 +43,7 @@ class ConfirmDialog extends BaseSubmitDialog<Props, *> {
43 43
      * @returns {string}
44 44
      */
45 45
     _getSubmitButtonKey() {
46
-        return 'dialog.confirmYes';
46
+        return this.props.okKey || 'dialog.confirmYes';
47 47
     }
48 48
 
49 49
     _onCancel: () => void;
@@ -57,7 +57,7 @@ class ConfirmDialog extends BaseSubmitDialog<Props, *> {
57 57
      * @inheritdoc
58 58
      */
59 59
     _renderAdditionalButtons() {
60
-        const { _dialogStyles, t } = this.props;
60
+        const { _dialogStyles, cancelKey, t } = this.props;
61 61
 
62 62
         return (
63 63
             <TouchableOpacity
@@ -68,7 +68,7 @@ class ConfirmDialog extends BaseSubmitDialog<Props, *> {
68 68
                     _dialogStyles.buttonSeparator
69 69
                 ] }>
70 70
                 <Text style = { _dialogStyles.text }>
71
-                    { t('dialog.confirmNo') }
71
+                    { t(cancelKey || 'dialog.confirmNo') }
72 72
                 </Text>
73 73
             </TouchableOpacity>
74 74
         );
@@ -80,6 +80,10 @@ class ConfirmDialog extends BaseSubmitDialog<Props, *> {
80 80
      * @inheritdoc
81 81
      */
82 82
     _renderSubmittable() {
83
+        if (this.props.children) {
84
+            return this.props.children;
85
+        }
86
+
83 87
         const { _dialogStyles, contentKey, t } = this.props;
84 88
         const content
85 89
             = typeof contentKey === 'string'

+ 4
- 4
react/features/overlay/components/AbstractPageReloadOverlay.js View File

@@ -23,7 +23,7 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
23 23
  * The type of the React {@code Component} props of
24 24
  * {@link AbstractPageReloadOverlay}.
25 25
  */
26
-type Props = {
26
+export type Props = {
27 27
 
28 28
     /**
29 29
      * The details is an object containing more information about the connection
@@ -82,8 +82,8 @@ type State = {
82 82
 /**
83 83
  * Implements an abstract React {@link Component} for the page reload overlays.
84 84
  */
85
-export default class AbstractPageReloadOverlay
86
-    extends Component<Props, State> {
85
+export default class AbstractPageReloadOverlay<P: Props>
86
+    extends Component<P, State> {
87 87
     /**
88 88
      * Determines whether this overlay needs to be rendered (according to a
89 89
      * specific redux state). Called by {@link OverlayContainer}.
@@ -132,7 +132,7 @@ export default class AbstractPageReloadOverlay
132 132
      * instance is to be initialized.
133 133
      * @public
134 134
      */
135
-    constructor(props: Object) {
135
+    constructor(props: P) {
136 136
         super(props);
137 137
 
138 138
         /**

+ 6
- 4
react/features/overlay/components/OverlayFrame.native.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import React, { Component, type Node } from 'react';
4
-import { SafeAreaView } from 'react-native';
4
+import { SafeAreaView, View } from 'react-native';
5 5
 
6 6
 import { overlayFrame as styles } from './styles';
7 7
 
@@ -28,9 +28,11 @@ export default class OverlayFrame extends Component<Props> {
28 28
      */
29 29
     render() {
30 30
         return (
31
-            <SafeAreaView style = { styles.container }>
32
-                { this.props.children }
33
-            </SafeAreaView>
31
+            <View style = { styles.container }>
32
+                <SafeAreaView style = { styles.safeContainer } >
33
+                    { this.props.children }
34
+                </SafeAreaView>
35
+            </View>
34 36
         );
35 37
     }
36 38
 }

+ 1
- 1
react/features/overlay/components/OverlayFrame.web.js View File

@@ -18,7 +18,7 @@ type Props = {
18 18
      * Indicates the css style of the overlay. If true, then lighter; darker,
19 19
      * otherwise.
20 20
      */
21
-    isLightOverlay: boolean
21
+    isLightOverlay?: boolean
22 22
 };
23 23
 
24 24
 /**

+ 50
- 30
react/features/overlay/components/PageReloadOverlay.native.js View File

@@ -1,23 +1,38 @@
1
+// @flow
2
+
1 3
 import React from 'react';
2
-import { Text, View } from 'react-native';
4
+import { Text } from 'react-native';
3 5
 import { connect } from 'react-redux';
4 6
 
5 7
 import { appNavigate, reloadNow } from '../../app';
8
+import { ColorSchemeRegistry } from '../../base/color-scheme';
9
+import { ConfirmDialog } from '../../base/dialog';
6 10
 import { translate } from '../../base/i18n';
7
-import { LoadingIndicator } from '../../base/react';
11
+import { StyleType } from '../../base/styles';
8 12
 
9
-import AbstractPageReloadOverlay, { abstractMapStateToProps }
10
-    from './AbstractPageReloadOverlay';
13
+import AbstractPageReloadOverlay, {
14
+    abstractMapStateToProps,
15
+    type Props as AbstractProps
16
+} from './AbstractPageReloadOverlay';
11 17
 import { setFatalError } from '../actions';
12 18
 import OverlayFrame from './OverlayFrame';
13
-import { pageReloadOverlay as styles } from './styles';
19
+
20
+type Props = AbstractProps & {
21
+
22
+    /**
23
+     * The color-schemed stylesheet of the base/dialog feature.
24
+     */
25
+    _dialogStyles: StyleType
26
+}
14 27
 
15 28
 /**
16 29
  * Implements a React Component for page reload overlay. Shown before the
17 30
  * conference is reloaded. Shows a warning message and counts down towards the
18 31
  * reload.
19 32
  */
20
-class PageReloadOverlay extends AbstractPageReloadOverlay {
33
+class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
34
+    _interval: IntervalID;
35
+
21 36
     /**
22 37
      * Initializes a new PageReloadOverlay instance.
23 38
      *
@@ -32,6 +47,8 @@ class PageReloadOverlay extends AbstractPageReloadOverlay {
32 47
         this._onReloadNow = this._onReloadNow.bind(this);
33 48
     }
34 49
 
50
+    _onCancel: () => void
51
+
35 52
     /**
36 53
      * Handle clicking of the "Cancel" button. It will navigate back to the
37 54
      * welcome page.
@@ -45,6 +62,8 @@ class PageReloadOverlay extends AbstractPageReloadOverlay {
45 62
         this.props.dispatch(appNavigate(undefined));
46 63
     }
47 64
 
65
+    _onReloadNow: () => void
66
+
48 67
     /**
49 68
      * Handle clicking on the "Reload Now" button. It will navigate to the same
50 69
      * conference URL as before immediately, without waiting for the timer to
@@ -65,37 +84,38 @@ class PageReloadOverlay extends AbstractPageReloadOverlay {
65 84
      * @returns {ReactElement}
66 85
      */
67 86
     render() {
68
-        const { t } = this.props;
87
+        const { _dialogStyles, t } = this.props;
69 88
         const { message, timeLeft, title } = this.state;
70 89
 
71 90
         return (
72 91
             <OverlayFrame>
73
-                <View style = { styles.container }>
74
-                    <View style = { styles.loadingIndicator }>
75
-                        <LoadingIndicator />
76
-                    </View>
77
-                    <Text style = { styles.title }>
78
-                        { t(title) }
92
+                <ConfirmDialog
93
+                    cancelKey = 'dialog.Cancel'
94
+                    okKey = 'dialog.rejoinNow'
95
+                    onCancel = { this._onCancel }
96
+                    onSubmit = { this._onReloadNow }>
97
+                    <Text style = { _dialogStyles.text }>
98
+                        { `${t(title)} ${t(message, { seconds: timeLeft })}` }
79 99
                     </Text>
80
-                    <Text style = { styles.message }>
81
-                        { t(message, { seconds: timeLeft }) }
82
-                    </Text>
83
-                    <View style = { styles.buttonBox }>
84
-                        <Text
85
-                            onPress = { this._onReloadNow }
86
-                            style = { styles.button } >
87
-                            { t('dialog.rejoinNow') }
88
-                        </Text>
89
-                        <Text
90
-                            onPress = { this._onCancel }
91
-                            style = { styles.button } >
92
-                            { t('dialog.Cancel') }
93
-                        </Text>
94
-                    </View>
95
-                </View>
100
+                </ConfirmDialog>
96 101
             </OverlayFrame>
97 102
         );
98 103
     }
99 104
 }
100 105
 
101
-export default translate(connect(abstractMapStateToProps)(PageReloadOverlay));
106
+/**
107
+ * Maps part of the Redux state to the props of this component.
108
+ *
109
+ * @param {Object} state - The Redux state.
110
+ * @returns {{
111
+ *     _dialogStyles: StyleType
112
+ * }}
113
+ */
114
+function _mapStateToProps(state) {
115
+    return {
116
+        ...abstractMapStateToProps(state),
117
+        _dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
118
+    };
119
+}
120
+
121
+export default translate(connect(_mapStateToProps)(PageReloadOverlay));

+ 11
- 3
react/features/overlay/components/PageReloadOverlay.web.js View File

@@ -1,10 +1,14 @@
1
+// @flow
2
+
1 3
 import React from 'react';
2 4
 import { connect } from 'react-redux';
3 5
 
4 6
 import { translate } from '../../base/i18n';
5 7
 
6
-import AbstractPageReloadOverlay, { abstractMapStateToProps }
7
-    from './AbstractPageReloadOverlay';
8
+import AbstractPageReloadOverlay, {
9
+    abstractMapStateToProps,
10
+    type Props
11
+} from './AbstractPageReloadOverlay';
8 12
 import OverlayFrame from './OverlayFrame';
9 13
 
10 14
 /**
@@ -12,7 +16,7 @@ import OverlayFrame from './OverlayFrame';
12 16
  * conference is reloaded. Shows a warning message and counts down towards the
13 17
  * reload.
14 18
  */
15
-class PageReloadOverlay extends AbstractPageReloadOverlay {
19
+class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
16 20
     /**
17 21
      * Implements React's {@link Component#render()}.
18 22
      *
@@ -39,6 +43,10 @@ class PageReloadOverlay extends AbstractPageReloadOverlay {
39 43
             </OverlayFrame>
40 44
         );
41 45
     }
46
+
47
+    _renderButton: () => React$Element<*>
48
+
49
+    _renderProgressBar: () => React$Element<*>
42 50
 }
43 51
 
44 52
 export default translate(connect(abstractMapStateToProps)(PageReloadOverlay));

+ 4
- 66
react/features/overlay/components/styles.js View File

@@ -1,11 +1,6 @@
1 1
 import { StyleSheet } from 'react-native';
2 2
 
3
-import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
4
-
5
-/**
6
- * The default color of text on overlays.
7
- */
8
-const TEXT_COLOR = ColorPalette.white;
3
+import { ColorPalette, createStyleSheet } from '../../base/styles';
9 4
 
10 5
 /**
11 6
  * The React {@code Component} styles of {@code OverlayFrame}.
@@ -17,67 +12,10 @@ export const overlayFrame = createStyleSheet({
17 12
      */
18 13
     container: {
19 14
         ...StyleSheet.absoluteFillObject,
20
-        backgroundColor: ColorPalette.red
21
-    }
22
-});
23
-
24
-/**
25
- * The React {@code Component} styles of {@code PageReloadOverlay}.
26
- */
27
-export const pageReloadOverlay = createStyleSheet({
28
-    /**
29
-     * Style for the buttons on {@code PageReloadOverlay}.
30
-     */
31
-    button: {
32
-        color: TEXT_COLOR,
33
-        fontSize: 20,
34
-        marginVertical: BoxModel.margin,
35
-        textAlign: 'center'
36
-    },
37
-
38
-    /**
39
-     * Style for the "box" surrounding the buttons at the bottom of the page.
40
-     */
41
-    buttonBox: {
42
-        bottom: BoxModel.margin,
43
-        left: 0,
44
-        position: 'absolute',
45
-        right: 0
46
-    },
47
-
48
-    /**
49
-     * Style for the container of the {@code PageReloadOVerlay}.
50
-     */
51
-    container: {
52
-        flex: 1,
53
-        margin: BoxModel.margin * 2
54
-    },
55
-
56
-    /**
57
-     * Style for the {@code LoadingIndicator}.
58
-     */
59
-    loadingIndicator: {
60
-        ...StyleSheet.absoluteFillObject,
61
-        alignItems: 'center',
62
-        justifyContent: 'center'
15
+        backgroundColor: ColorPalette.black
63 16
     },
64 17
 
65
-    /**
66
-     * Style for the descriptive error message.
67
-     */
68
-    message: {
69
-        color: TEXT_COLOR,
70
-        fontSize: 16,
71
-        marginTop: BoxModel.margin,
72
-        textAlign: 'center'
73
-    },
74
-
75
-    /**
76
-     * Style for the error title.
77
-     */
78
-    title: {
79
-        color: TEXT_COLOR,
80
-        fontSize: 24,
81
-        textAlign: 'center'
18
+    safeContainer: {
19
+        flex: 1
82 20
     }
83 21
 });

Loading…
Cancel
Save