File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
packages/react-native-web/src/exports/SafeAreaView Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 8
8
* @flow
9
9
*/
10
10
11
+ import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment' ;
11
12
import React from 'react' ;
12
13
import StyleSheet from '../StyleSheet' ;
13
14
import View from '../View' ;
@@ -34,12 +35,24 @@ class SafeAreaView extends React.Component<ViewProps> {
34
35
}
35
36
}
36
37
38
+ const cssFunction : 'constant' | 'env' = ( function ( ) {
39
+ if (
40
+ canUseDOM &&
41
+ window . CSS &&
42
+ window . CSS . supports &&
43
+ window . CSS . supports ( 'top: constant(safe-area-inset-top)' )
44
+ ) {
45
+ return 'constant' ;
46
+ }
47
+ return 'env' ;
48
+ } ) ( ) ;
49
+
37
50
const styles = StyleSheet . create ( {
38
51
root : {
39
- paddingTop : 'env (safe-area-inset-top)' ,
40
- paddingRight : 'env (safe-area-inset-right)' ,
41
- paddingBottom : 'env (safe-area-inset-bottom)' ,
42
- paddingLeft : 'env (safe-area-inset-left)'
52
+ paddingTop : ` ${ cssFunction } (safe-area-inset-top)` ,
53
+ paddingRight : ` ${ cssFunction } (safe-area-inset-right)` ,
54
+ paddingBottom : ` ${ cssFunction } (safe-area-inset-bottom)` ,
55
+ paddingLeft : ` ${ cssFunction } (safe-area-inset-left)`
43
56
}
44
57
} ) ;
45
58
You can’t perform that action at this time.
0 commit comments