@amazon-devices/react-native-safe-area-context 2.0.1758683737 → 8.0.9000000000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -302
- package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.bundle +7373 -0
- package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.map +2780 -0
- package/SystemModules/amzn__react-native-safe-area-context-8.modules.txt +7 -0
- package/SystemModules/amzn__react-native-safe-area-context-8.private.modules.txt +61 -0
- package/SystemModules/keplerscript-system-bundle-config.json +3 -3
- package/android/build.gradle +103 -25
- package/android/gradle.properties +1 -0
- package/android/spotless.gradle +24 -0
- package/android/src/fabric/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +25 -0
- package/android/src/fabric/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +14 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.kt +3 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.kt +3 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt +32 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt +41 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.kt +47 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt +41 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.kt +102 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt +155 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt +16 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt +7 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt +73 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt +6 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt +170 -0
- package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.kt +39 -0
- package/android/src/main/jni/CMakeLists.txt +87 -0
- package/android/src/main/jni/safeareacontext.h +17 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java +31 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java +16 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java +41 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java +20 -0
- package/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +29 -0
- package/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java +56 -0
- package/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +20 -0
- package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewComponentDescriptor.h +25 -0
- package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp +131 -0
- package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.h +36 -0
- package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.cpp +23 -0
- package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.h +56 -0
- package/ios/Fabric/RNCSafeAreaProviderComponentView.h +13 -0
- package/ios/Fabric/RNCSafeAreaProviderComponentView.mm +129 -0
- package/ios/Fabric/RNCSafeAreaViewComponentView.h +11 -0
- package/ios/Fabric/RNCSafeAreaViewComponentView.mm +153 -0
- package/ios/RNCSafeAreaContext.h +9 -0
- package/ios/RNCSafeAreaContext.mm +85 -0
- package/ios/{SafeAreaView/RNCSafeAreaProvider.h → RNCSafeAreaProvider.h} +4 -0
- package/ios/RNCSafeAreaProvider.m +102 -0
- package/ios/RNCSafeAreaProviderManager.m +20 -0
- package/ios/{SafeAreaView/RNCSafeAreaShadowView.m → RNCSafeAreaShadowView.m} +50 -36
- package/ios/RNCSafeAreaUtils.h +22 -0
- package/ios/RNCSafeAreaUtils.m +41 -0
- package/ios/{SafeAreaView/RNCSafeAreaView.h → RNCSafeAreaView.h} +8 -4
- package/ios/RNCSafeAreaView.m +168 -0
- package/ios/RNCSafeAreaViewEdgeMode.h +12 -0
- package/ios/RNCSafeAreaViewEdgeMode.m +16 -0
- package/ios/RNCSafeAreaViewEdges.h +15 -0
- package/ios/RNCSafeAreaViewEdges.m +36 -0
- package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.h → RNCSafeAreaViewLocalData.h} +12 -1
- package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.m → RNCSafeAreaViewLocalData.m} +4 -0
- package/ios/{SafeAreaView/RNCSafeAreaViewManager.m → RNCSafeAreaViewManager.m} +5 -1
- package/ios/RNCSafeAreaViewMode.m +15 -0
- package/ios/{SafeAreaView.xcodeproj → RNSafeAreaContext.xcodeproj}/project.pbxproj +70 -56
- package/jest/mock.tsx +59 -0
- package/kepler-compatibility.json +2 -4
- package/lib/commonjs/CompatNativeSafeAreaProvider.js +7 -8
- package/lib/commonjs/CompatNativeSafeAreaProvider.js.map +1 -1
- package/lib/commonjs/InitialWindow.js.map +1 -1
- package/lib/commonjs/InitialWindow.kepler.js +1 -1
- package/lib/commonjs/InitialWindow.kepler.js.map +1 -1
- package/lib/commonjs/InitialWindow.native.js +4 -4
- package/lib/commonjs/InitialWindow.native.js.map +1 -1
- package/lib/commonjs/NativeSafeAreaProvider.js +7 -125
- package/lib/commonjs/NativeSafeAreaProvider.js.map +1 -1
- package/lib/commonjs/NativeSafeAreaProvider.kepler.js +6 -2
- package/lib/commonjs/NativeSafeAreaProvider.kepler.js.map +1 -1
- package/lib/commonjs/NativeSafeAreaProvider.web.js +135 -0
- package/lib/commonjs/NativeSafeAreaProvider.web.js.map +1 -0
- package/lib/commonjs/NativeSafeAreaProvider.windows.js +6 -2
- package/lib/commonjs/NativeSafeAreaProvider.windows.js.map +1 -1
- package/lib/commonjs/SafeArea.types.js.map +1 -1
- package/lib/commonjs/SafeAreaContext.js +56 -36
- package/lib/commonjs/SafeAreaContext.js.map +1 -1
- package/lib/commonjs/SafeAreaView.js +40 -73
- package/lib/commonjs/SafeAreaView.js.map +1 -1
- package/lib/commonjs/SafeAreaView.kepler.js.map +1 -1
- package/lib/commonjs/SafeAreaView.web.js +91 -0
- package/lib/commonjs/SafeAreaView.web.js.map +1 -0
- package/lib/commonjs/SafeAreaView.windows.js.map +1 -1
- package/lib/commonjs/index.js +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NativeSafeAreaContext.js +9 -0
- package/lib/commonjs/specs/NativeSafeAreaContext.js.map +1 -0
- package/lib/commonjs/specs/NativeSafeAreaProvider.js +10 -0
- package/lib/commonjs/specs/NativeSafeAreaProvider.js.map +1 -0
- package/lib/commonjs/specs/NativeSafeAreaView.js +12 -0
- package/lib/commonjs/specs/NativeSafeAreaView.js.map +1 -0
- package/lib/module/CompatNativeSafeAreaProvider.js +8 -5
- package/lib/module/CompatNativeSafeAreaProvider.js.map +1 -1
- package/lib/module/InitialWindow.js +2 -0
- package/lib/module/InitialWindow.js.map +1 -1
- package/lib/module/InitialWindow.kepler.js +3 -1
- package/lib/module/InitialWindow.kepler.js.map +1 -1
- package/lib/module/InitialWindow.native.js +5 -4
- package/lib/module/InitialWindow.native.js.map +1 -1
- package/lib/module/NativeSafeAreaProvider.js +3 -122
- package/lib/module/NativeSafeAreaProvider.js.map +1 -1
- package/lib/module/NativeSafeAreaProvider.kepler.js +3 -2
- package/lib/module/NativeSafeAreaProvider.kepler.js.map +1 -1
- package/lib/module/NativeSafeAreaProvider.web.js +130 -0
- package/lib/module/NativeSafeAreaProvider.web.js.map +1 -0
- package/lib/module/NativeSafeAreaProvider.windows.js +3 -2
- package/lib/module/NativeSafeAreaProvider.windows.js.map +1 -1
- package/lib/module/SafeArea.types.js +2 -0
- package/lib/module/SafeArea.types.js.map +1 -1
- package/lib/module/SafeAreaContext.js +57 -33
- package/lib/module/SafeAreaContext.js.map +1 -1
- package/lib/module/SafeAreaView.js +38 -69
- package/lib/module/SafeAreaView.js.map +1 -1
- package/lib/module/SafeAreaView.kepler.js +2 -0
- package/lib/module/SafeAreaView.kepler.js.map +1 -1
- package/lib/module/SafeAreaView.web.js +86 -0
- package/lib/module/SafeAreaView.web.js.map +1 -0
- package/lib/module/SafeAreaView.windows.js +2 -0
- package/lib/module/SafeAreaView.windows.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeSafeAreaContext.js +5 -0
- package/lib/module/specs/NativeSafeAreaContext.js.map +1 -0
- package/lib/module/specs/NativeSafeAreaProvider.js +5 -0
- package/lib/module/specs/NativeSafeAreaProvider.js.map +1 -0
- package/lib/module/specs/NativeSafeAreaView.js +7 -0
- package/lib/module/specs/NativeSafeAreaView.js.map +1 -0
- package/lib/typescript/CompatNativeSafeAreaProvider.d.ts +4 -0
- package/lib/typescript/CompatNativeSafeAreaProvider.d.ts.map +1 -0
- package/lib/typescript/{src/InitialWindow.d.ts → InitialWindow.d.ts} +2 -1
- package/lib/typescript/InitialWindow.d.ts.map +1 -0
- package/lib/typescript/{src/InitialWindow.kepler.d.ts → InitialWindow.kepler.d.ts} +1 -0
- package/lib/typescript/InitialWindow.kepler.d.ts.map +1 -0
- package/lib/typescript/{src/InitialWindow.native.d.ts → InitialWindow.native.d.ts} +2 -1
- package/lib/typescript/InitialWindow.native.d.ts.map +1 -0
- package/lib/typescript/NativeSafeAreaProvider.d.ts +3 -0
- package/lib/typescript/NativeSafeAreaProvider.d.ts.map +1 -0
- package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts +2 -0
- package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts.map +1 -0
- package/lib/typescript/NativeSafeAreaProvider.web.d.ts +4 -0
- package/lib/typescript/NativeSafeAreaProvider.web.d.ts.map +1 -0
- package/lib/typescript/NativeSafeAreaProvider.windows.d.ts +2 -0
- package/lib/typescript/NativeSafeAreaProvider.windows.d.ts.map +1 -0
- package/lib/typescript/SafeArea.types.d.ts +36 -0
- package/lib/typescript/SafeArea.types.d.ts.map +1 -0
- package/lib/typescript/{src/SafeAreaContext.d.ts → SafeAreaContext.d.ts} +9 -6
- package/lib/typescript/SafeAreaContext.d.ts.map +1 -0
- package/lib/typescript/SafeAreaView.d.ts +5 -0
- package/lib/typescript/SafeAreaView.d.ts.map +1 -0
- package/lib/typescript/{src/SafeAreaView.kepler.d.ts → SafeAreaView.kepler.d.ts} +1 -0
- package/lib/typescript/SafeAreaView.kepler.d.ts.map +1 -0
- package/lib/typescript/SafeAreaView.web.d.ts +4 -0
- package/lib/typescript/SafeAreaView.web.d.ts.map +1 -0
- package/lib/typescript/SafeAreaView.windows.d.ts +3 -0
- package/lib/typescript/SafeAreaView.windows.d.ts.map +1 -0
- package/lib/typescript/{src/index.d.ts → index.d.ts} +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaContext.d.ts +23 -0
- package/lib/typescript/specs/NativeSafeAreaContext.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaProvider.d.ts +22 -0
- package/lib/typescript/specs/NativeSafeAreaProvider.d.ts.map +1 -0
- package/lib/typescript/specs/NativeSafeAreaView.d.ts +14 -0
- package/lib/typescript/specs/NativeSafeAreaView.d.ts.map +1 -0
- package/package.json +1 -1
- package/react-native-safe-area-context.podspec +26 -4
- package/react-native.config.js +8 -0
- package/src/CompatNativeSafeAreaProvider.tsx +2 -3
- package/src/InitialWindow.kepler.ts +1 -1
- package/src/InitialWindow.native.ts +5 -11
- package/src/InitialWindow.ts +1 -1
- package/src/NativeSafeAreaProvider.kepler.tsx +1 -3
- package/src/NativeSafeAreaProvider.tsx +2 -128
- package/src/NativeSafeAreaProvider.web.tsx +127 -0
- package/src/NativeSafeAreaProvider.windows.tsx +1 -3
- package/src/SafeArea.types.ts +15 -11
- package/src/SafeAreaContext.tsx +66 -43
- package/src/SafeAreaView.tsx +47 -82
- package/src/SafeAreaView.web.tsx +123 -0
- package/src/SafeAreaView.windows.tsx +2 -1
- package/src/index.tsx +2 -0
- package/src/specs/NativeSafeAreaContext.ts +23 -0
- package/src/specs/NativeSafeAreaProvider.ts +29 -0
- package/src/specs/NativeSafeAreaView.ts +17 -0
- package/SystemBundles/e3c0cdeab56b8b622d4f0fd5a80812eafe199fa2287d0e3a09c5e573a1035350.bundle +0 -11031
- package/SystemBundles/e3c0cdeab56b8b622d4f0fd5a80812eafe199fa2287d0e3a09c5e573a1035350.map +0 -1
- package/SystemModules/amzn__react-native-safe-area-context-2.modules.txt +0 -55
- package/SystemModules/amzn__react-native-safe-area-context-2.private.modules.txt +0 -91
- package/THIRD_PARTY_NOTICES.txt +0 -24
- package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.java +0 -22
- package/android/src/main/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.java +0 -33
- package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.java +0 -22
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.java +0 -31
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.java +0 -66
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.java +0 -94
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.java +0 -82
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.java +0 -159
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.java +0 -8
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.java +0 -27
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.java +0 -72
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.java +0 -6
- package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.java +0 -201
- package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.java +0 -52
- package/ios/SafeAreaView/RCTView+SafeAreaCompat.h +0 -16
- package/ios/SafeAreaView/RCTView+SafeAreaCompat.m +0 -57
- package/ios/SafeAreaView/RNCSafeAreaProvider.m +0 -65
- package/ios/SafeAreaView/RNCSafeAreaProviderManager.m +0 -61
- package/ios/SafeAreaView/RNCSafeAreaView.m +0 -118
- package/ios/SafeAreaView/RNCSafeAreaViewEdges.h +0 -9
- package/ios/SafeAreaView/RNCSafeAreaViewEdges.m +0 -13
- package/ios/SafeAreaView/RNCSafeAreaViewMode.m +0 -11
- package/lib/commonjs/NativeSafeAreaProvider.macos.js +0 -9
- package/lib/commonjs/NativeSafeAreaProvider.macos.js.map +0 -1
- package/lib/commonjs/NativeSafeAreaProvider.native.js +0 -9
- package/lib/commonjs/NativeSafeAreaProvider.native.js.map +0 -1
- package/lib/commonjs/SafeAreaView.macos.js +0 -9
- package/lib/commonjs/SafeAreaView.macos.js.map +0 -1
- package/lib/commonjs/SafeAreaView.native.js +0 -9
- package/lib/commonjs/SafeAreaView.native.js.map +0 -1
- package/lib/commonjs/useWindowDimensions.js +0 -32
- package/lib/commonjs/useWindowDimensions.js.map +0 -1
- package/lib/module/NativeSafeAreaProvider.macos.js +0 -3
- package/lib/module/NativeSafeAreaProvider.macos.js.map +0 -1
- package/lib/module/NativeSafeAreaProvider.native.js +0 -3
- package/lib/module/NativeSafeAreaProvider.native.js.map +0 -1
- package/lib/module/SafeAreaView.macos.js +0 -3
- package/lib/module/SafeAreaView.macos.js.map +0 -1
- package/lib/module/SafeAreaView.native.js +0 -3
- package/lib/module/SafeAreaView.native.js.map +0 -1
- package/lib/module/useWindowDimensions.js +0 -26
- package/lib/module/useWindowDimensions.js.map +0 -1
- package/lib/typescript/src/CompatNativeSafeAreaProvider.d.ts +0 -2
- package/lib/typescript/src/NativeSafeAreaProvider.d.ts +0 -2
- package/lib/typescript/src/NativeSafeAreaProvider.kepler.d.ts +0 -2
- package/lib/typescript/src/NativeSafeAreaProvider.macos.d.ts +0 -2
- package/lib/typescript/src/NativeSafeAreaProvider.native.d.ts +0 -3
- package/lib/typescript/src/NativeSafeAreaProvider.windows.d.ts +0 -2
- package/lib/typescript/src/SafeArea.types.d.ts +0 -31
- package/lib/typescript/src/SafeAreaView.d.ts +0 -2
- package/lib/typescript/src/SafeAreaView.macos.d.ts +0 -2
- package/lib/typescript/src/SafeAreaView.native.d.ts +0 -2
- package/lib/typescript/src/SafeAreaView.windows.d.ts +0 -2
- package/lib/typescript/src/useWindowDimensions.d.ts +0 -8
- package/src/NativeSafeAreaProvider.macos.tsx +0 -3
- package/src/NativeSafeAreaProvider.native.tsx +0 -6
- package/src/SafeAreaView.macos.tsx +0 -3
- package/src/SafeAreaView.native.tsx +0 -6
- package/src/useWindowDimensions.tsx +0 -35
- /package/ios/{SafeAreaView/RNCSafeAreaProviderManager.h → RNCSafeAreaProviderManager.h} +0 -0
- /package/ios/{SafeAreaView/RNCSafeAreaShadowView.h → RNCSafeAreaShadowView.h} +0 -0
- /package/ios/{SafeAreaView/RNCSafeAreaViewManager.h → RNCSafeAreaViewManager.h} +0 -0
- /package/ios/{SafeAreaView/RNCSafeAreaViewMode.h → RNCSafeAreaViewMode.h} +0 -0
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { EdgeInsets, Metrics, Rect } from './SafeArea.types';
|
|
2
|
+
import { type ViewProps } from 'react-native';
|
|
3
|
+
import type { EdgeInsets, Metrics, Rect } from './SafeArea.types';
|
|
4
4
|
export declare const SafeAreaInsetsContext: React.Context<EdgeInsets | null>;
|
|
5
5
|
export declare const SafeAreaFrameContext: React.Context<Rect | null>;
|
|
6
|
-
export interface
|
|
6
|
+
export interface SafeAreaProviderProps extends ViewProps {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
initialMetrics?: Metrics | null;
|
|
9
9
|
/**
|
|
10
10
|
* @deprecated
|
|
11
11
|
*/
|
|
12
12
|
initialSafeAreaInsets?: EdgeInsets | null;
|
|
13
|
-
style?: StyleProp<ViewStyle>;
|
|
14
13
|
}
|
|
15
|
-
export declare function SafeAreaProvider({ children, initialMetrics, initialSafeAreaInsets, style, }:
|
|
14
|
+
export declare function SafeAreaProvider({ children, initialMetrics, initialSafeAreaInsets, style, ...others }: SafeAreaProviderProps): React.JSX.Element;
|
|
16
15
|
export declare function useSafeAreaInsets(): EdgeInsets;
|
|
17
16
|
export declare function useSafeAreaFrame(): Rect;
|
|
18
|
-
export
|
|
17
|
+
export type WithSafeAreaInsetsProps = {
|
|
18
|
+
insets: EdgeInsets;
|
|
19
|
+
};
|
|
20
|
+
export declare function withSafeAreaInsets<T>(WrappedComponent: React.ComponentType<(React.PropsWithoutRef<T> | T) & WithSafeAreaInsetsProps>): React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<unknown>>;
|
|
19
21
|
/**
|
|
20
22
|
* @deprecated
|
|
21
23
|
*/
|
|
@@ -28,3 +30,4 @@ export declare const SafeAreaConsumer: React.Consumer<EdgeInsets | null>;
|
|
|
28
30
|
* @deprecated
|
|
29
31
|
*/
|
|
30
32
|
export declare const SafeAreaContext: React.Context<EdgeInsets | null>;
|
|
33
|
+
//# sourceMappingURL=SafeAreaContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAreaContext.d.ts","sourceRoot":"","sources":["../../src/SafeAreaContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EACV,UAAU,EAEV,OAAO,EACP,IAAI,EACL,MAAM,kBAAkB,CAAC;AAI1B,eAAO,MAAM,qBAAqB,kCAEjC,CAAC;AAKF,eAAO,MAAM,oBAAoB,4BAAyC,CAAC;AAK3E,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,KAAK,EACL,GAAG,MAAM,EACV,EAAE,qBAAqB,qBAkEvB;AAiBD,wBAAgB,iBAAiB,IAAI,UAAU,CAM9C;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CACnC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,uBAAuB,CACzD,GACA,KAAK,CAAC,yBAAyB,CAChC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CACxD,CAKA;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAExC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,mCAAiC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,eAAe,kCAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NativeSafeAreaViewProps } from './SafeArea.types';
|
|
3
|
+
export type SafeAreaViewProps = NativeSafeAreaViewProps;
|
|
4
|
+
export declare const SafeAreaView: React.ForwardRefExoticComponent<NativeSafeAreaViewProps & React.RefAttributes<React.Component<import("./specs/NativeSafeAreaView").NativeProps, {}, any> & import("react-native").NativeMethods>>;
|
|
5
|
+
//# sourceMappingURL=SafeAreaView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAreaView.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAKV,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAW1B,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAExD,eAAO,MAAM,YAAY,mMA6BvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAreaView.kepler.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.kepler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,YAAY,aAAO,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { NativeSafeAreaViewProps } from './SafeArea.types';
|
|
3
|
+
export declare const SafeAreaView: React.ForwardRefExoticComponent<NativeSafeAreaViewProps & React.RefAttributes<React.Component<import("./specs/NativeSafeAreaView").NativeProps, {}, any> & import("react-native").NativeMethods>>;
|
|
4
|
+
//# sourceMappingURL=SafeAreaView.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAreaView.web.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AA0B1B,eAAO,MAAM,YAAY,mMAwFvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAreaView.windows.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.windows.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEnE,eAAO,MAAM,YAAY,EAAsB,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAEA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TurboModule } from 'react-native';
|
|
2
|
+
import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface Spec extends TurboModule {
|
|
4
|
+
getConstants: () => {
|
|
5
|
+
initialWindowMetrics?: {
|
|
6
|
+
insets: {
|
|
7
|
+
top: Double;
|
|
8
|
+
right: Double;
|
|
9
|
+
bottom: Double;
|
|
10
|
+
left: Double;
|
|
11
|
+
};
|
|
12
|
+
frame: {
|
|
13
|
+
x: Double;
|
|
14
|
+
y: Double;
|
|
15
|
+
width: Double;
|
|
16
|
+
height: Double;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
declare const _default: Spec | null;
|
|
22
|
+
export default _default;
|
|
23
|
+
//# sourceMappingURL=NativeSafeAreaContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeSafeAreaContext.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAExE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,YAAY,EAAE,MAAM;QAClB,oBAAoB,CAAC,EAAE;YACrB,MAAM,EAAE;gBACN,GAAG,EAAE,MAAM,CAAC;gBACZ,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,IAAI,EAAE,MAAM,CAAC;aACd,CAAC;YACF,KAAK,EAAE;gBACL,CAAC,EAAE,MAAM,CAAC;gBACV,CAAC,EAAE,MAAM,CAAC;gBACV,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;CACH;;AAED,wBAAmE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
export type Event = Readonly<{
|
|
4
|
+
insets: Readonly<{
|
|
5
|
+
top: Double;
|
|
6
|
+
right: Double;
|
|
7
|
+
bottom: Double;
|
|
8
|
+
left: Double;
|
|
9
|
+
}>;
|
|
10
|
+
frame: Readonly<{
|
|
11
|
+
x: Double;
|
|
12
|
+
y: Double;
|
|
13
|
+
width: Double;
|
|
14
|
+
height: Double;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
export interface NativeProps extends ViewProps {
|
|
18
|
+
onInsetsChange?: DirectEventHandler<Event>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: HostComponent<NativeProps>;
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=NativeSafeAreaProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeSafeAreaProvider.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,KAAK,EAAE,QAAQ,CAAC;QACd,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,cAAc,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;CAC5C;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
mode?: WithDefault<'padding' | 'margin', 'padding'>;
|
|
5
|
+
edges?: Readonly<{
|
|
6
|
+
top: string;
|
|
7
|
+
right: string;
|
|
8
|
+
bottom: string;
|
|
9
|
+
left: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: HostComponent<NativeProps>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=NativeSafeAreaView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeSafeAreaView.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaView.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC,SAAS,GAAG,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,QAAQ,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;wBAIK,aAAa,CAAC,WAAW,CAAC;AAFhC,wBAEiC"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@amazon-devices/react-native-safe-area-context", "version": "
|
|
1
|
+
{"name": "@amazon-devices/react-native-safe-area-context", "version": "8.0.9000000000+5.2.0", "description": "A flexible way to handle safe area, also works on Android and web.", "main": "lib/commonjs/index.js", "module": "lib/module/index.js", "react-native": "src/index.tsx", "types": "lib/typescript/index.d.ts", "source": "src/index.tsx", "sideEffects": false, "files": ["src", "lib", "android", "ios", "common", "jest", "*.podspec", "react-native.config.js", "!**/__tests__", "!example", "kepler-compatibility.json", "SystemModules", "SystemBundles", "kepler-transformed-package-info.json"], "author": "Janic Duplessis <janicduplessis@gmail.com>", "contributors": ["Evan Bacon <bacon@expo.io> (https://github.com/evanbacon)"], "homepage": "https://github.com/th3rdwave/react-native-safe-area-context#readme", "license": "See license in LICENSE", "scripts": {"start": "react-native start", "test": "yarn format:check && yarn validate:eslint && yarn validate:typescript && yarn validate:jest", "validate:eslint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"", "validate:typescript": "tsc --project ./ --noEmit", "validate:jest": "jest", "format:prettier:check": "prettier \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\" --check", "format:prettier:write": "yarn format:prettier:check --write", "format:clang:check": "clang-format --dry-run --Werror --glob='{ios,android/src,common}/**/*.{h,cpp,m,mm}'", "format:clang:write": "clang-format -i --glob='{ios,android/src,common}/**/*.{h,hpp,cpp,m,mm}'", "format:spotless:check": "cd android && ./gradlew spotlessCheck", "format:spotless:write": "cd android && ./gradlew spotlessApply", "format:check": "yarn format:prettier:check && yarn format:clang:check && yarn format:spotless:check", "format:write": "yarn format:prettier:write && yarn format:clang:write && yarn format:spotless:write"}, "keywords": ["react-native", "react native", "react-native-web", "expo-web", "safe area", "view"], "kepler": {"temporary-alias-for-package": {"name": "react-native-safe-area-context", "version": "5.2.0"}}, "peerDependencies": {"react": "*", "react-native": "*"}, "devDependencies": {"@commitlint/config-conventional": "^19.2.2", "@jest/globals": "^30.0.0", "@react-native/babel-preset": "^0.74.84", "@react-native/eslint-config": "^0.74.84", "@react-native/eslint-plugin-specs": "^0.74.84", "@release-it/conventional-changelog": "^8.0.1", "@types/react": "~19.0.10", "@types/react-dom": "~19.1.3", "@types/react-test-renderer": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.14.1", "@typescript-eslint/parser": "^7.14.1", "babel-plugin-module-resolver": "^5.0.2", "clang-format": "^1.8.0", "commitlint": "19.6.1", "eslint": "^8.57.0", "eslint-plugin-jest": "^28.6.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.11", "jest": "^29.7.0", "prettier": "^3.3.2", "react": "19.0.0", "react-dom": "19.0.0", "react-native": "0.79.3", "react-native-builder-bob": "^0.40.12", "react-test-renderer": "19.0.0", "release-it": "^17.4.0", "typescript": "^5.8.3"}, "repository": {"type": "git", "url": "https://github.com/th3rdwave/react-native-safe-area-context.git"}, "jest": {"preset": "react-native", "testEnvironment": "node", "clearMocks": true, "modulePathIgnorePatterns": ["<rootDir>/lib/"]}, "commitlint": {"extends": ["@commitlint/config-conventional"]}, "react-native-builder-bob": {"source": "src", "output": "lib", "targets": ["commonjs", "module", "typescript"]}, "codegenConfig": {"android": {"javaPackageName": "com.th3rdwave.safeareacontext"}, "ios": {"componentProvider": {"RNCSafeAreaProvider": "RNCSafeAreaProviderComponentView", "RNCSafeAreaView": "RNCSafeAreaViewComponentView"}}, "name": "safeareacontext", "type": "all", "jsSrcsDir": "./src/specs"}}
|
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
|
|
3
|
+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
4
|
+
|
|
3
5
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
6
|
|
|
5
7
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "
|
|
8
|
+
s.name = "react-native-safe-area-context"
|
|
7
9
|
s.version = package['version']
|
|
8
10
|
s.summary = package['description']
|
|
9
11
|
s.license = package['license']
|
|
10
12
|
|
|
11
13
|
s.authors = package['author']
|
|
12
14
|
s.homepage = package['homepage']
|
|
13
|
-
s.
|
|
15
|
+
s.ios.deployment_target = "12.4"
|
|
16
|
+
s.osx.deployment_target = "10.15"
|
|
17
|
+
s.tvos.deployment_target = "12.4"
|
|
18
|
+
s.visionos.deployment_target = "1.0"
|
|
14
19
|
|
|
15
20
|
s.source = { :git => "https://github.com/th3rdwave/react-native-safe-area-context.git", :tag => "v#{s.version}" }
|
|
16
|
-
s.source_files = "ios/**/*.{h,m}"
|
|
21
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
22
|
+
s.exclude_files = "ios/Fabric"
|
|
23
|
+
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
|
|
26
|
+
if fabric_enabled
|
|
27
|
+
install_modules_dependencies(s)
|
|
28
|
+
|
|
29
|
+
s.subspec "common" do |ss|
|
|
30
|
+
ss.source_files = "common/cpp/**/*.{cpp,h}"
|
|
31
|
+
ss.header_dir = "react/renderer/components/safeareacontext"
|
|
32
|
+
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
|
|
33
|
+
end
|
|
17
34
|
|
|
18
|
-
|
|
35
|
+
s.subspec "fabric" do |ss|
|
|
36
|
+
ss.dependency "react-native-safe-area-context/common"
|
|
37
|
+
ss.source_files = "ios/Fabric/**/*.{h,m,mm}"
|
|
38
|
+
ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
19
41
|
end
|
package/react-native.config.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
dependency: {
|
|
3
3
|
platforms: {
|
|
4
|
+
android: {
|
|
5
|
+
libraryName: 'safeareacontext',
|
|
6
|
+
componentDescriptors: [
|
|
7
|
+
'RNCSafeAreaProviderComponentDescriptor',
|
|
8
|
+
'RNCSafeAreaViewComponentDescriptor',
|
|
9
|
+
],
|
|
10
|
+
cmakeListsPath: 'src/main/jni/CMakeLists.txt',
|
|
11
|
+
},
|
|
4
12
|
macos: null,
|
|
5
13
|
windows: null,
|
|
6
14
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { NativeSafeAreaProviderProps } from './SafeArea.types';
|
|
4
|
-
import useWindowDimensions from './useWindowDimensions';
|
|
2
|
+
import { useWindowDimensions, View } from 'react-native';
|
|
3
|
+
import type { NativeSafeAreaProviderProps } from './SafeArea.types';
|
|
5
4
|
|
|
6
5
|
export function CompatNativeSafeAreaProvider({
|
|
7
6
|
children,
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Metrics } from './SafeArea.types';
|
|
2
|
+
import NativeSafeAreaContext from './specs/NativeSafeAreaContext';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
) as any;
|
|
7
|
-
|
|
8
|
-
export const initialWindowMetrics = (RNCSafeAreaProviderConfig != null &&
|
|
9
|
-
RNCSafeAreaProviderConfig.Constants != null
|
|
10
|
-
? RNCSafeAreaProviderConfig.Constants.initialWindowMetrics
|
|
11
|
-
: null) as Metrics | null;
|
|
4
|
+
export const initialWindowMetrics = (NativeSafeAreaContext?.getConstants?.()
|
|
5
|
+
?.initialWindowMetrics ?? null) as Metrics | null;
|
|
12
6
|
|
|
13
7
|
/**
|
|
14
8
|
* @deprecated
|
|
15
9
|
*/
|
|
16
|
-
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
|
10
|
+
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
package/src/InitialWindow.ts
CHANGED
|
@@ -1,129 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { NativeSafeAreaProviderProps } from './SafeArea.types';
|
|
1
|
+
import NativeSafeAreaProvider from './specs/NativeSafeAreaProvider';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
* TODO:
|
|
7
|
-
* Currently insets and frame are based on the window and are not
|
|
8
|
-
* relative to the provider view. This is inconsistent with iOS and Android.
|
|
9
|
-
* However in most cases if the provider view covers the screen this is not
|
|
10
|
-
* an issue.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const CSSTransitions: Record<string, string> = {
|
|
14
|
-
WebkitTransition: 'webkitTransitionEnd',
|
|
15
|
-
Transition: 'transitionEnd',
|
|
16
|
-
MozTransition: 'transitionend',
|
|
17
|
-
MSTransition: 'msTransitionEnd',
|
|
18
|
-
OTransition: 'oTransitionEnd',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default function NativeSafeAreaView({
|
|
22
|
-
children,
|
|
23
|
-
style,
|
|
24
|
-
onInsetsChange,
|
|
25
|
-
}: NativeSafeAreaProviderProps) {
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
// Skip for SSR.
|
|
28
|
-
if (typeof document === 'undefined') {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const element = createContextElement();
|
|
33
|
-
document.body.appendChild(element);
|
|
34
|
-
const onEnd = () => {
|
|
35
|
-
const {
|
|
36
|
-
paddingTop,
|
|
37
|
-
paddingBottom,
|
|
38
|
-
paddingLeft,
|
|
39
|
-
paddingRight,
|
|
40
|
-
} = window.getComputedStyle(element);
|
|
41
|
-
|
|
42
|
-
const insets = {
|
|
43
|
-
top: paddingTop ? parseInt(paddingTop, 10) : 0,
|
|
44
|
-
bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
|
|
45
|
-
left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
|
|
46
|
-
right: paddingRight ? parseInt(paddingRight, 10) : 0,
|
|
47
|
-
};
|
|
48
|
-
const frame = {
|
|
49
|
-
x: 0,
|
|
50
|
-
y: 0,
|
|
51
|
-
width: document.documentElement.offsetWidth,
|
|
52
|
-
height: document.documentElement.offsetHeight,
|
|
53
|
-
};
|
|
54
|
-
// @ts-ignore: missing properties
|
|
55
|
-
onInsetsChange({ nativeEvent: { insets, frame } });
|
|
56
|
-
};
|
|
57
|
-
element.addEventListener(getSupportedTransitionEvent(), onEnd);
|
|
58
|
-
onEnd();
|
|
59
|
-
return () => {
|
|
60
|
-
document.body.removeChild(element);
|
|
61
|
-
element.removeEventListener(getSupportedTransitionEvent(), onEnd);
|
|
62
|
-
};
|
|
63
|
-
}, [onInsetsChange]);
|
|
64
|
-
|
|
65
|
-
return <View style={style}>{children}</View>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let _supportedTransitionEvent: string | null = null;
|
|
69
|
-
function getSupportedTransitionEvent(): string {
|
|
70
|
-
if (_supportedTransitionEvent !== null) {
|
|
71
|
-
return _supportedTransitionEvent;
|
|
72
|
-
}
|
|
73
|
-
const element = document.createElement('invalidtype');
|
|
74
|
-
|
|
75
|
-
_supportedTransitionEvent = CSSTransitions.Transition;
|
|
76
|
-
for (const key in CSSTransitions) {
|
|
77
|
-
if (element.style[key as keyof CSSStyleDeclaration] !== undefined) {
|
|
78
|
-
_supportedTransitionEvent = CSSTransitions[key];
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return _supportedTransitionEvent;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
type CssEnv = 'constant' | 'env';
|
|
86
|
-
|
|
87
|
-
let _supportedEnv: CssEnv | null = null;
|
|
88
|
-
function getSupportedEnv(): CssEnv {
|
|
89
|
-
if (_supportedEnv !== null) {
|
|
90
|
-
return _supportedEnv;
|
|
91
|
-
}
|
|
92
|
-
const { CSS } = window;
|
|
93
|
-
if (
|
|
94
|
-
CSS &&
|
|
95
|
-
CSS.supports &&
|
|
96
|
-
CSS.supports('top: constant(safe-area-inset-top)')
|
|
97
|
-
) {
|
|
98
|
-
_supportedEnv = 'constant';
|
|
99
|
-
} else {
|
|
100
|
-
_supportedEnv = 'env';
|
|
101
|
-
}
|
|
102
|
-
return _supportedEnv;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getInset(side: string): string {
|
|
106
|
-
return `${getSupportedEnv()}(safe-area-inset-${side})`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function createContextElement(): HTMLElement {
|
|
110
|
-
const element = document.createElement('div');
|
|
111
|
-
const { style } = element;
|
|
112
|
-
style.position = 'fixed';
|
|
113
|
-
style.left = '0';
|
|
114
|
-
style.top = '0';
|
|
115
|
-
style.width = '0';
|
|
116
|
-
style.height = '0';
|
|
117
|
-
style.zIndex = '-1';
|
|
118
|
-
style.overflow = 'hidden';
|
|
119
|
-
style.visibility = 'hidden';
|
|
120
|
-
// Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
|
|
121
|
-
style.transitionDuration = '0.05s';
|
|
122
|
-
style.transitionProperty = 'padding';
|
|
123
|
-
style.transitionDelay = '0s';
|
|
124
|
-
style.paddingTop = getInset('top');
|
|
125
|
-
style.paddingBottom = getInset('bottom');
|
|
126
|
-
style.paddingLeft = getInset('left');
|
|
127
|
-
style.paddingRight = getInset('right');
|
|
128
|
-
return element;
|
|
129
|
-
}
|
|
3
|
+
export { NativeSafeAreaProvider };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import type { NativeSafeAreaProviderProps } from './SafeArea.types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TODO:
|
|
9
|
+
* Currently insets and frame are based on the window and are not
|
|
10
|
+
* relative to the provider view. This is inconsistent with iOS and Android.
|
|
11
|
+
* However in most cases if the provider view covers the screen this is not
|
|
12
|
+
* an issue.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const CSSTransitions: Record<string, string> = {
|
|
16
|
+
WebkitTransition: 'webkitTransitionEnd',
|
|
17
|
+
Transition: 'transitionEnd',
|
|
18
|
+
MozTransition: 'transitionend',
|
|
19
|
+
MSTransition: 'msTransitionEnd',
|
|
20
|
+
OTransition: 'oTransitionEnd',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function NativeSafeAreaProvider({
|
|
24
|
+
children,
|
|
25
|
+
style,
|
|
26
|
+
onInsetsChange,
|
|
27
|
+
}: NativeSafeAreaProviderProps) {
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
// Skip for SSR.
|
|
30
|
+
if (typeof document === 'undefined') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const element = createContextElement();
|
|
35
|
+
document.body.appendChild(element);
|
|
36
|
+
const onEnd = () => {
|
|
37
|
+
const { paddingTop, paddingBottom, paddingLeft, paddingRight } =
|
|
38
|
+
window.getComputedStyle(element);
|
|
39
|
+
|
|
40
|
+
const insets = {
|
|
41
|
+
top: paddingTop ? parseInt(paddingTop, 10) : 0,
|
|
42
|
+
bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
|
|
43
|
+
left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
|
|
44
|
+
right: paddingRight ? parseInt(paddingRight, 10) : 0,
|
|
45
|
+
};
|
|
46
|
+
const frame = {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
width: document.documentElement.offsetWidth,
|
|
50
|
+
height: document.documentElement.offsetHeight,
|
|
51
|
+
};
|
|
52
|
+
// @ts-ignore: missing properties
|
|
53
|
+
onInsetsChange({ nativeEvent: { insets, frame } });
|
|
54
|
+
};
|
|
55
|
+
element.addEventListener(getSupportedTransitionEvent(), onEnd);
|
|
56
|
+
onEnd();
|
|
57
|
+
return () => {
|
|
58
|
+
document.body.removeChild(element);
|
|
59
|
+
element.removeEventListener(getSupportedTransitionEvent(), onEnd);
|
|
60
|
+
};
|
|
61
|
+
}, [onInsetsChange]);
|
|
62
|
+
|
|
63
|
+
return <View style={style}>{children}</View>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let _supportedTransitionEvent: string | null | undefined = null;
|
|
67
|
+
function getSupportedTransitionEvent(): string {
|
|
68
|
+
if (_supportedTransitionEvent != null) {
|
|
69
|
+
return _supportedTransitionEvent;
|
|
70
|
+
}
|
|
71
|
+
const element = document.createElement('invalidtype');
|
|
72
|
+
|
|
73
|
+
_supportedTransitionEvent = CSSTransitions.Transition;
|
|
74
|
+
for (const key in CSSTransitions) {
|
|
75
|
+
if (element.style[key as keyof CSSStyleDeclaration] !== undefined) {
|
|
76
|
+
_supportedTransitionEvent = CSSTransitions[key];
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return _supportedTransitionEvent as string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type CssEnv = 'constant' | 'env';
|
|
84
|
+
|
|
85
|
+
let _supportedEnv: CssEnv | null = null;
|
|
86
|
+
function getSupportedEnv(): CssEnv {
|
|
87
|
+
if (_supportedEnv !== null) {
|
|
88
|
+
return _supportedEnv;
|
|
89
|
+
}
|
|
90
|
+
const { CSS } = window;
|
|
91
|
+
if (
|
|
92
|
+
CSS &&
|
|
93
|
+
CSS.supports &&
|
|
94
|
+
CSS.supports('top: constant(safe-area-inset-top)')
|
|
95
|
+
) {
|
|
96
|
+
_supportedEnv = 'constant';
|
|
97
|
+
} else {
|
|
98
|
+
_supportedEnv = 'env';
|
|
99
|
+
}
|
|
100
|
+
return _supportedEnv;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getInset(side: string): string {
|
|
104
|
+
return `${getSupportedEnv()}(safe-area-inset-${side})`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function createContextElement(): HTMLElement {
|
|
108
|
+
const element = document.createElement('div');
|
|
109
|
+
const { style } = element;
|
|
110
|
+
style.position = 'fixed';
|
|
111
|
+
style.left = '0';
|
|
112
|
+
style.top = '0';
|
|
113
|
+
style.width = '0';
|
|
114
|
+
style.height = '0';
|
|
115
|
+
style.zIndex = '-1';
|
|
116
|
+
style.overflow = 'hidden';
|
|
117
|
+
style.visibility = 'hidden';
|
|
118
|
+
// Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
|
|
119
|
+
style.transitionDuration = '0.05s';
|
|
120
|
+
style.transitionProperty = 'padding';
|
|
121
|
+
style.transitionDelay = '0s';
|
|
122
|
+
style.paddingTop = getInset('top');
|
|
123
|
+
style.paddingBottom = getInset('bottom');
|
|
124
|
+
style.paddingLeft = getInset('left');
|
|
125
|
+
style.paddingRight = getInset('right');
|
|
126
|
+
return element;
|
|
127
|
+
}
|
package/src/SafeArea.types.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ViewProps,
|
|
5
|
-
ViewStyle,
|
|
6
|
-
} from 'react-native';
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
3
|
+
import NativeSafeAreaView from './specs/NativeSafeAreaView';
|
|
7
4
|
|
|
8
5
|
export type Edge = 'top' | 'right' | 'bottom' | 'left';
|
|
6
|
+
export type EdgeMode = 'off' | 'additive' | 'maximum';
|
|
7
|
+
|
|
8
|
+
export type EdgeRecord = Partial<Record<Edge, EdgeMode>>;
|
|
9
|
+
export type Edges = readonly Edge[] | Readonly<EdgeRecord>;
|
|
9
10
|
|
|
10
11
|
export interface EdgeInsets {
|
|
11
12
|
top: number;
|
|
@@ -30,14 +31,17 @@ export type InsetChangedEvent = NativeSyntheticEvent<Metrics>;
|
|
|
30
31
|
|
|
31
32
|
export type InsetChangeNativeCallback = (event: InsetChangedEvent) => void;
|
|
32
33
|
|
|
33
|
-
export interface NativeSafeAreaProviderProps {
|
|
34
|
+
export interface NativeSafeAreaProviderProps extends ViewProps {
|
|
34
35
|
children?: React.ReactNode;
|
|
35
|
-
style?: StyleProp<ViewStyle>;
|
|
36
36
|
onInsetsChange: InsetChangeNativeCallback;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export
|
|
39
|
+
export interface NativeSafeAreaViewProps extends ViewProps {
|
|
40
40
|
children?: React.ReactNode;
|
|
41
41
|
mode?: 'padding' | 'margin';
|
|
42
|
-
edges?:
|
|
43
|
-
}
|
|
42
|
+
edges?: Edges;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type NativeSafeAreaViewInstance = InstanceType<
|
|
46
|
+
typeof NativeSafeAreaView
|
|
47
|
+
>;
|