mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-23 14:57:13 +00:00
[fix] SafeAreaView types
This commit is contained in:
+15
-14
@@ -9,13 +9,26 @@
|
||||
*/
|
||||
|
||||
import type { ViewProps } from '../View';
|
||||
import type { Node } from 'react';
|
||||
|
||||
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
|
||||
import React from 'react';
|
||||
import StyleSheet from '../StyleSheet';
|
||||
import View from '../View';
|
||||
import React, { forwardRef } from 'react';
|
||||
|
||||
const SafeAreaView = React.forwardRef<View, ViewProps>((props: ViewProps, ref) => {
|
||||
const cssFunction: 'constant' | 'env' = (function() {
|
||||
if (
|
||||
canUseDOM &&
|
||||
window.CSS &&
|
||||
window.CSS.supports &&
|
||||
window.CSS.supports('top: constant(safe-area-inset-top)')
|
||||
) {
|
||||
return 'constant';
|
||||
}
|
||||
return 'env';
|
||||
})();
|
||||
|
||||
const SafeAreaView = forwardRef<ViewProps, Node>((props, ref) => {
|
||||
const { style, ...rest } = props;
|
||||
|
||||
return (
|
||||
@@ -32,18 +45,6 @@ const SafeAreaView = React.forwardRef<View, ViewProps>((props: ViewProps, ref) =
|
||||
|
||||
SafeAreaView.displayName = 'SafeAreaView';
|
||||
|
||||
const cssFunction: 'constant' | 'env' = (function() {
|
||||
if (
|
||||
canUseDOM &&
|
||||
window.CSS &&
|
||||
window.CSS.supports &&
|
||||
window.CSS.supports('top: constant(safe-area-inset-top)')
|
||||
) {
|
||||
return 'constant';
|
||||
}
|
||||
return 'env';
|
||||
})();
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
paddingTop: `${cssFunction}(safe-area-inset-top)`,
|
||||
|
||||
Reference in New Issue
Block a user