Browse Source

fix: iOS 10 bottom sheet style

master
Bettenbuk Zoltan 6 years ago
parent
commit
d387cbe5bd

+ 35
- 21
react/features/base/dialog/components/native/BottomSheet.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 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 6
 import { ColorSchemeRegistry } from '../../../color-scheme';
7 7
 import { SlidingView } from '../../../react';
@@ -36,21 +36,6 @@ type Props = {
36 36
  * A component emulating Android's BottomSheet.
37 37
  */
38 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 40
      * Implements React's {@link Component#render()}.
56 41
      *
@@ -65,15 +50,44 @@ class BottomSheet extends PureComponent<Props> {
65 50
                 onHide = { this.props.onCancel }
66 51
                 position = 'bottom'
67 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 65
                     </View>
73
-                </SafeAreaView>
66
+                </View>
74 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 View File

@@ -27,17 +27,25 @@ export const PLACEHOLDER_COLOR = ColorPalette.lightGrey;
27 27
  * been implemented as per the Material Design guidelines:
28 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 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 50
 export const brandedDialog = createStyleSheet({
43 51
 
@@ -137,10 +145,7 @@ ColorSchemeRegistry.register('BottomSheet', {
137 145
      * Bottom sheet's base style.
138 146
      */
139 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
     /**

Loading…
Cancel
Save