expo-navigation-bar 4.1.2 → 4.2.0

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 (51) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/build.gradle +2 -2
  3. package/build/NativeNavigationBarWrapper.d.ts +178 -0
  4. package/build/NativeNavigationBarWrapper.d.ts.map +1 -0
  5. package/build/NativeNavigationBarWrapper.js +316 -0
  6. package/build/NativeNavigationBarWrapper.js.map +1 -0
  7. package/build/NavigationBar.d.ts +12 -152
  8. package/build/NavigationBar.d.ts.map +1 -1
  9. package/build/NavigationBar.js +32 -292
  10. package/build/NavigationBar.js.map +1 -1
  11. package/build/NavigationBar.types.d.ts +9 -0
  12. package/build/NavigationBar.types.d.ts.map +1 -1
  13. package/build/NavigationBar.types.js.map +1 -1
  14. package/expo-module.config.json +1 -1
  15. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.module → 4.2.0/expo.modules.navigationbar-4.2.0.module} +7 -7
  16. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.module.md5 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.module.sha1 +1 -0
  18. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.module.sha256 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.module.sha512 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.pom → 4.2.0/expo.modules.navigationbar-4.2.0.pom} +1 -1
  21. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.pom.md5 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.pom.sha1 +1 -0
  23. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.pom.sha256 +1 -0
  24. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.2.0/expo.modules.navigationbar-4.2.0.pom.sha512 +1 -0
  25. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/maven-metadata.xml +4 -4
  26. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/maven-metadata.xml.md5 +1 -1
  27. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/maven-metadata.xml.sha1 +1 -1
  28. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/maven-metadata.xml.sha256 +1 -1
  29. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/maven-metadata.xml.sha512 +1 -1
  30. package/package.json +6 -5
  31. package/src/NativeNavigationBarWrapper.ts +366 -0
  32. package/src/NavigationBar.ts +39 -320
  33. package/src/NavigationBar.types.ts +10 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.module.md5 +0 -1
  35. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.module.sha1 +0 -1
  36. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.module.sha256 +0 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.module.sha512 +0 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.pom.md5 +0 -1
  39. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.pom.sha1 +0 -1
  40. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.pom.sha256 +0 -1
  41. package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/4.1.2/expo.modules.navigationbar-4.1.2.pom.sha512 +0 -1
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2-sources.jar → 4.2.0/expo.modules.navigationbar-4.2.0-sources.jar} +0 -0
  43. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2-sources.jar.md5 → 4.2.0/expo.modules.navigationbar-4.2.0-sources.jar.md5} +0 -0
  44. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2-sources.jar.sha1 → 4.2.0/expo.modules.navigationbar-4.2.0-sources.jar.sha1} +0 -0
  45. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2-sources.jar.sha256 → 4.2.0/expo.modules.navigationbar-4.2.0-sources.jar.sha256} +0 -0
  46. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2-sources.jar.sha512 → 4.2.0/expo.modules.navigationbar-4.2.0-sources.jar.sha512} +0 -0
  47. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.aar → 4.2.0/expo.modules.navigationbar-4.2.0.aar} +0 -0
  48. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.aar.md5 → 4.2.0/expo.modules.navigationbar-4.2.0.aar.md5} +0 -0
  49. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.aar.sha1 → 4.2.0/expo.modules.navigationbar-4.2.0.aar.sha1} +0 -0
  50. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.aar.sha256 → 4.2.0/expo.modules.navigationbar-4.2.0.aar.sha256} +0 -0
  51. /package/local-maven-repo/host/exp/exponent/expo.modules.navigationbar/{4.1.2/expo.modules.navigationbar-4.1.2.aar.sha512 → 4.2.0/expo.modules.navigationbar-4.2.0.aar.sha512} +0 -0
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.navigationbar",
6
- "version": "4.1.2",
6
+ "version": "4.2.0",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.navigationbar-4.1.2.aar",
28
- "url": "expo.modules.navigationbar-4.1.2.aar",
27
+ "name": "expo.modules.navigationbar-4.2.0.aar",
28
+ "url": "expo.modules.navigationbar-4.2.0.aar",
29
29
  "size": 50116,
30
30
  "sha512": "9002413b7a09b940dda0ec41995b6fb09841f18ac5c64a81a149aa123d438487f1f5aaa072a0de7d54ad1e77712968d76502d4e745ea759defa83bce5edaecad",
31
31
  "sha256": "efc2da7015bb42d104de63aaafe098e547b290c00892881177100cff34bb1654",
@@ -67,8 +67,8 @@
67
67
  ],
68
68
  "files": [
69
69
  {
70
- "name": "expo.modules.navigationbar-4.1.2.aar",
71
- "url": "expo.modules.navigationbar-4.1.2.aar",
70
+ "name": "expo.modules.navigationbar-4.2.0.aar",
71
+ "url": "expo.modules.navigationbar-4.2.0.aar",
72
72
  "size": 50116,
73
73
  "sha512": "9002413b7a09b940dda0ec41995b6fb09841f18ac5c64a81a149aa123d438487f1f5aaa072a0de7d54ad1e77712968d76502d4e745ea759defa83bce5edaecad",
74
74
  "sha256": "efc2da7015bb42d104de63aaafe098e547b290c00892881177100cff34bb1654",
@@ -87,8 +87,8 @@
87
87
  },
88
88
  "files": [
89
89
  {
90
- "name": "expo.modules.navigationbar-4.1.2-sources.jar",
91
- "url": "expo.modules.navigationbar-4.1.2-sources.jar",
90
+ "name": "expo.modules.navigationbar-4.2.0-sources.jar",
91
+ "url": "expo.modules.navigationbar-4.2.0-sources.jar",
92
92
  "size": 5746,
93
93
  "sha512": "b062a1e85ccee489c49a264c5809226a0215ba7b7232895127f45002b605e6d5beb5739a3fee2c3b88420721949d17adfbd9dc15aaadebecd940958c871a8e28",
94
94
  "sha256": "c396cf58026bd79f443df5992bd12db17586c7e3702f1ace4c3e3e65a066cf14",
@@ -0,0 +1 @@
1
+ cc026d254024aa01b3989a6436867e6871e408416c495544e98b521bfbceed22
@@ -0,0 +1 @@
1
+ 1faf19621a3dfea493786219c0e7d3b4452cfc35bbf39de9ae779fe921774d24fdb564aaa49a4d38871cdaa4541d6f226feb38c1dc76566c5255d2e61ec4162a
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.navigationbar</artifactId>
12
- <version>4.1.2</version>
12
+ <version>4.2.0</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.navigationbar</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ a40d811800056e1d146ccd7d734975040f23cd332e5ec490b2c0728f16aba832
@@ -0,0 +1 @@
1
+ 6fcef0828efa2b7a49e7659cd414bf4f4670e7e2450563124e8693c1dde1fa77f142be74958ce1d32263ae476fdc66965804e265897f6eacbb48e756372c71e4
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.navigationbar</artifactId>
5
5
  <versioning>
6
- <latest>4.1.2</latest>
7
- <release>4.1.2</release>
6
+ <latest>4.2.0</latest>
7
+ <release>4.2.0</release>
8
8
  <versions>
9
- <version>4.1.2</version>
9
+ <version>4.2.0</version>
10
10
  </versions>
11
- <lastUpdated>20250409202802</lastUpdated>
11
+ <lastUpdated>20250421213308</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 3a083bd3c41a139256861de55958c0d7
1
+ bc75226166051fca81a20cd4b391104e
@@ -1 +1 @@
1
- dee6fac5deeb66ee15536f555c11485ce42a6e7b
1
+ f242d6e566913c9883f105e05bdd02e2b77e6470
@@ -1 +1 @@
1
- d97a354b10b846dfbd0f52e86030924af0eb6c4346bf98863c9d184ce7df6be2
1
+ 874b736a29798298d102061509bde4e1c93542da819d31aaffc75889046c24b5
@@ -1 +1 @@
1
- 33837522ab36eb3a45629c903bb3f915ce6b27531633be7f4d4651ec1c8d37ddcce80e7a9e5e33a5e9cbfe33a063e95ebe80795d6f1737dd70b9c55f7a8d76ff
1
+ 0ec26a66fe23714b30881fa9064e18b252ebbdf6880ec84d5f53939bd960b0cdb38b0526c7ba52855fad1a0a0bdc60bb97b5ee8542faa85e24288fb111619113
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-navigation-bar",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "Modify and observe the native navigation bar on Android devices.",
5
5
  "main": "build/NavigationBar.js",
6
6
  "types": "build/NavigationBar.d.ts",
@@ -34,18 +34,19 @@
34
34
  "license": "MIT",
35
35
  "homepage": "https://docs.expo.dev/versions/latest/sdk/navigation-bar",
36
36
  "dependencies": {
37
- "@react-native/normalize-colors": "0.79.0",
37
+ "@react-native/normalize-colors": "0.79.1",
38
38
  "debug": "^4.3.2",
39
- "react-native-is-edge-to-edge": "^1.1.6"
39
+ "react-native-is-edge-to-edge": "^1.1.6",
40
+ "react-native-edge-to-edge": "1.6.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@types/debug": "^4.1.7",
43
- "expo-module-scripts": "^4.1.1"
44
+ "expo-module-scripts": "^4.1.2"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "expo": "*",
47
48
  "react": "*",
48
49
  "react-native": "*"
49
50
  },
50
- "gitHead": "1914bb35d23af23078da37e70988261844436505"
51
+ "gitHead": "f1394f21ff2719a9a3037d7511db170704e5c492"
51
52
  }
@@ -0,0 +1,366 @@
1
+ import { type EventSubscription, Platform, UnavailabilityError } from 'expo-modules-core';
2
+ import { useEffect, useState } from 'react';
3
+ import { processColor } from 'react-native';
4
+ import { isEdgeToEdge } from 'react-native-is-edge-to-edge';
5
+
6
+ import ExpoNavigationBar from './ExpoNavigationBar';
7
+ import {
8
+ NavigationBarBehavior,
9
+ NavigationBarButtonStyle,
10
+ NavigationBarPosition,
11
+ NavigationBarVisibility,
12
+ NavigationBarVisibilityEvent,
13
+ } from './NavigationBar.types';
14
+
15
+ const shouldWarnAboutEdgeToEdge = Platform.OS === 'android' && isEdgeToEdge();
16
+ const defaultMessage =
17
+ 'Using expo-navigation-bar in apps with edge-to-edge layout enabled may cause unexpected behavior. Instead, use the SystemBars component from react-native-edge-to-edge. Learn more: https://expo.fyi/edge-to-edge-system-bars';
18
+
19
+ function potentiallyWarnAboutEdgeToEdge(message: string = defaultMessage) {
20
+ if (shouldWarnAboutEdgeToEdge) {
21
+ console.warn(message);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Observe changes to the system navigation bar.
27
+ * Due to platform constraints, this callback will also be triggered when the status bar visibility changes.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * NavigationBar.addVisibilityListener(({ visibility }) => {
32
+ * // ...
33
+ * });
34
+ * ```
35
+ */
36
+ export function addVisibilityListener(
37
+ listener: (event: NavigationBarVisibilityEvent) => void
38
+ ): EventSubscription {
39
+ // Assert so the type is non-nullable.
40
+ if (!ExpoNavigationBar.addListener) {
41
+ throw new UnavailabilityError('NavigationBar', 'addVisibilityListener');
42
+ }
43
+ return ExpoNavigationBar.addListener('ExpoNavigationBar.didChange', listener);
44
+ }
45
+
46
+ /**
47
+ * Changes the navigation bar's background color.
48
+ *
49
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * NavigationBar.setBackgroundColorAsync("white");
54
+ * ```
55
+ * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).
56
+ */
57
+ export async function setBackgroundColorAsync(color: string): Promise<void> {
58
+ if (__DEV__) {
59
+ potentiallyWarnAboutEdgeToEdge(
60
+ 'Setting the background color of the navigation bar is not supported when edge-to-edge is enabled And may lead to unexpected behavoir. Use the `setStyle` method instead.'
61
+ );
62
+ }
63
+ if (Platform.OS !== 'android') {
64
+ console.warn('`setBackgroundColorAsync` is only available on Android');
65
+ return;
66
+ }
67
+ const colorNumber = processColor(color);
68
+ return await ExpoNavigationBar.setBackgroundColorAsync(colorNumber);
69
+ }
70
+
71
+ /**
72
+ * Gets the navigation bar's background color.
73
+ *
74
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const color = await NavigationBar.getBackgroundColorAsync();
79
+ * ```
80
+ * @returns Current navigation bar color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).
81
+ *
82
+ */
83
+ export async function getBackgroundColorAsync(): Promise<string> {
84
+ if (__DEV__) {
85
+ potentiallyWarnAboutEdgeToEdge(
86
+ 'Getting the background color of the navigation bar is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
87
+ );
88
+ }
89
+ if (Platform.OS !== 'android') {
90
+ console.warn('`getBackgroundColorAsync` is only available on Android');
91
+ return `#00000000`;
92
+ }
93
+ return await ExpoNavigationBar.getBackgroundColorAsync();
94
+ }
95
+
96
+ /**
97
+ * Changes the navigation bar's border color.
98
+ *
99
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * NavigationBar.setBorderColorAsync("red");
104
+ * ```
105
+ * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).
106
+ */
107
+ export async function setBorderColorAsync(color: string): Promise<void> {
108
+ if (__DEV__) {
109
+ potentiallyWarnAboutEdgeToEdge(
110
+ 'Setting the border color of the navigation bar is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
111
+ );
112
+ }
113
+ if (Platform.OS !== 'android') {
114
+ console.warn('`setBorderColorAsync` is only available on Android');
115
+ return;
116
+ }
117
+ const colorNumber = processColor(color);
118
+ await ExpoNavigationBar.setBorderColorAsync(colorNumber);
119
+ }
120
+
121
+ /**
122
+ * Gets the navigation bar's top border color, also known as the "divider color".
123
+ *
124
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * const color = await NavigationBar.getBorderColorAsync();
129
+ * ```
130
+ * @returns Navigation bar top border color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).
131
+ */
132
+ export async function getBorderColorAsync(): Promise<string> {
133
+ if (__DEV__) {
134
+ potentiallyWarnAboutEdgeToEdge(
135
+ 'Getting the border color of the navigation bar is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
136
+ );
137
+ }
138
+ if (Platform.OS !== 'android') {
139
+ console.warn('`getBorderColorAsync` is only available on Android');
140
+ return `#00000000`;
141
+ }
142
+
143
+ return await ExpoNavigationBar.getBorderColorAsync();
144
+ }
145
+
146
+ /**
147
+ * Get the navigation bar's visibility.
148
+ *
149
+ *
150
+ * @example
151
+ * ```ts
152
+ * const visibility = await NavigationBar.getVisibilityAsync("hidden");
153
+ * ```
154
+ * @returns Navigation bar's current visibility status. Returns `hidden` on unsupported platforms (iOS, web).
155
+ */
156
+ export async function getVisibilityAsync(): Promise<NavigationBarVisibility> {
157
+ if (Platform.OS !== 'android') {
158
+ console.warn('`getVisibilityAsync` is only available on Android');
159
+ return 'hidden';
160
+ }
161
+ return ExpoNavigationBar.getVisibilityAsync();
162
+ }
163
+
164
+ /**
165
+ * Changes the navigation bar's button colors between white (`light`) and a dark gray color (`dark`).
166
+ *
167
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * NavigationBar.setButtonStyleAsync("light");
172
+ * ```
173
+ * @param style Dictates the color of the foreground element color.
174
+ */
175
+ export async function setButtonStyleAsync(style: NavigationBarButtonStyle): Promise<void> {
176
+ if (__DEV__) {
177
+ potentiallyWarnAboutEdgeToEdge(
178
+ 'Setting the navigation bar button style is not supported when edge-to-edge is enabled and may lead to unexpected behavior. Use the `setStyle` method instead.'
179
+ );
180
+ }
181
+ if (Platform.OS !== 'android') {
182
+ console.warn('`setButtonStyleAsync` is only available on Android');
183
+ return;
184
+ }
185
+ await ExpoNavigationBar.setButtonStyleAsync(style);
186
+ }
187
+
188
+ /**
189
+ * Gets the navigation bar's button color styles.
190
+ *
191
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const style = await NavigationBar.getButtonStyleAsync();
196
+ * ```
197
+ * @returns Navigation bar foreground element color settings. Returns `light` on unsupported platforms (iOS, web).
198
+ */
199
+ export async function getButtonStyleAsync(): Promise<NavigationBarButtonStyle> {
200
+ if (__DEV__) {
201
+ potentiallyWarnAboutEdgeToEdge(
202
+ 'Getting the navigation bar button style is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
203
+ );
204
+ }
205
+ if (Platform.OS !== 'android') {
206
+ console.warn('`getButtonStyleAsync` is only available on Android');
207
+ return 'light';
208
+ }
209
+ return await ExpoNavigationBar.getButtonStyleAsync();
210
+ }
211
+
212
+ /**
213
+ * Sets positioning method used for the navigation bar (and status bar).
214
+ * Setting position `absolute` will float the navigation bar above the content,
215
+ * whereas position `relative` will shrink the screen to inline the navigation bar.
216
+ *
217
+ * When drawing behind the status and navigation bars, ensure the safe area insets are adjusted accordingly.
218
+ *
219
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * // enables edge-to-edge mode
224
+ * await NavigationBar.setPositionAsync('absolute')
225
+ * // transparent backgrounds to see through
226
+ * await NavigationBar.setBackgroundColorAsync('#ffffff00')
227
+ * ```
228
+ * @param position Based on CSS position property.
229
+ */
230
+ export async function setPositionAsync(position: NavigationBarPosition): Promise<void> {
231
+ if (__DEV__) {
232
+ potentiallyWarnAboutEdgeToEdge(
233
+ 'Setting the navigation bar position is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
234
+ );
235
+ }
236
+ if (Platform.OS !== 'android') {
237
+ console.warn('`setPositionAsync` is only available on Android');
238
+ return;
239
+ }
240
+ await ExpoNavigationBar.setPositionAsync(position);
241
+ }
242
+
243
+ /**
244
+ * Whether the navigation and status bars float above the app (absolute) or sit inline with it (relative).
245
+ * This value can be incorrect if `androidNavigationBar.visible` is used instead of the config plugin `position` property.
246
+ *
247
+ * This method is unstable because the position can be set via another native module and get out of sync.
248
+ * Alternatively, you can get the position by measuring the insets returned by `react-native-safe-area-context`.
249
+ *
250
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * await NavigationBar.unstable_getPositionAsync()
255
+ * ```
256
+ * @returns Navigation bar positional rendering mode. Returns `relative` on unsupported platforms (iOS, web).
257
+ */
258
+ export async function unstable_getPositionAsync(): Promise<NavigationBarPosition> {
259
+ if (__DEV__) {
260
+ potentiallyWarnAboutEdgeToEdge(
261
+ 'Using the `unstable_getPositionAsync` function is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
262
+ );
263
+ }
264
+ if (Platform.OS !== 'android') {
265
+ console.warn('`unstable_getPositionAsync` is only available on Android');
266
+ return 'relative';
267
+ }
268
+ return await ExpoNavigationBar.unstable_getPositionAsync();
269
+ }
270
+
271
+ /**
272
+ * Sets the behavior of the status bar and navigation bar when they are hidden and the user wants to reveal them.
273
+ *
274
+ * For example, if the navigation bar is hidden (`setVisibilityAsync(false)`) and the behavior
275
+ * is `'overlay-swipe'`, the user can swipe from the bottom of the screen to temporarily reveal the navigation bar.
276
+ *
277
+ * - `'overlay-swipe'`: Temporarily reveals the System UI after a swipe gesture (bottom or top) without insetting your App's content.
278
+ * - `'inset-swipe'`: Reveals the System UI after a swipe gesture (bottom or top) and insets your App's content (Safe Area). The System UI is visible until you explicitly hide it again.
279
+ * - `'inset-touch'`: Reveals the System UI after a touch anywhere on the screen and insets your App's content (Safe Area). The System UI is visible until you explicitly hide it again.
280
+ *
281
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * await NavigationBar.setBehaviorAsync('overlay-swipe')
286
+ * ```
287
+ * @param behavior Dictates the interaction behavior of the navigation bar.
288
+ */
289
+ export async function setBehaviorAsync(behavior: NavigationBarBehavior): Promise<void> {
290
+ if (__DEV__) {
291
+ potentiallyWarnAboutEdgeToEdge(
292
+ 'Setting the behavior of the navigation bar is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
293
+ );
294
+ }
295
+ if (Platform.OS !== 'android') {
296
+ console.warn('`setBehaviorAsync` is only available on Android');
297
+ return;
298
+ }
299
+ return await ExpoNavigationBar.setBehaviorAsync(behavior);
300
+ }
301
+
302
+ /**
303
+ * Gets the behavior of the status and navigation bars when the user swipes or touches the screen.
304
+ *
305
+ * > This method is supported only when edge-to-edge is disabled. Using it in edge-to-edge app may lead to unexpected behavior.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * await NavigationBar.getBehaviorAsync()
310
+ * ```
311
+ * @returns Navigation bar interaction behavior. Returns `inset-touch` on unsupported platforms (iOS, web).
312
+ */
313
+ export async function getBehaviorAsync(): Promise<NavigationBarBehavior> {
314
+ if (__DEV__) {
315
+ potentiallyWarnAboutEdgeToEdge(
316
+ 'Getting the behavior of the navigation bar is not supported when edge-to-edge is enabled and may lead to unexpected behavior.'
317
+ );
318
+ }
319
+ if (Platform.OS !== 'android') {
320
+ console.warn('`getBehaviorAsync` is only available on Android');
321
+ return 'inset-touch';
322
+ }
323
+ return await ExpoNavigationBar.getBehaviorAsync();
324
+ }
325
+
326
+ /**
327
+ * React hook that statefully updates with the visibility of the system navigation bar.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * function App() {
332
+ * const visibility = NavigationBar.useVisibility()
333
+ * // React Component...
334
+ * }
335
+ * ```
336
+ * @returns Visibility of the navigation bar, `null` during async initialization.
337
+ */
338
+ export function useVisibility(): NavigationBarVisibility | null {
339
+ const [visibility, setVisible] = useState<NavigationBarVisibility | null>(null);
340
+
341
+ useEffect(() => {
342
+ let isMounted = true;
343
+ if (Platform.OS !== 'android') {
344
+ setVisible('hidden');
345
+ return;
346
+ }
347
+ getVisibilityAsync().then((visibility) => {
348
+ if (isMounted) {
349
+ setVisible(visibility);
350
+ }
351
+ });
352
+
353
+ const listener = addVisibilityListener(({ visibility }) => {
354
+ if (isMounted) {
355
+ setVisible(visibility);
356
+ }
357
+ });
358
+
359
+ return () => {
360
+ listener.remove();
361
+ isMounted = false;
362
+ };
363
+ }, []);
364
+
365
+ return visibility;
366
+ }