1import * as React from 'react';
2import { View } from 'react-native';
3import { NativeSafeAreaProviderProps } from './SafeArea.types';
4import useWindowDimensions from './useWindowDimensions';
5
6export function CompatNativeSafeAreaProvider({
7  children,
8  style,
9  onInsetsChange,
10}: NativeSafeAreaProviderProps) {
11  const window = useWindowDimensions();
12  React.useEffect(() => {
13    const insets = {
14      top: 0,
15      bottom: 0,
16      left: 0,
17      right: 0,
18    };
19    const frame = {
20      x: 0,
21      y: 0,
22      width: window.width,
23      height: window.height,
24    };
25    // @ts-ignore: missing properties
26    onInsetsChange({ nativeEvent: { insets, frame } });
27  }, [onInsetsChange, window.height, window.width]);
28  return <View style={style}>{children}</View>;
29}
30