|
@@ -43,12 +43,14 @@ pod 'react-native-safe-area-context', :path => '../node_modules/react-native-saf
|
43
|
43
|
Make the following changes:
|
44
|
44
|
|
45
|
45
|
#### `android/settings.gradle`
|
|
46
|
+
|
46
|
47
|
```groovy
|
47
|
48
|
include ':react-native-safe-area-context'
|
48
|
49
|
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
|
49
|
50
|
```
|
50
|
51
|
|
51
|
52
|
#### `android/app/build.gradle`
|
|
53
|
+
|
52
|
54
|
```groovy
|
53
|
55
|
dependencies {
|
54
|
56
|
...
|
|
@@ -57,6 +59,7 @@ dependencies {
|
57
|
59
|
```
|
58
|
60
|
|
59
|
61
|
#### `android/app/src/main/.../MainApplication.java`
|
|
62
|
+
|
60
|
63
|
On top, where imports are:
|
61
|
64
|
|
62
|
65
|
```java
|
|
@@ -75,6 +78,7 @@ protected List<ReactPackage> getPackages() {
|
75
|
78
|
);
|
76
|
79
|
}
|
77
|
80
|
```
|
|
81
|
+
|
78
|
82
|
</details>
|
79
|
83
|
|
80
|
84
|
## Usage
|
|
@@ -85,11 +89,7 @@ Add `SafeAreaProvider` in your app root component:
|
85
|
89
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
86
|
90
|
|
87
|
91
|
function App() {
|
88
|
|
- return (
|
89
|
|
- <SafeAreaProvider>
|
90
|
|
- ...
|
91
|
|
- </SafeAreaProvider>
|
92
|
|
- );
|
|
92
|
+ return <SafeAreaProvider>...</SafeAreaProvider>;
|
93
|
93
|
}
|
94
|
94
|
```
|
95
|
95
|
|
|
@@ -139,6 +139,27 @@ function SomeComponent() {
|
139
|
139
|
|
140
|
140
|
If you are doing server side rendering on the web you can use `initialSafeAreaInsets` to inject insets 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.
|
141
|
141
|
|
|
142
|
+### Optimization
|
|
143
|
+
|
|
144
|
+To speed up the initial render, you can import `initialWindowSafeAreaInsets` from this package and set as the `initialSafeAreaInsets` prop on the provider as described in Web SSR. You cannot do this if your provider remounts, or you are using `react-native-navigation`.
|
|
145
|
+
|
|
146
|
+Only supported on iOS at the moment.
|
|
147
|
+
|
|
148
|
+```js
|
|
149
|
+import {
|
|
150
|
+ SafeAreaProvider,
|
|
151
|
+ initialWindowSafeAreaInsets,
|
|
152
|
+} from 'react-native-safe-area-context';
|
|
153
|
+
|
|
154
|
+function App() {
|
|
155
|
+ return (
|
|
156
|
+ <SafeAreaProvider initialSafeAreaInsets={initialWindowSafeAreaInsets}>
|
|
157
|
+ ...
|
|
158
|
+ </SafeAreaProvider>
|
|
159
|
+ );
|
|
160
|
+}
|
|
161
|
+```
|
|
162
|
+
|
142
|
163
|
## Resources
|
143
|
164
|
|
144
|
165
|
- Great article about how this library can be used: https://dev.to/brunolemos/adding-notch-support-to-your-react-native-android-app-3ci3
|