Bläddra i källkod

[RN] Replace red screen with dialog

master
Bettenbuk Zoltan 6 år sedan
förälder
incheckning
98c7430b6f

+ 7
- 3
react/features/base/dialog/components/native/ConfirmDialog.js Visa fil

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

+ 4
- 4
react/features/overlay/components/AbstractPageReloadOverlay.js Visa fil

23
  * The type of the React {@code Component} props of
23
  * The type of the React {@code Component} props of
24
  * {@link AbstractPageReloadOverlay}.
24
  * {@link AbstractPageReloadOverlay}.
25
  */
25
  */
26
-type Props = {
26
+export type Props = {
27
 
27
 
28
     /**
28
     /**
29
      * The details is an object containing more information about the connection
29
      * The details is an object containing more information about the connection
82
 /**
82
 /**
83
  * Implements an abstract React {@link Component} for the page reload overlays.
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
      * Determines whether this overlay needs to be rendered (according to a
88
      * Determines whether this overlay needs to be rendered (according to a
89
      * specific redux state). Called by {@link OverlayContainer}.
89
      * specific redux state). Called by {@link OverlayContainer}.
132
      * instance is to be initialized.
132
      * instance is to be initialized.
133
      * @public
133
      * @public
134
      */
134
      */
135
-    constructor(props: Object) {
135
+    constructor(props: P) {
136
         super(props);
136
         super(props);
137
 
137
 
138
         /**
138
         /**

+ 6
- 4
react/features/overlay/components/OverlayFrame.native.js Visa fil

1
 // @flow
1
 // @flow
2
 
2
 
3
 import React, { Component, type Node } from 'react';
3
 import React, { Component, type Node } from 'react';
4
-import { SafeAreaView } from 'react-native';
4
+import { SafeAreaView, View } from 'react-native';
5
 
5
 
6
 import { overlayFrame as styles } from './styles';
6
 import { overlayFrame as styles } from './styles';
7
 
7
 
28
      */
28
      */
29
     render() {
29
     render() {
30
         return (
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 Visa fil

18
      * Indicates the css style of the overlay. If true, then lighter; darker,
18
      * Indicates the css style of the overlay. If true, then lighter; darker,
19
      * otherwise.
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 Visa fil

1
+// @flow
2
+
1
 import React from 'react';
3
 import React from 'react';
2
-import { Text, View } from 'react-native';
4
+import { Text } from 'react-native';
3
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
4
 
6
 
5
 import { appNavigate, reloadNow } from '../../app';
7
 import { appNavigate, reloadNow } from '../../app';
8
+import { ColorSchemeRegistry } from '../../base/color-scheme';
9
+import { ConfirmDialog } from '../../base/dialog';
6
 import { translate } from '../../base/i18n';
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
 import { setFatalError } from '../actions';
17
 import { setFatalError } from '../actions';
12
 import OverlayFrame from './OverlayFrame';
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
  * Implements a React Component for page reload overlay. Shown before the
29
  * Implements a React Component for page reload overlay. Shown before the
17
  * conference is reloaded. Shows a warning message and counts down towards the
30
  * conference is reloaded. Shows a warning message and counts down towards the
18
  * reload.
31
  * reload.
19
  */
32
  */
20
-class PageReloadOverlay extends AbstractPageReloadOverlay {
33
+class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
34
+    _interval: IntervalID;
35
+
21
     /**
36
     /**
22
      * Initializes a new PageReloadOverlay instance.
37
      * Initializes a new PageReloadOverlay instance.
23
      *
38
      *
32
         this._onReloadNow = this._onReloadNow.bind(this);
47
         this._onReloadNow = this._onReloadNow.bind(this);
33
     }
48
     }
34
 
49
 
50
+    _onCancel: () => void
51
+
35
     /**
52
     /**
36
      * Handle clicking of the "Cancel" button. It will navigate back to the
53
      * Handle clicking of the "Cancel" button. It will navigate back to the
37
      * welcome page.
54
      * welcome page.
45
         this.props.dispatch(appNavigate(undefined));
62
         this.props.dispatch(appNavigate(undefined));
46
     }
63
     }
47
 
64
 
65
+    _onReloadNow: () => void
66
+
48
     /**
67
     /**
49
      * Handle clicking on the "Reload Now" button. It will navigate to the same
68
      * Handle clicking on the "Reload Now" button. It will navigate to the same
50
      * conference URL as before immediately, without waiting for the timer to
69
      * conference URL as before immediately, without waiting for the timer to
65
      * @returns {ReactElement}
84
      * @returns {ReactElement}
66
      */
85
      */
67
     render() {
86
     render() {
68
-        const { t } = this.props;
87
+        const { _dialogStyles, t } = this.props;
69
         const { message, timeLeft, title } = this.state;
88
         const { message, timeLeft, title } = this.state;
70
 
89
 
71
         return (
90
         return (
72
             <OverlayFrame>
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
                     </Text>
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
             </OverlayFrame>
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 Visa fil

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

+ 4
- 66
react/features/overlay/components/styles.js Visa fil

1
 import { StyleSheet } from 'react-native';
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
  * The React {@code Component} styles of {@code OverlayFrame}.
6
  * The React {@code Component} styles of {@code OverlayFrame}.
17
      */
12
      */
18
     container: {
13
     container: {
19
         ...StyleSheet.absoluteFillObject,
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
 });

Laddar…
Avbryt
Spara