@amazon-devices/react-native-safe-area-context 2.0.9000000000 → 8.0.9000000000-rn-83

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.
Files changed (259) hide show
  1. package/README.md +6 -302
  2. package/SystemBundles/{85c8d24b7f717b77a2deb00e32cc2aaa293a5a16c46eecebca21e95bda425730.bundle → 920f0b3a0c43cc93db1621b4c3a47e06a0d4ed32175c793e9934ad9c764fbc25.bundle} +6447 -9418
  3. package/SystemBundles/920f0b3a0c43cc93db1621b4c3a47e06a0d4ed32175c793e9934ad9c764fbc25.map +2780 -0
  4. package/SystemModules/amzn__react-native-safe-area-context-8.modules.txt +7 -0
  5. package/SystemModules/amzn__react-native-safe-area-context-8.private.modules.txt +61 -0
  6. package/SystemModules/keplerscript-system-bundle-config.json +3 -3
  7. package/android/build.gradle +103 -25
  8. package/android/gradle.properties +1 -0
  9. package/android/spotless.gradle +24 -0
  10. package/android/src/fabric/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +25 -0
  11. package/android/src/fabric/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +14 -0
  12. package/android/src/main/AndroidManifest.xml +1 -2
  13. package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.kt +3 -0
  14. package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.kt +3 -0
  15. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt +32 -0
  16. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt +41 -0
  17. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.kt +47 -0
  18. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt +41 -0
  19. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.kt +102 -0
  20. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt +155 -0
  21. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt +16 -0
  22. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt +7 -0
  23. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt +73 -0
  24. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt +6 -0
  25. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt +170 -0
  26. package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.kt +39 -0
  27. package/android/src/main/jni/CMakeLists.txt +87 -0
  28. package/android/src/main/jni/safeareacontext.h +17 -0
  29. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java +31 -0
  30. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java +16 -0
  31. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java +41 -0
  32. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java +20 -0
  33. package/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +29 -0
  34. package/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java +56 -0
  35. package/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +20 -0
  36. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewComponentDescriptor.h +25 -0
  37. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp +131 -0
  38. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.h +36 -0
  39. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.cpp +23 -0
  40. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.h +56 -0
  41. package/ios/Fabric/RNCSafeAreaProviderComponentView.h +13 -0
  42. package/ios/Fabric/RNCSafeAreaProviderComponentView.mm +129 -0
  43. package/ios/Fabric/RNCSafeAreaViewComponentView.h +11 -0
  44. package/ios/Fabric/RNCSafeAreaViewComponentView.mm +153 -0
  45. package/ios/RNCSafeAreaContext.h +9 -0
  46. package/ios/RNCSafeAreaContext.mm +85 -0
  47. package/ios/{SafeAreaView/RNCSafeAreaProvider.h → RNCSafeAreaProvider.h} +4 -0
  48. package/ios/RNCSafeAreaProvider.m +102 -0
  49. package/ios/RNCSafeAreaProviderManager.m +20 -0
  50. package/ios/{SafeAreaView/RNCSafeAreaShadowView.m → RNCSafeAreaShadowView.m} +50 -36
  51. package/ios/RNCSafeAreaUtils.h +22 -0
  52. package/ios/RNCSafeAreaUtils.m +41 -0
  53. package/ios/{SafeAreaView/RNCSafeAreaView.h → RNCSafeAreaView.h} +8 -4
  54. package/ios/RNCSafeAreaView.m +168 -0
  55. package/ios/RNCSafeAreaViewEdgeMode.h +12 -0
  56. package/ios/RNCSafeAreaViewEdgeMode.m +16 -0
  57. package/ios/RNCSafeAreaViewEdges.h +15 -0
  58. package/ios/RNCSafeAreaViewEdges.m +36 -0
  59. package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.h → RNCSafeAreaViewLocalData.h} +12 -1
  60. package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.m → RNCSafeAreaViewLocalData.m} +4 -0
  61. package/ios/{SafeAreaView/RNCSafeAreaViewManager.m → RNCSafeAreaViewManager.m} +5 -1
  62. package/ios/RNCSafeAreaViewMode.m +15 -0
  63. package/ios/{SafeAreaView.xcodeproj → RNSafeAreaContext.xcodeproj}/project.pbxproj +70 -56
  64. package/jest/mock.tsx +59 -0
  65. package/kepler-compatibility.json +2 -2
  66. package/lib/commonjs/CompatNativeSafeAreaProvider.js +6 -6
  67. package/lib/commonjs/CompatNativeSafeAreaProvider.js.map +1 -1
  68. package/lib/commonjs/InitialWindow.js.map +1 -1
  69. package/lib/commonjs/InitialWindow.kepler.js +1 -1
  70. package/lib/commonjs/InitialWindow.kepler.js.map +1 -1
  71. package/lib/commonjs/InitialWindow.native.js +4 -4
  72. package/lib/commonjs/InitialWindow.native.js.map +1 -1
  73. package/lib/commonjs/NativeSafeAreaProvider.js +7 -124
  74. package/lib/commonjs/NativeSafeAreaProvider.js.map +1 -1
  75. package/lib/commonjs/NativeSafeAreaProvider.kepler.js +6 -2
  76. package/lib/commonjs/NativeSafeAreaProvider.kepler.js.map +1 -1
  77. package/lib/commonjs/NativeSafeAreaProvider.web.js +135 -0
  78. package/lib/commonjs/NativeSafeAreaProvider.web.js.map +1 -0
  79. package/lib/commonjs/NativeSafeAreaProvider.windows.js +6 -2
  80. package/lib/commonjs/NativeSafeAreaProvider.windows.js.map +1 -1
  81. package/lib/commonjs/SafeArea.types.js.map +1 -1
  82. package/lib/commonjs/SafeAreaContext.js +55 -34
  83. package/lib/commonjs/SafeAreaContext.js.map +1 -1
  84. package/lib/commonjs/SafeAreaView.js +39 -71
  85. package/lib/commonjs/SafeAreaView.js.map +1 -1
  86. package/lib/commonjs/SafeAreaView.kepler.js.map +1 -1
  87. package/lib/commonjs/SafeAreaView.web.js +91 -0
  88. package/lib/commonjs/SafeAreaView.web.js.map +1 -0
  89. package/lib/commonjs/SafeAreaView.windows.js.map +1 -1
  90. package/lib/commonjs/index.js +1 -0
  91. package/lib/commonjs/index.js.map +1 -1
  92. package/lib/commonjs/package.json +1 -0
  93. package/lib/commonjs/specs/NativeSafeAreaContext.js +9 -0
  94. package/lib/commonjs/specs/NativeSafeAreaContext.js.map +1 -0
  95. package/lib/commonjs/specs/NativeSafeAreaProvider.js +10 -0
  96. package/lib/commonjs/specs/NativeSafeAreaProvider.js.map +1 -0
  97. package/lib/commonjs/specs/NativeSafeAreaView.js +12 -0
  98. package/lib/commonjs/specs/NativeSafeAreaView.js.map +1 -0
  99. package/lib/module/CompatNativeSafeAreaProvider.js +8 -5
  100. package/lib/module/CompatNativeSafeAreaProvider.js.map +1 -1
  101. package/lib/module/InitialWindow.js +2 -0
  102. package/lib/module/InitialWindow.js.map +1 -1
  103. package/lib/module/InitialWindow.kepler.js +3 -1
  104. package/lib/module/InitialWindow.kepler.js.map +1 -1
  105. package/lib/module/InitialWindow.native.js +5 -4
  106. package/lib/module/InitialWindow.native.js.map +1 -1
  107. package/lib/module/NativeSafeAreaProvider.js +3 -122
  108. package/lib/module/NativeSafeAreaProvider.js.map +1 -1
  109. package/lib/module/NativeSafeAreaProvider.kepler.js +3 -2
  110. package/lib/module/NativeSafeAreaProvider.kepler.js.map +1 -1
  111. package/lib/module/NativeSafeAreaProvider.web.js +130 -0
  112. package/lib/module/NativeSafeAreaProvider.web.js.map +1 -0
  113. package/lib/module/NativeSafeAreaProvider.windows.js +3 -2
  114. package/lib/module/NativeSafeAreaProvider.windows.js.map +1 -1
  115. package/lib/module/SafeArea.types.js +2 -0
  116. package/lib/module/SafeArea.types.js.map +1 -1
  117. package/lib/module/SafeAreaContext.js +57 -33
  118. package/lib/module/SafeAreaContext.js.map +1 -1
  119. package/lib/module/SafeAreaView.js +38 -69
  120. package/lib/module/SafeAreaView.js.map +1 -1
  121. package/lib/module/SafeAreaView.kepler.js +2 -0
  122. package/lib/module/SafeAreaView.kepler.js.map +1 -1
  123. package/lib/module/SafeAreaView.web.js +86 -0
  124. package/lib/module/SafeAreaView.web.js.map +1 -0
  125. package/lib/module/SafeAreaView.windows.js +2 -0
  126. package/lib/module/SafeAreaView.windows.js.map +1 -1
  127. package/lib/module/index.js +3 -0
  128. package/lib/module/index.js.map +1 -1
  129. package/lib/module/specs/NativeSafeAreaContext.js +5 -0
  130. package/lib/module/specs/NativeSafeAreaContext.js.map +1 -0
  131. package/lib/module/specs/NativeSafeAreaProvider.js +5 -0
  132. package/lib/module/specs/NativeSafeAreaProvider.js.map +1 -0
  133. package/lib/module/specs/NativeSafeAreaView.js +7 -0
  134. package/lib/module/specs/NativeSafeAreaView.js.map +1 -0
  135. package/lib/typescript/CompatNativeSafeAreaProvider.d.ts +4 -0
  136. package/lib/typescript/CompatNativeSafeAreaProvider.d.ts.map +1 -0
  137. package/lib/typescript/{src/InitialWindow.d.ts → InitialWindow.d.ts} +2 -1
  138. package/lib/typescript/InitialWindow.d.ts.map +1 -0
  139. package/lib/typescript/{src/InitialWindow.kepler.d.ts → InitialWindow.kepler.d.ts} +1 -0
  140. package/lib/typescript/InitialWindow.kepler.d.ts.map +1 -0
  141. package/lib/typescript/{src/InitialWindow.native.d.ts → InitialWindow.native.d.ts} +2 -1
  142. package/lib/typescript/InitialWindow.native.d.ts.map +1 -0
  143. package/lib/typescript/NativeSafeAreaProvider.d.ts +3 -0
  144. package/lib/typescript/NativeSafeAreaProvider.d.ts.map +1 -0
  145. package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts +2 -0
  146. package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts.map +1 -0
  147. package/lib/typescript/NativeSafeAreaProvider.web.d.ts +4 -0
  148. package/lib/typescript/NativeSafeAreaProvider.web.d.ts.map +1 -0
  149. package/lib/typescript/NativeSafeAreaProvider.windows.d.ts +2 -0
  150. package/lib/typescript/NativeSafeAreaProvider.windows.d.ts.map +1 -0
  151. package/lib/typescript/SafeArea.types.d.ts +36 -0
  152. package/lib/typescript/SafeArea.types.d.ts.map +1 -0
  153. package/lib/typescript/{src/SafeAreaContext.d.ts → SafeAreaContext.d.ts} +9 -6
  154. package/lib/typescript/SafeAreaContext.d.ts.map +1 -0
  155. package/lib/typescript/SafeAreaView.d.ts +5 -0
  156. package/lib/typescript/SafeAreaView.d.ts.map +1 -0
  157. package/lib/typescript/{src/SafeAreaView.kepler.d.ts → SafeAreaView.kepler.d.ts} +1 -0
  158. package/lib/typescript/SafeAreaView.kepler.d.ts.map +1 -0
  159. package/lib/typescript/SafeAreaView.web.d.ts +4 -0
  160. package/lib/typescript/SafeAreaView.web.d.ts.map +1 -0
  161. package/lib/typescript/SafeAreaView.windows.d.ts +3 -0
  162. package/lib/typescript/SafeAreaView.windows.d.ts.map +1 -0
  163. package/lib/typescript/{src/index.d.ts → index.d.ts} +1 -0
  164. package/lib/typescript/index.d.ts.map +1 -0
  165. package/lib/typescript/specs/NativeSafeAreaContext.d.ts +23 -0
  166. package/lib/typescript/specs/NativeSafeAreaContext.d.ts.map +1 -0
  167. package/lib/typescript/specs/NativeSafeAreaProvider.d.ts +22 -0
  168. package/lib/typescript/specs/NativeSafeAreaProvider.d.ts.map +1 -0
  169. package/lib/typescript/specs/NativeSafeAreaView.d.ts +14 -0
  170. package/lib/typescript/specs/NativeSafeAreaView.d.ts.map +1 -0
  171. package/oss-attribution/attribution.txt +0 -0
  172. package/oss-attribution/licenseInfos.json +1 -0
  173. package/package.json +137 -1
  174. package/react-native-safe-area-context.podspec +26 -4
  175. package/react-native.config.js +8 -0
  176. package/src/CompatNativeSafeAreaProvider.tsx +2 -3
  177. package/src/InitialWindow.kepler.ts +1 -1
  178. package/src/InitialWindow.native.ts +5 -11
  179. package/src/InitialWindow.ts +1 -1
  180. package/src/NativeSafeAreaProvider.kepler.tsx +1 -3
  181. package/src/NativeSafeAreaProvider.tsx +2 -128
  182. package/src/NativeSafeAreaProvider.web.tsx +127 -0
  183. package/src/NativeSafeAreaProvider.windows.tsx +1 -3
  184. package/src/SafeArea.types.ts +15 -11
  185. package/src/SafeAreaContext.tsx +66 -43
  186. package/src/SafeAreaView.tsx +47 -82
  187. package/src/SafeAreaView.web.tsx +123 -0
  188. package/src/SafeAreaView.windows.tsx +2 -1
  189. package/src/index.tsx +2 -0
  190. package/src/specs/NativeSafeAreaContext.ts +23 -0
  191. package/src/specs/NativeSafeAreaProvider.ts +29 -0
  192. package/src/specs/NativeSafeAreaView.ts +17 -0
  193. package/SystemBundles/85c8d24b7f717b77a2deb00e32cc2aaa293a5a16c46eecebca21e95bda425730.map +0 -4335
  194. package/SystemModules/amzn__react-native-safe-area-context-2.modules.txt +0 -55
  195. package/SystemModules/amzn__react-native-safe-area-context-2.private.modules.txt +0 -90
  196. package/THIRD_PARTY_NOTICES.txt +0 -24
  197. package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.java +0 -22
  198. package/android/src/main/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.java +0 -33
  199. package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.java +0 -22
  200. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.java +0 -31
  201. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.java +0 -66
  202. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.java +0 -94
  203. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.java +0 -82
  204. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.java +0 -159
  205. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.java +0 -8
  206. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.java +0 -27
  207. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.java +0 -72
  208. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.java +0 -6
  209. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.java +0 -201
  210. package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.java +0 -52
  211. package/ios/SafeAreaView/RCTView+SafeAreaCompat.h +0 -16
  212. package/ios/SafeAreaView/RCTView+SafeAreaCompat.m +0 -57
  213. package/ios/SafeAreaView/RNCSafeAreaProvider.m +0 -65
  214. package/ios/SafeAreaView/RNCSafeAreaProviderManager.m +0 -61
  215. package/ios/SafeAreaView/RNCSafeAreaView.m +0 -118
  216. package/ios/SafeAreaView/RNCSafeAreaViewEdges.h +0 -9
  217. package/ios/SafeAreaView/RNCSafeAreaViewEdges.m +0 -13
  218. package/ios/SafeAreaView/RNCSafeAreaViewMode.m +0 -11
  219. package/lib/commonjs/NativeSafeAreaProvider.macos.js +0 -9
  220. package/lib/commonjs/NativeSafeAreaProvider.macos.js.map +0 -1
  221. package/lib/commonjs/NativeSafeAreaProvider.native.js +0 -9
  222. package/lib/commonjs/NativeSafeAreaProvider.native.js.map +0 -1
  223. package/lib/commonjs/SafeAreaView.macos.js +0 -9
  224. package/lib/commonjs/SafeAreaView.macos.js.map +0 -1
  225. package/lib/commonjs/SafeAreaView.native.js +0 -9
  226. package/lib/commonjs/SafeAreaView.native.js.map +0 -1
  227. package/lib/commonjs/useWindowDimensions.js +0 -32
  228. package/lib/commonjs/useWindowDimensions.js.map +0 -1
  229. package/lib/module/NativeSafeAreaProvider.macos.js +0 -3
  230. package/lib/module/NativeSafeAreaProvider.macos.js.map +0 -1
  231. package/lib/module/NativeSafeAreaProvider.native.js +0 -3
  232. package/lib/module/NativeSafeAreaProvider.native.js.map +0 -1
  233. package/lib/module/SafeAreaView.macos.js +0 -3
  234. package/lib/module/SafeAreaView.macos.js.map +0 -1
  235. package/lib/module/SafeAreaView.native.js +0 -3
  236. package/lib/module/SafeAreaView.native.js.map +0 -1
  237. package/lib/module/useWindowDimensions.js +0 -26
  238. package/lib/module/useWindowDimensions.js.map +0 -1
  239. package/lib/typescript/src/CompatNativeSafeAreaProvider.d.ts +0 -2
  240. package/lib/typescript/src/NativeSafeAreaProvider.d.ts +0 -2
  241. package/lib/typescript/src/NativeSafeAreaProvider.kepler.d.ts +0 -2
  242. package/lib/typescript/src/NativeSafeAreaProvider.macos.d.ts +0 -2
  243. package/lib/typescript/src/NativeSafeAreaProvider.native.d.ts +0 -3
  244. package/lib/typescript/src/NativeSafeAreaProvider.windows.d.ts +0 -2
  245. package/lib/typescript/src/SafeArea.types.d.ts +0 -31
  246. package/lib/typescript/src/SafeAreaView.d.ts +0 -2
  247. package/lib/typescript/src/SafeAreaView.macos.d.ts +0 -2
  248. package/lib/typescript/src/SafeAreaView.native.d.ts +0 -2
  249. package/lib/typescript/src/SafeAreaView.windows.d.ts +0 -2
  250. package/lib/typescript/src/useWindowDimensions.d.ts +0 -8
  251. package/src/NativeSafeAreaProvider.macos.tsx +0 -3
  252. package/src/NativeSafeAreaProvider.native.tsx +0 -6
  253. package/src/SafeAreaView.macos.tsx +0 -3
  254. package/src/SafeAreaView.native.tsx +0 -6
  255. package/src/useWindowDimensions.tsx +0 -35
  256. /package/ios/{SafeAreaView/RNCSafeAreaProviderManager.h → RNCSafeAreaProviderManager.h} +0 -0
  257. /package/ios/{SafeAreaView/RNCSafeAreaShadowView.h → RNCSafeAreaShadowView.h} +0 -0
  258. /package/ios/{SafeAreaView/RNCSafeAreaViewManager.h → RNCSafeAreaViewManager.h} +0 -0
  259. /package/ios/{SafeAreaView/RNCSafeAreaViewMode.h → RNCSafeAreaViewMode.h} +0 -0
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ![safearea](https://github.com/user-attachments/assets/d951efe6-4d25-4ff6-b654-7aaf4519829b)
2
+ ### About
3
+ App & Flow is a Montreal-based React Native engineering and consulting studio. We partner with the world’s top companies and are recommended by [Expo](https://expo.dev/consultants). Need a hand? Let’s build together. team@appandflow.com
4
+
1
5
  # react-native-safe-area-context
2
6
 
3
7
  [![npm](https://img.shields.io/npm/v/react-native-safe-area-context)](https://www.npmjs.com/package/react-native-safe-area-context) ![Supports Android, iOS, web, macOS and Windows](https://img.shields.io/badge/platforms-android%20%7C%20ios%20%7C%20web%20%7C%20macos%20%7C%20windows-lightgrey.svg) ![MIT License](https://img.shields.io/npm/l/react-native-safe-area-context.svg)
@@ -6,309 +10,9 @@
6
10
 
7
11
  A flexible way to handle safe area, also works on Android and Web!
8
12
 
9
- ## Getting started
10
-
11
- ```
12
- npm install react-native-safe-area-context
13
- ```
14
-
15
- You then need to link the native parts of the library for the platforms you are using.
16
-
17
- #### Linking in React Native >= 0.60
18
-
19
- Linking the package is not required anymore with [Autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).
20
-
21
- - **iOS Platform:**
22
-
23
- `$ npx pod-install`
24
-
25
- #### Linking in React Native < 0.60
26
-
27
- The easiest way to link the library is using the CLI tool by running this command from the root of your project:
28
-
29
- ```
30
- react-native link react-native-safe-area-context
31
- ```
32
-
33
- If you can't or don't want to use the CLI tool, you can also manually link the library using the instructions below (click on the arrow to show them):
34
-
35
- <details>
36
- <summary>Manually link the library on iOS</summary>
37
-
38
- Either follow the [instructions in the React Native documentation](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking) to manually link the framework or link using [Cocoapods](https://cocoapods.org) by adding this to your `Podfile`:
39
-
40
- ```ruby
41
- pod 'react-native-safe-area-context', :path => '../node_modules/react-native-safe-area-context'
42
- ```
43
-
44
- </details>
45
-
46
- <details>
47
- <summary>Manually link the library on Android</summary>
48
-
49
- Make the following changes:
50
-
51
- #### `android/settings.gradle`
52
-
53
- ```groovy
54
- include ':react-native-safe-area-context'
55
- project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
56
- ```
57
-
58
- #### `android/app/build.gradle`
59
-
60
- ```groovy
61
- dependencies {
62
- ...
63
- implementation project(':react-native-safe-area-context')
64
- }
65
- ```
66
-
67
- #### `android/app/src/main/.../MainApplication.java`
68
-
69
- On top, where imports are:
70
-
71
- ```java
72
- import com.th3rdwave.safeareacontext.SafeAreaContextPackage;
73
- ```
74
-
75
- Add the `SafeAreaContextPackage` class to your list of exported packages.
76
-
77
- ```java
78
- @Override
79
- protected List<ReactPackage> getPackages() {
80
- return Arrays.asList(
81
- new MainReactPackage(),
82
- ...
83
- new SafeAreaContextPackage()
84
- );
85
- }
86
- ```
87
-
88
- </details>
89
-
90
- **Note**
91
- Before 3.1.9 release of safe-area-context, Building for React Native 0.59 would not work due to missing header files. Use >= 3.1.9 to work around that.
92
-
93
- ## Usage
94
-
95
- This library has 2 important concepts, if you are familiar with React Context this is very similar.
96
-
97
- ### Providers
98
-
99
- The [SafeAreaProvider](#safeareaprovider) component is a `View` from where insets provided by [Consumers](#consumers) are relative to. This means that if this view overlaps with any system elements (status bar, notches, etc.) these values will be provided to descendent consumers. Usually you will have one provider at the top of your app.
100
-
101
- ### Consumers
102
-
103
- Consumers are components and hooks that allow using inset values provided by the nearest parent [Provider](#providers). Values are always relative to a provider and not to these components.
104
-
105
- - [SafeAreaView](#safeareaview) is the preferred way to consume insets. This is a regular `View` with insets applied as extra padding or margin. It offers better performance by applying insets natively and avoids flickers that can happen with the other JS based consumers.
106
-
107
- - [useSafeAreaInsets](#usesafeareainsets) offers more flexibility, but can cause some layout flicker in certain cases. Use this if you need more control over how insets are applied.
108
-
109
- ## API
110
-
111
- ### SafeAreaProvider
112
-
113
- You should add `SafeAreaProvider` in your app root component. You may need to add it in other places like the root of modals and routes when using [`react-native-screens`](https://github.com/software-mansion/react-native-screens).
114
-
115
- Note that providers should not be inside a `View` that is animated with `Animated` or inside a `ScrollView` since it can cause very frequent updates.
116
-
117
- #### Example
118
-
119
- ```js
120
- import { SafeAreaProvider } from '@amazon-devices/react-native-safe-area-context';
121
-
122
- function App() {
123
- return <SafeAreaProvider>...</SafeAreaProvider>;
124
- }
125
- ```
126
-
127
- #### Props
128
-
129
- Accepts all [View](https://reactnative.dev/docs/view#props) props. Has a default style of `{flex: 1}`.
130
-
131
- ##### `initialMetrics`
132
-
133
- Optional, defaults to `null`.
134
-
135
- Can be used to provide the initial value for frame and insets, this allows rendering immediatly. See [optimization](#optimization) for more information on how to use this prop.
136
-
137
- ### SafeAreaView
138
-
139
- `SafeAreaView` is a regular `View` component with the safe area insets applied as padding or margin.
140
-
141
- Padding or margin styles are added to the insets, for example `style={{paddingTop: 10}}` on a `SafeAreaView` that has insets of 20 will result in a top padding of 30.
142
-
143
- #### Example
144
-
145
- ```js
146
- import { SafeAreaView } from '@amazon-devices/react-native-safe-area-context';
147
-
148
- function SomeComponent() {
149
- return (
150
- <SafeAreaView style={{ flex: 1, backgroundColor: 'red' }}>
151
- <View style={{ flex: 1, backgroundColor: 'blue' }} />
152
- </SafeAreaView>
153
- );
154
- }
155
- ```
156
-
157
- #### Props
158
-
159
- Accepts all [View](https://reactnative.dev/docs/view#props) props.
160
-
161
- ##### `edges`
162
-
163
- Optional, array of `top`, `right`, `bottom`, and `left`. Defaults to all.
164
-
165
- Sets the edges to apply the safe area insets to.
166
-
167
- For example if you don't want insets to apply to the top edge because the view does not touch the top of the screen you can use:
168
-
169
- ```js
170
- <SafeAreaView edges={['right', 'bottom', 'left']} />
171
- ```
172
-
173
- ##### `mode`
174
-
175
- Optional, `padding` (default) or `margin`.
176
-
177
- Apply the safe area to either the padding or the margin.
178
-
179
- This can be useful for example to create a safe area aware separator component:
180
-
181
- ```js
182
- <SafeAreaView mode="margin" style={{ height: 1, backgroundColor: '#eee' }} />
183
- ```
184
-
185
- ### useSafeAreaInsets
186
-
187
- Returns the safe area insets of the nearest provider. This allows manipulating the inset values from JavaScript. Note that insets are not updated synchronously so it might cause a slight delay for example when rotating the screen.
188
-
189
- Object with `{ top: number, right: number, bottom: number, left: number }`.
190
-
191
- ```js
192
- import { useSafeAreaInsets } from '@amazon-devices/react-native-safe-area-context';
193
-
194
- function HookComponent() {
195
- const insets = useSafeAreaInsets();
196
-
197
- return <View style={{ paddingBottom: Math.max(insets.bottom, 16) }} />;
198
- }
199
- ```
200
-
201
- ### useSafeAreaFrame
202
-
203
- Returns the frame of the nearest provider. This can be used as an alternative to the `Dimensions` module.
204
-
205
- Object with `{ x: number, y: number, width: number, height: number }`
206
-
207
- ### `SafeAreaInsetsContext`
208
-
209
- React Context with the value of the safe area insets.
210
-
211
- Can be used with class components:
212
-
213
- ```js
214
- import { SafeAreaInsetsContext } from '@amazon-devices/react-native-safe-area-context';
215
-
216
- class ClassComponent extends React.Component {
217
- render() {
218
- return (
219
- <SafeAreaInsetsContext.Consumer>
220
- {(insets) => <View style={{ paddingTop: insets.top }} />}
221
- </SafeAreaInsetsContext.Consumer>
222
- );
223
- }
224
- }
225
- ```
226
-
227
- ### `withSafeAreaInsets`
228
-
229
- Higher order component that provides safe area insets as the `insets` prop.
230
-
231
- ### `SafeAreaFrameContext`
232
-
233
- React Context with the value of the safe area frame.
234
-
235
- ### `initialWindowMetrics`
236
-
237
- Insets and frame of the window on initial render. This can be used with the `initialMetrics` from `SafeAreaProvider`. See [optimization](#optimization) for more information.
238
-
239
- Object with:
240
-
241
- ```ts
242
- {
243
- frame: { x: number, y: number, width: number, height: number },
244
- insets: { top: number, left: number, right: number, bottom: number },
245
- }
246
- ```
247
-
248
- **NOTE:** This value can be null or out of date as it is computed when the native module is created.
249
-
250
- ## Deprecated apis
251
-
252
- ### useSafeArea
253
-
254
- Use `useSafeAreaInsets` instead.
255
-
256
- ### SafeAreaConsumer
257
-
258
- Use `SafeAreaInsetsContext.Consumer` instead.
259
-
260
- ### SafeAreaContext
261
-
262
- Use `SafeAreaInsetsContext` instead.
263
-
264
- ### initialWindowSafeAreaInsets
265
-
266
- Use `initialWindowMetrics` instead.
267
-
268
- ## Web SSR
269
-
270
- If you are doing server side rendering on the web you can use `initialMetrics` to inject insets and frame value based on the device the user has, or simply pass zero values. Since insets measurement is async it will break rendering your page content otherwise.
271
-
272
- ## Optimization
273
-
274
- If you can, use `SafeAreaView`. It's implemented natively so when rotating the device, there is no delay from the asynchronous bridge.
275
-
276
- To speed up the initial render, you can import `initialWindowMetrics` from this package and set as the `initialMetrics` prop on the provider as described in Web SSR. You cannot do this if your provider remounts, or you are using `react-native-navigation`.
277
-
278
- ```js
279
- import {
280
- SafeAreaProvider,
281
- initialWindowMetrics,
282
- } from '@amazon-devices/react-native-safe-area-context';
283
-
284
- function App() {
285
- return (
286
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
287
- ...
288
- </SafeAreaProvider>
289
- );
290
- }
291
- ```
292
-
293
- ## Testing
294
-
295
- When testing components nested under `SafeAreaProvider`, ensure to pass `initialMetrics` to
296
- provide mock data for frame and insets and ensure the provider renders its children.
13
+ ## Documentation
297
14
 
298
- ```js
299
- export function TestSafeAreaProvider({ children }) {
300
- return (
301
- <SafeAreaProvider
302
- initialMetrics={{
303
- frame: { x: 0, y: 0, width: 0, height: 0 },
304
- insets: { top: 0, left: 0, right: 0, bottom: 0 },
305
- }}
306
- >
307
- {children}
308
- </SafeAreaProvider>
309
- );
310
- }
311
- ```
15
+ Check out our [documentation site](https://appandflow.github.io/react-native-safe-area-context/).
312
16
 
313
17
  ## Contributing
314
18