Quellcode durchsuchen

[RN] Add an abstraction layer to Modal

efficient_tiling
Bettenbuk Zoltan vor 6 Jahren
Ursprung
Commit
eef31d05cf

+ 3
- 7
react/features/base/dialog/components/native/BottomSheet.js Datei anzeigen

@@ -1,7 +1,9 @@
1 1
 // @flow
2 2
 
3 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 8
 import { bottomSheetStyles as styles } from './styles';
7 9
 
@@ -50,14 +52,8 @@ export default class BottomSheet extends Component<Props> {
50 52
                 key = 'overlay'
51 53
                 style = { styles.overlay } />,
52 54
             <Modal
53
-                animationType = { 'slide' }
54 55
                 key = 'modal'
55 56
                 onRequestClose = { this._onCancel }
56
-                supportedOrientations = { [
57
-                    'landscape',
58
-                    'portrait'
59
-                ] }
60
-                transparent = { true }
61 57
                 visible = { true }>
62 58
                 <View style = { styles.container }>
63 59
                     <TouchableWithoutFeedback

+ 53
- 0
react/features/base/react/components/native/Modal.js Datei anzeigen

@@ -0,0 +1,53 @@
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 Datei anzeigen

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

+ 2
- 8
react/features/settings/components/native/SettingsView.js Datei anzeigen

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

+ 5
- 0
react/features/settings/components/native/styles.js Datei anzeigen

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

Laden…
Abbrechen
Speichern