expo-navigation-bar 1.1.0 → 1.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.
- package/CHANGELOG.md +27 -0
- package/README.md +7 -7
- package/android/build.gradle +38 -25
- package/android/src/main/java/expo/modules/navigationbar/NavigationBarModule.kt +6 -6
- package/android/src/main/java/expo/modules/navigationbar/NavigationBarReactActivityLifecycleListener.kt +3 -0
- package/build/ExpoNavigationBar.d.ts +1 -0
- package/build/ExpoNavigationBar.d.ts.map +1 -0
- package/build/ExpoNavigationBar.web.d.ts +1 -0
- package/build/ExpoNavigationBar.web.d.ts.map +1 -0
- package/build/NavigationBar.d.ts +1 -0
- package/build/NavigationBar.d.ts.map +1 -0
- package/build/NavigationBar.js +23 -9
- package/build/NavigationBar.js.map +1 -1
- package/build/NavigationBar.types.d.ts +1 -0
- package/build/NavigationBar.types.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/NavigationBar.ts +24 -9
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,33 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.2.0 — 2022-04-18
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix `getVisiblilityAsync` crashing on Android 10 and older. ([#16445](https://github.com/expo/expo/pull/16445) by [@barthap](https://github.com/barthap))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- Updated `@expo/config-plugins` from `4.0.2` to `4.0.14` ([#15621](https://github.com/expo/expo/pull/15621) by [@EvanBacon](https://github.com/EvanBacon))
|
|
22
|
+
|
|
23
|
+
### ⚠️ Notices
|
|
24
|
+
|
|
25
|
+
- On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
|
|
26
|
+
|
|
27
|
+
## 1.1.2 - 2022-02-01
|
|
28
|
+
|
|
29
|
+
### 🐛 Bug fixes
|
|
30
|
+
|
|
31
|
+
- Fix `Plugin with id 'maven' not found` build error from Android Gradle 7. ([#16080](https://github.com/expo/expo/pull/16080) by [@kudo](https://github.com/kudo))
|
|
32
|
+
|
|
33
|
+
## 1.1.1 — 2021-12-08
|
|
34
|
+
|
|
35
|
+
### 🐛 Bug fixes
|
|
36
|
+
|
|
37
|
+
- Return `hidden` from `useVisibility` hook on unsupported platforms. ([#15430](https://github.com/expo/expo/pull/15430) by [@EvanBacon](https://github.com/EvanBacon))
|
|
38
|
+
- Lazily initialize emitter to allow importing the module on unsupported platforms. ([#15430](https://github.com/expo/expo/pull/15430) by [@EvanBacon](https://github.com/EvanBacon))
|
|
39
|
+
|
|
13
40
|
## 1.1.0 — 2021-12-03
|
|
14
41
|
|
|
15
42
|
### 🐛 Bug fixes
|
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@ Properties are named after style properties; visibility, position, backgroundCol
|
|
|
6
6
|
|
|
7
7
|
## API documentation
|
|
8
8
|
|
|
9
|
-
- [Documentation for the
|
|
9
|
+
- [Documentation for the main branch][docs-main]
|
|
10
10
|
- [Documentation for the latest stable release][docs-stable]
|
|
11
11
|
|
|
12
12
|
## Installation in managed Expo projects
|
|
13
13
|
|
|
14
|
-
For
|
|
14
|
+
For [managed][docs-workflows] Expo projects, please follow the installation instructions in the [API documentation for the latest stable release][docs-stable].
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
## Installation in bare React Native projects
|
|
@@ -29,9 +29,9 @@ expo install expo-navigation-bar
|
|
|
29
29
|
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][contributing].
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
[docs-main]: https://github.com/expo/expo/blob/
|
|
33
|
-
[docs-stable]: https://docs.expo.
|
|
34
|
-
[docs-workflows]: https://docs.expo.
|
|
32
|
+
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/navigation-bar.md
|
|
33
|
+
[docs-stable]: https://docs.expo.dev/versions/latest/sdk/navigation-bar/
|
|
34
|
+
[docs-workflows]: https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/
|
|
35
35
|
[contributing]: https://github.com/expo/expo#contributing
|
|
36
|
-
[unimodules]: https://github.com/expo/expo/tree/
|
|
37
|
-
[status-bar]: https://github.com/expo/expo/tree/
|
|
36
|
+
[unimodules]: https://github.com/expo/expo/tree/main/packages/react-native-unimodules
|
|
37
|
+
[status-bar]: https://github.com/expo/expo/tree/main/packages/expo-status-bar
|
package/android/build.gradle
CHANGED
|
@@ -1,67 +1,80 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
apply plugin: 'kotlin-android'
|
|
3
|
-
apply plugin: 'maven'
|
|
3
|
+
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '1.
|
|
6
|
+
version = '1.2.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
10
|
+
if (expoModulesCorePlugin.exists()) {
|
|
11
|
+
apply from: expoModulesCorePlugin
|
|
12
|
+
applyKotlinExpoModulesCorePlugin()
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
10
16
|
ext.safeExtGet = { prop, fallback ->
|
|
11
17
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
// Ensures backward compatibility
|
|
21
|
+
ext.getKotlinVersion = {
|
|
22
|
+
if (ext.has("kotlinVersion")) {
|
|
23
|
+
ext.kotlinVersion()
|
|
24
|
+
} else {
|
|
25
|
+
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
repositories {
|
|
15
30
|
mavenCentral()
|
|
16
31
|
}
|
|
17
32
|
|
|
18
33
|
dependencies {
|
|
19
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${
|
|
34
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
|
|
23
|
-
// Upload android library to maven with javadoc and android sources
|
|
24
|
-
configurations {
|
|
25
|
-
deployerJars
|
|
26
|
-
}
|
|
27
|
-
|
|
28
38
|
// Creating sources with comments
|
|
29
39
|
task androidSourcesJar(type: Jar) {
|
|
30
40
|
classifier = 'sources'
|
|
31
41
|
from android.sourceSets.main.java.srcDirs
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
afterEvaluate {
|
|
45
|
+
publishing {
|
|
46
|
+
publications {
|
|
47
|
+
release(MavenPublication) {
|
|
48
|
+
from components.release
|
|
49
|
+
// Add additional sourcesJar to artifacts
|
|
50
|
+
artifact(androidSourcesJar)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
repositories {
|
|
54
|
+
maven {
|
|
55
|
+
url = mavenLocal().url
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
android {
|
|
49
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
62
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 31)
|
|
50
63
|
|
|
51
64
|
compileOptions {
|
|
52
|
-
sourceCompatibility JavaVersion.
|
|
53
|
-
targetCompatibility JavaVersion.
|
|
65
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
66
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
kotlinOptions {
|
|
57
|
-
jvmTarget = JavaVersion.
|
|
70
|
+
jvmTarget = JavaVersion.VERSION_11.majorVersion
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
defaultConfig {
|
|
61
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
62
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
75
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
63
76
|
versionCode 1
|
|
64
|
-
versionName '1.
|
|
77
|
+
versionName '1.2.0'
|
|
65
78
|
}
|
|
66
79
|
lintOptions {
|
|
67
80
|
abortOnError false
|
|
@@ -71,7 +84,7 @@ android {
|
|
|
71
84
|
dependencies {
|
|
72
85
|
implementation project(':expo-modules-core')
|
|
73
86
|
|
|
74
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${
|
|
87
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
75
88
|
implementation 'androidx.core:core:1.6.0'
|
|
76
89
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
|
77
90
|
}
|
|
@@ -111,14 +111,14 @@ class NavigationBarModule(context: Context) : ExportedModule(context) {
|
|
|
111
111
|
@ExpoMethod
|
|
112
112
|
fun getVisibilityAsync(promise: Promise) {
|
|
113
113
|
safeRunOnUiThread(promise) {
|
|
114
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.
|
|
115
|
-
|
|
116
|
-
promise.resolve(visibility)
|
|
114
|
+
val isVisible = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
115
|
+
it.window.decorView.rootWindowInsets.isVisible(WindowInsets.Type.navigationBars())
|
|
117
116
|
} else {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
promise.resolve(visibility)
|
|
117
|
+
@Suppress("DEPRECATION")
|
|
118
|
+
(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION and it.window.decorView.systemUiVisibility) == 0
|
|
121
119
|
}
|
|
120
|
+
val visibility = if (isVisible) "visible" else "hidden"
|
|
121
|
+
promise.resolve(visibility)
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -6,6 +6,9 @@ import android.os.Bundle
|
|
|
6
6
|
import android.util.Log
|
|
7
7
|
import expo.modules.core.interfaces.ReactActivityLifecycleListener
|
|
8
8
|
|
|
9
|
+
// this needs to stay for versioning to work
|
|
10
|
+
// EXPO_VERSIONING_NEEDS_EXPOVIEW_R
|
|
11
|
+
|
|
9
12
|
class NavigationBarReactActivityLifecycleListener(activityContext: Context) : ReactActivityLifecycleListener {
|
|
10
13
|
override fun onCreate(activity: Activity, savedInstanceState: Bundle?) {
|
|
11
14
|
// Execute static tasks before the JS engine starts.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNavigationBar.d.ts","sourceRoot":"","sources":["../src/ExpoNavigationBar.ts"],"names":[],"mappings":";AAEA,wBAA0D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoNavigationBar.web.d.ts","sourceRoot":"","sources":["../src/ExpoNavigationBar.web.ts"],"names":[],"mappings":";;;AAAA,wBAIE"}
|
package/build/NavigationBar.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationBar.d.ts","sourceRoot":"","sources":["../src/NavigationBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAGxD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAa/B;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,GACtD,YAAY,CAMd;AAED;;;;;;;;GAQG;AACH,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|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { EventEmitter, Platform } from 'expo-modules-core';
|
|
1
|
+
import { EventEmitter, Platform, UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { processColor } from 'react-native';
|
|
4
4
|
import ExpoNavigationBar from './ExpoNavigationBar';
|
|
5
|
-
|
|
5
|
+
let _emitter;
|
|
6
|
+
// Lazily initialize the event emitter because it isn't available on iOS,
|
|
7
|
+
// this enables us to use the same code for all platforms.
|
|
8
|
+
function getEmitter() {
|
|
9
|
+
if (!_emitter) {
|
|
10
|
+
_emitter = new EventEmitter(ExpoNavigationBar);
|
|
11
|
+
}
|
|
12
|
+
return _emitter;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Observe changes to the system navigation bar.
|
|
8
16
|
* Due to platform constraints, this callback will also be triggered when the status bar visibility changes.
|
|
@@ -15,7 +23,11 @@ const emitter = new EventEmitter(ExpoNavigationBar);
|
|
|
15
23
|
* ```
|
|
16
24
|
*/
|
|
17
25
|
export function addVisibilityListener(listener) {
|
|
18
|
-
|
|
26
|
+
// Assert so the type is non-nullable.
|
|
27
|
+
if (!ExpoNavigationBar.addListener) {
|
|
28
|
+
throw new UnavailabilityError('NavigationBar', 'addVisibilityListener');
|
|
29
|
+
}
|
|
30
|
+
return getEmitter().addListener('ExpoNavigationBar.didChange', listener);
|
|
19
31
|
}
|
|
20
32
|
/**
|
|
21
33
|
* Changes the navigation bar's background color.
|
|
@@ -245,13 +257,15 @@ export function useVisibility() {
|
|
|
245
257
|
const [visibility, setVisible] = useState(null);
|
|
246
258
|
useEffect(() => {
|
|
247
259
|
let isMounted = true;
|
|
248
|
-
if (Platform.OS
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
setVisible(visibility);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
260
|
+
if (Platform.OS !== 'android') {
|
|
261
|
+
setVisible('hidden');
|
|
262
|
+
return;
|
|
254
263
|
}
|
|
264
|
+
getVisibilityAsync().then((visibility) => {
|
|
265
|
+
if (isMounted) {
|
|
266
|
+
setVisible(visibility);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
255
269
|
const listener = addVisibilityListener(({ visibility }) => {
|
|
256
270
|
if (isMounted) {
|
|
257
271
|
setVisible(visibility);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationBar.js","sourceRoot":"","sources":["../src/NavigationBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AASpD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAuD;IAEvD,OAAO,OAAO,CAAC,WAAW,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,KAAiB;IAC7D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACxC,OAAO,MAAM,iBAAiB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO,WAAW,CAAC;K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QG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAChE,OAAO,aAAa,CAAC;KACtB;IACD,OAAO,MAAM,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiC,IAAI,CAAC,CAAC;IAEhF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;YAC7B,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;gBACvC,IAAI,SAAS,EAAE;oBACb,UAAU,CAAC,UAAU,CAAC,CAAC;iBACxB;YACH,CAAC,CAAC,CAAC;SACJ;QAED,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;YACxD,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,UAAU,CAAC,CAAC;aACxB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,cAAc,uBAAuB,CAAC","sourcesContent":["import { EventEmitter, Platform, Subscription } from 'expo-modules-core';\nimport { useEffect, useState } from 'react';\nimport { ColorValue, processColor } from 'react-native';\n\nimport ExpoNavigationBar from './ExpoNavigationBar';\nimport {\n NavigationBarButtonStyle,\n NavigationBarBehavior,\n NavigationBarPosition,\n NavigationBarVisibility,\n NavigationBarVisibilityEvent,\n} from './NavigationBar.types';\n\nconst emitter = new EventEmitter(ExpoNavigationBar);\n\n/**\n * Observe changes to the system navigation bar.\n * Due to platform constraints, this callback will also be triggered when the status bar visibility changes.\n *\n * @example\n * ```ts\n * NavigationBar.addVisibilityListener(({ visibility }) => {\n * // ...\n * });\n * ```\n */\nexport function addVisibilityListener(\n listener: (event: NavigationBarVisibilityEvent) => void\n): Subscription {\n return emitter.addListener('ExpoNavigationBar.didChange', listener);\n}\n\n/**\n * Changes the navigation bar's background color.\n *\n * @example\n * ```ts\n * NavigationBar.setBackgroundColorAsync(\"white\");\n * ```\n * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).\n */\nexport async function setBackgroundColorAsync(color: ColorValue): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBackgroundColorAsync` is only available on Android');\n return;\n }\n const colorNumber = processColor(color);\n return await ExpoNavigationBar.setBackgroundColorAsync(colorNumber);\n}\n\n/**\n * Gets the navigation bar's background color.\n *\n * @example\n * ```ts\n * const color = await NavigationBar.getBackgroundColorAsync();\n * ```\n * @returns Current navigation bar color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).\n */\nexport async function getBackgroundColorAsync(): Promise<ColorValue> {\n if (Platform.OS !== 'android') {\n console.warn('`getBackgroundColorAsync` is only available on Android');\n return `#00000000`;\n }\n return await ExpoNavigationBar.getBackgroundColorAsync();\n}\n\n/**\n * Changes the navigation bar's border color.\n *\n * @example\n * ```ts\n * NavigationBar.setBorderColorAsync(\"red\");\n * ```\n * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).\n */\nexport async function setBorderColorAsync(color: ColorValue): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBorderColorAsync` is only available on Android');\n return;\n }\n const colorNumber = processColor(color);\n await ExpoNavigationBar.setBorderColorAsync(colorNumber);\n}\n\n/**\n * Gets the navigation bar's top border color, also known as the \"divider color\".\n *\n * @example\n * ```ts\n * const color = await NavigationBar.getBorderColorAsync();\n * ```\n * @returns Navigation bar top border color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).\n */\nexport async function getBorderColorAsync(): Promise<ColorValue> {\n if (Platform.OS !== 'android') {\n console.warn('`getBorderColorAsync` is only available on Android');\n return `#00000000`;\n }\n\n return await ExpoNavigationBar.getBorderColorAsync();\n}\n\n/**\n * Set the navigation bar's visibility.\n *\n * @example\n * ```ts\n * NavigationBar.setVisibilityAsync(\"hidden\");\n * ```\n * @param color Based on CSS visibility property.\n */\nexport async function setVisibilityAsync(visibility: NavigationBarVisibility): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setVisibilityAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setVisibilityAsync(visibility);\n}\n\n/**\n * Get the navigation bar's visibility.\n *\n * @example\n * ```ts\n * const visibility = await NavigationBar.getVisibilityAsync(\"hidden\");\n * ```\n * @returns Navigation bar's current visibility status. Returns `hidden` on unsupported platforms (iOS, web).\n */\nexport async function getVisibilityAsync(): Promise<NavigationBarVisibility> {\n if (Platform.OS !== 'android') {\n console.warn('`getVisibilityAsync` is only available on Android');\n return 'hidden';\n }\n return ExpoNavigationBar.getVisibilityAsync();\n}\n\n/**\n * Changes the navigation bar's button colors between white (`light`) and a dark gray color (`dark`).\n *\n * @example\n * ```ts\n * NavigationBar.setButtonStyleAsync(\"light\");\n * ```\n * @param style Dictates the color of the foreground element color.\n */\nexport async function setButtonStyleAsync(style: NavigationBarButtonStyle): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setButtonStyleAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setButtonStyleAsync(style);\n}\n\n/**\n * Gets the navigation bar's button color styles.\n *\n * @example\n * ```ts\n * const style = await NavigationBar.getButtonStyleAsync();\n * ```\n * @returns Navigation bar foreground element color settings. Returns `light` on unsupported platforms (iOS, web).\n */\nexport async function getButtonStyleAsync(): Promise<NavigationBarButtonStyle> {\n if (Platform.OS !== 'android') {\n console.warn('`getButtonStyleAsync` is only available on Android');\n return 'light';\n }\n return await ExpoNavigationBar.getButtonStyleAsync();\n}\n\n/**\n * Sets positioning method used for the navigation bar (and status bar).\n * Setting position `absolute` will float the navigation bar above the content,\n * whereas position `relative` will shrink the screen to inline the navigation bar.\n *\n * When drawing behind the status and navigation bars, ensure the safe area insets are adjusted accordingly.\n *\n * @example\n * ```ts\n * // enables edge-to-edge mode\n * await NavigationBar.setPositionAsync('absolute')\n * // transparent backgrounds to see through\n * await NavigationBar.setBackgroundColorAsync('#ffffff00')\n * ```\n * @param position Based on CSS position property.\n */\nexport async function setPositionAsync(position: NavigationBarPosition): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setPositionAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setPositionAsync(position);\n}\n\n/**\n * Whether the navigation and status bars float above the app (absolute) or sit inline with it (relative).\n * This value can be incorrect if `androidNavigationBar.visible` is used instead of the config plugin `position` property.\n *\n * This method is unstable because the position can be set via another native module and get out of sync.\n * Alternatively, you can get the position by measuring the insets returned by `react-native-safe-area-context`.\n *\n * @example\n * ```ts\n * await NavigationBar.unstable_getPositionAsync()\n * ```\n * @returns Navigation bar positional rendering mode. Returns `relative` on unsupported platforms (iOS, web).\n */\nexport async function unstable_getPositionAsync(): Promise<NavigationBarPosition> {\n if (Platform.OS !== 'android') {\n console.warn('`unstable_getPositionAsync` is only available on Android');\n return 'relative';\n }\n return await ExpoNavigationBar.unstable_getPositionAsync();\n}\n\n/**\n * Sets the behavior of the status bar and navigation bar when they are hidden and the user wants to reveal them.\n *\n * For example, if the navigation bar is hidden (`setVisibilityAsync(false)`) and the behavior\n * is `'overlay-swipe'`, the user can swipe from the bottom of the screen to temporarily reveal the navigation bar.\n *\n * - `'overlay-swipe'`: Temporarily reveals the System UI after a swipe gesture (bottom or top) without insetting your App's content.\n * - `'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.\n * - `'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.\n *\n * @example\n * ```ts\n * await NavigationBar.setBehaviorAsync('overlay-swipe')\n * ```\n * @param behavior Dictates the interaction behavior of the navigation bar.\n */\nexport async function setBehaviorAsync(behavior: NavigationBarBehavior): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBehaviorAsync` is only available on Android');\n return;\n }\n return await ExpoNavigationBar.setBehaviorAsync(behavior);\n}\n\n/**\n * Gets the behavior of the status and navigation bars when the user swipes or touches the screen.\n *\n * @example\n * ```ts\n * await NavigationBar.getBehaviorAsync()\n * ```\n * @returns Navigation bar interaction behavior. Returns `inset-touch` on unsupported platforms (iOS, web).\n */\nexport async function getBehaviorAsync(): Promise<NavigationBarBehavior> {\n if (Platform.OS !== 'android') {\n console.warn('`getBehaviorAsync` is only available on Android');\n return 'inset-touch';\n }\n return await ExpoNavigationBar.getBehaviorAsync();\n}\n\n/**\n * React hook that statefully updates with the visibility of the system navigation bar.\n *\n * @example\n * ```ts\n * function App() {\n * const visibility = NavigationBar.useVisibility()\n * // React Component...\n * }\n * ```\n * @returns Visibility of the navigation bar, `null` during async initialization.\n */\nexport function useVisibility(): NavigationBarVisibility | null {\n const [visibility, setVisible] = useState<NavigationBarVisibility | null>(null);\n\n useEffect(() => {\n let isMounted = true;\n if (Platform.OS === 'android') {\n getVisibilityAsync().then((visibility) => {\n if (isMounted) {\n setVisible(visibility);\n }\n });\n }\n\n const listener = addVisibilityListener(({ visibility }) => {\n if (isMounted) {\n setVisible(visibility);\n }\n });\n\n return () => {\n listener.remove();\n isMounted = false;\n };\n }, []);\n\n return visibility;\n}\n\nexport * from './NavigationBar.types';\n"]}
|
|
1
|
+
{"version":3,"file":"NavigationBar.js","sourceRoot":"","sources":["../src/NavigationBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,mBAAmB,EAAE,MAAM,mBAA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,EAAE;QAC7B,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAChE,OAAO,aAAa,CAAC;KACtB;IACD,OAAO,MAAM,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiC,IAAI,CAAC,CAAC;IAEhF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;YAC7B,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrB,OAAO;SACR;QACD,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YACvC,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,UAAU,CAAC,CAAC;aACxB;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;YACxD,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,UAAU,CAAC,CAAC;aACxB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,cAAc,uBAAuB,CAAC","sourcesContent":["import { EventEmitter, Platform, Subscription, UnavailabilityError } from 'expo-modules-core';\nimport { useEffect, useState } from 'react';\nimport { ColorValue, processColor } from 'react-native';\n\nimport ExpoNavigationBar from './ExpoNavigationBar';\nimport {\n NavigationBarButtonStyle,\n NavigationBarBehavior,\n NavigationBarPosition,\n NavigationBarVisibility,\n NavigationBarVisibilityEvent,\n} from './NavigationBar.types';\n\nlet _emitter: EventEmitter;\n\n// Lazily initialize the event emitter because it isn't available on iOS,\n// this enables us to use the same code for all platforms.\nfunction getEmitter() {\n if (!_emitter) {\n _emitter = new EventEmitter(ExpoNavigationBar);\n }\n return _emitter;\n}\n\n/**\n * Observe changes to the system navigation bar.\n * Due to platform constraints, this callback will also be triggered when the status bar visibility changes.\n *\n * @example\n * ```ts\n * NavigationBar.addVisibilityListener(({ visibility }) => {\n * // ...\n * });\n * ```\n */\nexport function addVisibilityListener(\n listener: (event: NavigationBarVisibilityEvent) => void\n): Subscription {\n // Assert so the type is non-nullable.\n if (!ExpoNavigationBar.addListener) {\n throw new UnavailabilityError('NavigationBar', 'addVisibilityListener');\n }\n return getEmitter().addListener('ExpoNavigationBar.didChange', listener);\n}\n\n/**\n * Changes the navigation bar's background color.\n *\n * @example\n * ```ts\n * NavigationBar.setBackgroundColorAsync(\"white\");\n * ```\n * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).\n */\nexport async function setBackgroundColorAsync(color: ColorValue): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBackgroundColorAsync` is only available on Android');\n return;\n }\n const colorNumber = processColor(color);\n return await ExpoNavigationBar.setBackgroundColorAsync(colorNumber);\n}\n\n/**\n * Gets the navigation bar's background color.\n *\n * @example\n * ```ts\n * const color = await NavigationBar.getBackgroundColorAsync();\n * ```\n * @returns Current navigation bar color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).\n */\nexport async function getBackgroundColorAsync(): Promise<ColorValue> {\n if (Platform.OS !== 'android') {\n console.warn('`getBackgroundColorAsync` is only available on Android');\n return `#00000000`;\n }\n return await ExpoNavigationBar.getBackgroundColorAsync();\n}\n\n/**\n * Changes the navigation bar's border color.\n *\n * @example\n * ```ts\n * NavigationBar.setBorderColorAsync(\"red\");\n * ```\n * @param color Any valid [CSS 3 (SVG) color](http://www.w3.org/TR/css3-color/#svg-color).\n */\nexport async function setBorderColorAsync(color: ColorValue): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBorderColorAsync` is only available on Android');\n return;\n }\n const colorNumber = processColor(color);\n await ExpoNavigationBar.setBorderColorAsync(colorNumber);\n}\n\n/**\n * Gets the navigation bar's top border color, also known as the \"divider color\".\n *\n * @example\n * ```ts\n * const color = await NavigationBar.getBorderColorAsync();\n * ```\n * @returns Navigation bar top border color in hex format. Returns `#00000000` (transparent) on unsupported platforms (iOS, web).\n */\nexport async function getBorderColorAsync(): Promise<ColorValue> {\n if (Platform.OS !== 'android') {\n console.warn('`getBorderColorAsync` is only available on Android');\n return `#00000000`;\n }\n\n return await ExpoNavigationBar.getBorderColorAsync();\n}\n\n/**\n * Set the navigation bar's visibility.\n *\n * @example\n * ```ts\n * NavigationBar.setVisibilityAsync(\"hidden\");\n * ```\n * @param color Based on CSS visibility property.\n */\nexport async function setVisibilityAsync(visibility: NavigationBarVisibility): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setVisibilityAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setVisibilityAsync(visibility);\n}\n\n/**\n * Get the navigation bar's visibility.\n *\n * @example\n * ```ts\n * const visibility = await NavigationBar.getVisibilityAsync(\"hidden\");\n * ```\n * @returns Navigation bar's current visibility status. Returns `hidden` on unsupported platforms (iOS, web).\n */\nexport async function getVisibilityAsync(): Promise<NavigationBarVisibility> {\n if (Platform.OS !== 'android') {\n console.warn('`getVisibilityAsync` is only available on Android');\n return 'hidden';\n }\n return ExpoNavigationBar.getVisibilityAsync();\n}\n\n/**\n * Changes the navigation bar's button colors between white (`light`) and a dark gray color (`dark`).\n *\n * @example\n * ```ts\n * NavigationBar.setButtonStyleAsync(\"light\");\n * ```\n * @param style Dictates the color of the foreground element color.\n */\nexport async function setButtonStyleAsync(style: NavigationBarButtonStyle): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setButtonStyleAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setButtonStyleAsync(style);\n}\n\n/**\n * Gets the navigation bar's button color styles.\n *\n * @example\n * ```ts\n * const style = await NavigationBar.getButtonStyleAsync();\n * ```\n * @returns Navigation bar foreground element color settings. Returns `light` on unsupported platforms (iOS, web).\n */\nexport async function getButtonStyleAsync(): Promise<NavigationBarButtonStyle> {\n if (Platform.OS !== 'android') {\n console.warn('`getButtonStyleAsync` is only available on Android');\n return 'light';\n }\n return await ExpoNavigationBar.getButtonStyleAsync();\n}\n\n/**\n * Sets positioning method used for the navigation bar (and status bar).\n * Setting position `absolute` will float the navigation bar above the content,\n * whereas position `relative` will shrink the screen to inline the navigation bar.\n *\n * When drawing behind the status and navigation bars, ensure the safe area insets are adjusted accordingly.\n *\n * @example\n * ```ts\n * // enables edge-to-edge mode\n * await NavigationBar.setPositionAsync('absolute')\n * // transparent backgrounds to see through\n * await NavigationBar.setBackgroundColorAsync('#ffffff00')\n * ```\n * @param position Based on CSS position property.\n */\nexport async function setPositionAsync(position: NavigationBarPosition): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setPositionAsync` is only available on Android');\n return;\n }\n await ExpoNavigationBar.setPositionAsync(position);\n}\n\n/**\n * Whether the navigation and status bars float above the app (absolute) or sit inline with it (relative).\n * This value can be incorrect if `androidNavigationBar.visible` is used instead of the config plugin `position` property.\n *\n * This method is unstable because the position can be set via another native module and get out of sync.\n * Alternatively, you can get the position by measuring the insets returned by `react-native-safe-area-context`.\n *\n * @example\n * ```ts\n * await NavigationBar.unstable_getPositionAsync()\n * ```\n * @returns Navigation bar positional rendering mode. Returns `relative` on unsupported platforms (iOS, web).\n */\nexport async function unstable_getPositionAsync(): Promise<NavigationBarPosition> {\n if (Platform.OS !== 'android') {\n console.warn('`unstable_getPositionAsync` is only available on Android');\n return 'relative';\n }\n return await ExpoNavigationBar.unstable_getPositionAsync();\n}\n\n/**\n * Sets the behavior of the status bar and navigation bar when they are hidden and the user wants to reveal them.\n *\n * For example, if the navigation bar is hidden (`setVisibilityAsync(false)`) and the behavior\n * is `'overlay-swipe'`, the user can swipe from the bottom of the screen to temporarily reveal the navigation bar.\n *\n * - `'overlay-swipe'`: Temporarily reveals the System UI after a swipe gesture (bottom or top) without insetting your App's content.\n * - `'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.\n * - `'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.\n *\n * @example\n * ```ts\n * await NavigationBar.setBehaviorAsync('overlay-swipe')\n * ```\n * @param behavior Dictates the interaction behavior of the navigation bar.\n */\nexport async function setBehaviorAsync(behavior: NavigationBarBehavior): Promise<void> {\n if (Platform.OS !== 'android') {\n console.warn('`setBehaviorAsync` is only available on Android');\n return;\n }\n return await ExpoNavigationBar.setBehaviorAsync(behavior);\n}\n\n/**\n * Gets the behavior of the status and navigation bars when the user swipes or touches the screen.\n *\n * @example\n * ```ts\n * await NavigationBar.getBehaviorAsync()\n * ```\n * @returns Navigation bar interaction behavior. Returns `inset-touch` on unsupported platforms (iOS, web).\n */\nexport async function getBehaviorAsync(): Promise<NavigationBarBehavior> {\n if (Platform.OS !== 'android') {\n console.warn('`getBehaviorAsync` is only available on Android');\n return 'inset-touch';\n }\n return await ExpoNavigationBar.getBehaviorAsync();\n}\n\n/**\n * React hook that statefully updates with the visibility of the system navigation bar.\n *\n * @example\n * ```ts\n * function App() {\n * const visibility = NavigationBar.useVisibility()\n * // React Component...\n * }\n * ```\n * @returns Visibility of the navigation bar, `null` during async initialization.\n */\nexport function useVisibility(): NavigationBarVisibility | null {\n const [visibility, setVisible] = useState<NavigationBarVisibility | null>(null);\n\n useEffect(() => {\n let isMounted = true;\n if (Platform.OS !== 'android') {\n setVisible('hidden');\n return;\n }\n getVisibilityAsync().then((visibility) => {\n if (isMounted) {\n setVisible(visibility);\n }\n });\n\n const listener = addVisibilityListener(({ visibility }) => {\n if (isMounted) {\n setVisible(visibility);\n }\n });\n\n return () => {\n listener.remove();\n isMounted = false;\n };\n }, []);\n\n return visibility;\n}\n\nexport * from './NavigationBar.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationBar.types.d.ts","sourceRoot":"","sources":["../src/NavigationBar.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,wBAAwB,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD;;GAEG;AACH,oBAAY,uBAAuB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D;;GAEG;AACH,oBAAY,qBAAqB,GAAG,eAAe,GAAG,aAAa,GAAG,aAAa,CAAC;AAEpF;;GAEG;AACH,oBAAY,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D;;GAEG;AACH,oBAAY,4BAA4B,GAAG;IACzC;;OAEG;IACH,UAAU,EAAE,uBAAuB,CAAC;IACpC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-navigation-bar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Interact with the system navigation bar",
|
|
5
5
|
"main": "build/NavigationBar.js",
|
|
6
6
|
"types": "build/NavigationBar.d.ts",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"author": "650 Industries, Inc.",
|
|
33
33
|
"license": "MIT",
|
|
34
|
-
"homepage": "https://docs.expo.
|
|
34
|
+
"homepage": "https://docs.expo.dev/versions/latest/sdk/navigation-bar",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@expo/config-plugins": "^4.0.
|
|
36
|
+
"@expo/config-plugins": "^4.0.14",
|
|
37
37
|
"@react-native/normalize-color": "^2.0.0",
|
|
38
38
|
"debug": "^4.3.2"
|
|
39
39
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"expo": "*"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "22dce752354bb429c84851bc4389abe47a766b1f"
|
|
48
48
|
}
|
package/src/NavigationBar.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventEmitter, Platform, Subscription } from 'expo-modules-core';
|
|
1
|
+
import { EventEmitter, Platform, Subscription, UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { ColorValue, processColor } from 'react-native';
|
|
4
4
|
|
|
@@ -11,7 +11,16 @@ import {
|
|
|
11
11
|
NavigationBarVisibilityEvent,
|
|
12
12
|
} from './NavigationBar.types';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
let _emitter: EventEmitter;
|
|
15
|
+
|
|
16
|
+
// Lazily initialize the event emitter because it isn't available on iOS,
|
|
17
|
+
// this enables us to use the same code for all platforms.
|
|
18
|
+
function getEmitter() {
|
|
19
|
+
if (!_emitter) {
|
|
20
|
+
_emitter = new EventEmitter(ExpoNavigationBar);
|
|
21
|
+
}
|
|
22
|
+
return _emitter;
|
|
23
|
+
}
|
|
15
24
|
|
|
16
25
|
/**
|
|
17
26
|
* Observe changes to the system navigation bar.
|
|
@@ -27,7 +36,11 @@ const emitter = new EventEmitter(ExpoNavigationBar);
|
|
|
27
36
|
export function addVisibilityListener(
|
|
28
37
|
listener: (event: NavigationBarVisibilityEvent) => void
|
|
29
38
|
): Subscription {
|
|
30
|
-
|
|
39
|
+
// Assert so the type is non-nullable.
|
|
40
|
+
if (!ExpoNavigationBar.addListener) {
|
|
41
|
+
throw new UnavailabilityError('NavigationBar', 'addVisibilityListener');
|
|
42
|
+
}
|
|
43
|
+
return getEmitter().addListener('ExpoNavigationBar.didChange', listener);
|
|
31
44
|
}
|
|
32
45
|
|
|
33
46
|
/**
|
|
@@ -272,13 +285,15 @@ export function useVisibility(): NavigationBarVisibility | null {
|
|
|
272
285
|
|
|
273
286
|
useEffect(() => {
|
|
274
287
|
let isMounted = true;
|
|
275
|
-
if (Platform.OS
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
setVisible(visibility);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
288
|
+
if (Platform.OS !== 'android') {
|
|
289
|
+
setVisible('hidden');
|
|
290
|
+
return;
|
|
281
291
|
}
|
|
292
|
+
getVisibilityAsync().then((visibility) => {
|
|
293
|
+
if (isMounted) {
|
|
294
|
+
setVisible(visibility);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
282
297
|
|
|
283
298
|
const listener = addVisibilityListener(({ visibility }) => {
|
|
284
299
|
if (isMounted) {
|