浏览代码

fix: iOS 10 bottom sheet style

master
Bettenbuk Zoltan 6 年前
父节点
当前提交
d387cbe5bd

+ 35
- 21
react/features/base/dialog/components/native/BottomSheet.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
 import React, { PureComponent, type Node } from 'react';
3
 import React, { PureComponent, type Node } from 'react';
4
-import { SafeAreaView, View } from 'react-native';
4
+import { Platform, SafeAreaView, View } from 'react-native';
5
 
5
 
6
 import { ColorSchemeRegistry } from '../../../color-scheme';
6
 import { ColorSchemeRegistry } from '../../../color-scheme';
7
 import { SlidingView } from '../../../react';
7
 import { SlidingView } from '../../../react';
36
  * A component emulating Android's BottomSheet.
36
  * A component emulating Android's BottomSheet.
37
  */
37
  */
38
 class BottomSheet extends PureComponent<Props> {
38
 class BottomSheet extends PureComponent<Props> {
39
-    /**
40
-     * Assembles a style for the BottomSheet container.
41
-     *
42
-     * @private
43
-     * @returns {StyleType}
44
-     */
45
-    _getContainerStyle() {
46
-        const { _styles } = this.props;
47
-
48
-        return {
49
-            ...styles.container,
50
-            backgroundColor: _styles.sheet.backgroundColor
51
-        };
52
-    }
53
-
54
     /**
39
     /**
55
      * Implements React's {@link Component#render()}.
40
      * Implements React's {@link Component#render()}.
56
      *
41
      *
65
                 onHide = { this.props.onCancel }
50
                 onHide = { this.props.onCancel }
66
                 position = 'bottom'
51
                 position = 'bottom'
67
                 show = { true }>
52
                 show = { true }>
68
-                <SafeAreaView
69
-                    style = { this._getContainerStyle() }>
70
-                    <View style = { _styles.sheet }>
71
-                        { this.props.children }
53
+                <View
54
+                    pointerEvents = 'box-none'
55
+                    style = { styles.sheetContainer }>
56
+                    <View
57
+                        pointerEvents = 'box-none'
58
+                        style = { styles.sheetAreaCover } />
59
+                    <View
60
+                        style = { [
61
+                            styles.sheetItemContainer,
62
+                            _styles.sheet
63
+                        ] }>
64
+                        { this._getWrappedContent() }
72
                     </View>
65
                     </View>
73
-                </SafeAreaView>
66
+                </View>
74
             </SlidingView>
67
             </SlidingView>
75
         );
68
         );
76
     }
69
     }
70
+
71
+    /**
72
+     * Wraps the content when needed (iOS 11 and above), or just returns the original children.
73
+     *
74
+     * @returns {React$Element}
75
+     */
76
+    _getWrappedContent() {
77
+        if (Platform.OS === 'ios') {
78
+            const majorVersionIOS = parseInt(Platform.Version, 10);
79
+
80
+            if (majorVersionIOS > 10) {
81
+                return (
82
+                    <SafeAreaView>
83
+                        { this.props.children }
84
+                    </SafeAreaView>
85
+                );
86
+            }
87
+        }
88
+
89
+        return this.props.children;
90
+    }
77
 }
91
 }
78
 
92
 
79
 /**
93
 /**

+ 16
- 11
react/features/base/dialog/components/native/styles.js 查看文件

27
  * been implemented as per the Material Design guidelines:
27
  * been implemented as per the Material Design guidelines:
28
  * {@link https://material.io/guidelines/components/bottom-sheets.html}.
28
  * {@link https://material.io/guidelines/components/bottom-sheets.html}.
29
  */
29
  */
30
-export const bottomSheetStyles = createStyleSheet({
30
+export const bottomSheetStyles = {
31
+    sheetAreaCover: {
32
+        backgroundColor: ColorPalette.transparent,
33
+        flex: 1
34
+    },
35
+
31
     /**
36
     /**
32
      * Style for the container of the sheet.
37
      * Style for the container of the sheet.
33
      */
38
      */
34
-    container: {
35
-        bottom: 0,
36
-        left: 0,
37
-        position: 'absolute',
38
-        right: 0
39
+    sheetContainer: {
40
+        alignContent: 'stretch',
41
+        flex: 1,
42
+        flexDirection: 'column'
43
+    },
44
+
45
+    sheetItemContainer: {
46
+        paddingHorizontal: MD_ITEM_MARGIN_PADDING
39
     }
47
     }
40
-});
48
+};
41
 
49
 
42
 export const brandedDialog = createStyleSheet({
50
 export const brandedDialog = createStyleSheet({
43
 
51
 
137
      * Bottom sheet's base style.
145
      * Bottom sheet's base style.
138
      */
146
      */
139
     sheet: {
147
     sheet: {
140
-        backgroundColor: schemeColor('background'),
141
-        flex: 1,
142
-        paddingHorizontal: MD_ITEM_MARGIN_PADDING,
143
-        paddingVertical: 8
148
+        backgroundColor: schemeColor('background')
144
     },
149
     },
145
 
150
 
146
     /**
151
     /**

正在加载...
取消
保存