Browse Source

[RN] Add an abstraction layer to Modal

master
Bettenbuk Zoltan 6 years ago
parent
commit
eef31d05cf

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

1
 // @flow
1
 // @flow
2
 
2
 
3
 import React, { Component, type Node } from 'react';
3
 import React, { Component, type Node } from 'react';
4
-import { Modal, TouchableWithoutFeedback, View } from 'react-native';
4
+import { TouchableWithoutFeedback, View } from 'react-native';
5
+
6
+import { Modal } from '../../../react';
5
 
7
 
6
 import { bottomSheetStyles as styles } from './styles';
8
 import { bottomSheetStyles as styles } from './styles';
7
 
9
 
50
                 key = 'overlay'
52
                 key = 'overlay'
51
                 style = { styles.overlay } />,
53
                 style = { styles.overlay } />,
52
             <Modal
54
             <Modal
53
-                animationType = { 'slide' }
54
                 key = 'modal'
55
                 key = 'modal'
55
                 onRequestClose = { this._onCancel }
56
                 onRequestClose = { this._onCancel }
56
-                supportedOrientations = { [
57
-                    'landscape',
58
-                    'portrait'
59
-                ] }
60
-                transparent = { true }
61
                 visible = { true }>
57
                 visible = { true }>
62
                 <View style = { styles.container }>
58
                 <View style = { styles.container }>
63
                     <TouchableWithoutFeedback
59
                     <TouchableWithoutFeedback

+ 53
- 0
react/features/base/react/components/native/Modal.js View File

1
+// @flow
2
+
3
+import React, { Component, type Node } from 'react';
4
+import { Modal as NativeModal } from 'react-native';
5
+
6
+/**
7
+ * Type of the props of the component.
8
+ */
9
+type Props = {
10
+
11
+    /**
12
+     * Children of the component.
13
+     */
14
+    children: Node
15
+
16
+    /**
17
+     * NOTE: We pass through all props to {@code react-native#Modal} that are
18
+     * passed to this component, so we don't list them all here, as that would
19
+     * be an unnecessary duplication and probably an unmaintained list after a
20
+     * while.
21
+     *
22
+     * See list: https://facebook.github.io/react-native/docs/modal
23
+     */
24
+};
25
+
26
+/**
27
+ * Implements a generic Modal (using the built-in Modal component) to share
28
+ * behaviour across modals in the app.
29
+ */
30
+export default class Modal extends Component<Props> {
31
+
32
+    /**
33
+     * Implements {@code Component#render}.
34
+     *
35
+     * @inheritdoc
36
+     */
37
+    render() {
38
+        const { children, ...props } = this.props;
39
+
40
+        return (
41
+            <NativeModal
42
+                animationType = { 'slide' }
43
+                supportedOrientations = { [
44
+                    'landscape',
45
+                    'portrait'
46
+                ] }
47
+                transparent = { true }
48
+                { ...props } >
49
+                { children }
50
+            </NativeModal>
51
+        );
52
+    }
53
+}

+ 1
- 0
react/features/base/react/components/native/index.js View File

4
 export { default as HeaderLabel } from './HeaderLabel';
4
 export { default as HeaderLabel } from './HeaderLabel';
5
 export { default as Link } from './Link';
5
 export { default as Link } from './Link';
6
 export { default as LoadingIndicator } from './LoadingIndicator';
6
 export { default as LoadingIndicator } from './LoadingIndicator';
7
+export { default as Modal } from './Modal';
7
 export { default as NavigateSectionListEmptyComponent } from
8
 export { default as NavigateSectionListEmptyComponent } from
8
     './NavigateSectionListEmptyComponent';
9
     './NavigateSectionListEmptyComponent';
9
 export { default as NavigateSectionListItem }
10
 export { default as NavigateSectionListItem }

+ 2
- 8
react/features/settings/components/native/SettingsView.js View File

3
 import React from 'react';
3
 import React from 'react';
4
 import {
4
 import {
5
     Alert,
5
     Alert,
6
-    Modal,
7
     SafeAreaView,
6
     SafeAreaView,
8
     ScrollView,
7
     ScrollView,
9
     Switch,
8
     Switch,
13
 import { connect } from 'react-redux';
12
 import { connect } from 'react-redux';
14
 
13
 
15
 import { translate } from '../../../base/i18n';
14
 import { translate } from '../../../base/i18n';
16
-import { BackButton, Header } from '../../../base/react';
15
+import { BackButton, Header, Modal } from '../../../base/react';
17
 
16
 
18
 import {
17
 import {
19
     AbstractSettingsView,
18
     AbstractSettingsView,
58
     render() {
57
     render() {
59
         return (
58
         return (
60
             <Modal
59
             <Modal
61
-                animationType = 'slide'
62
                 onRequestClose = { this._onRequestClose }
60
                 onRequestClose = { this._onRequestClose }
63
-                presentationStyle = 'fullScreen'
64
-                supportedOrientations = { [
65
-                    'landscape',
66
-                    'portrait'
67
-                ] }
61
+                presentationStyle = 'overFullScreen'
68
                 visible = { this.props._visible }>
62
                 visible = { this.props._visible }>
69
                 <View style = { Header.pageStyle }>
63
                 <View style = { Header.pageStyle }>
70
                     { this._renderHeader() }
64
                     { this._renderHeader() }

+ 5
- 0
react/features/settings/components/native/styles.js View File

64
         padding: 5
64
         padding: 5
65
     },
65
     },
66
 
66
 
67
+    settingsForm: {
68
+        backgroundColor: ColorPalette.white,
69
+        flex: 1
70
+    },
71
+
67
     /**
72
     /**
68
      * Global {@code Text} color for the components.
73
      * Global {@code Text} color for the components.
69
      */
74
      */

Loading…
Cancel
Save