expo-navigation-bar 2.8.1 → 3.0.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 CHANGED
@@ -10,7 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 2.8.12023-12-19
13
+ ## 3.0.02024-04-18
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix event listeners on Android. ([#28260](https://github.com/expo/expo/pull/28260) by [@gabrieldonadel](https://github.com/gabrieldonadel))
18
+
19
+ ### 💡 Others
20
+
21
+ - Migrated dependency from `@react-native/normalize-color` to `@react-native/normalize-colors`. ([#27736](https://github.com/expo/expo/pull/27736) by [@kudo](https://github.com/kudo))
22
+ - Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
23
+
24
+ ## 2.8.1 - 2023-12-19
14
25
 
15
26
  _This version does not introduce any user-facing changes._
16
27
 
@@ -1,110 +1,24 @@
1
1
  apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
2
 
5
3
  group = 'host.exp.exponent'
6
- version = '2.8.1'
4
+ version = '3.0.0'
7
5
 
8
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
- if (expoModulesCorePlugin.exists()) {
10
- apply from: expoModulesCorePlugin
11
- applyKotlinExpoModulesCorePlugin()
12
- // Remove this check, but keep the contents after SDK49 support is dropped
13
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
- useExpoPublishing()
15
- useCoreDependencies()
16
- }
17
- }
18
-
19
- buildscript {
20
- // Simple helper that allows the root project to override versions declared by this library.
21
- ext.safeExtGet = { prop, fallback ->
22
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
- }
24
-
25
- // Ensures backward compatibility
26
- ext.getKotlinVersion = {
27
- if (ext.has("kotlinVersion")) {
28
- ext.kotlinVersion()
29
- } else {
30
- ext.safeExtGet("kotlinVersion", "1.8.10")
31
- }
32
- }
33
-
34
- repositories {
35
- mavenCentral()
36
- }
37
-
38
- dependencies {
39
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
- }
41
- }
42
-
43
- // Remove this if and it's contents, when support for SDK49 is dropped
44
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
- }
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useDefaultAndroidSdkVersions()
11
+ useExpoPublishing()
60
12
 
61
13
  android {
62
- // Remove this if and it's contents, when support for SDK49 is dropped
63
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
- compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
-
66
- defaultConfig {
67
- minSdkVersion safeExtGet("minSdkVersion", 23)
68
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
- }
70
-
71
- publishing {
72
- singleVariant("release") {
73
- withSourcesJar()
74
- }
75
- }
76
-
77
- lintOptions {
78
- abortOnError false
79
- }
80
- }
81
-
82
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
- compileOptions {
85
- sourceCompatibility JavaVersion.VERSION_11
86
- targetCompatibility JavaVersion.VERSION_11
87
- }
88
-
89
- kotlinOptions {
90
- jvmTarget = JavaVersion.VERSION_11.majorVersion
91
- }
92
- }
93
-
94
14
  namespace "expo.modules.navigationbar"
95
15
  defaultConfig {
96
16
  versionCode 1
97
- versionName '2.8.1'
17
+ versionName '3.0.0'
98
18
  }
99
19
  }
100
20
 
101
21
  dependencies {
102
- // Remove this if and it's contents, when support for SDK49 is dropped
103
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
- implementation project(':expo-modules-core')
105
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
- }
107
-
108
22
  implementation 'androidx.core:core:1.6.0'
109
23
  implementation 'androidx.appcompat:appcompat:1.2.0'
110
24
  }
@@ -24,11 +24,37 @@ class NavigationBarModule : Module() {
24
24
 
25
25
  Events(VISIBILITY_EVENT_NAME)
26
26
 
27
+ OnStartObserving {
28
+ val decorView = activity.window.decorView
29
+ decorView.post {
30
+ @Suppress("DEPRECATION")
31
+ decorView.setOnSystemUiVisibilityChangeListener { visibility: Int ->
32
+ val isNavigationBarVisible = (visibility and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0
33
+ val stringVisibility = if (isNavigationBarVisible) "visible" else "hidden"
34
+ sendEvent(
35
+ VISIBILITY_EVENT_NAME,
36
+ Bundle().apply {
37
+ putString("visibility", stringVisibility)
38
+ putInt("rawVisibility", visibility)
39
+ }
40
+ )
41
+ }
42
+ }
43
+ }
44
+
45
+ OnStopObserving {
46
+ val decorView = activity.window.decorView
47
+ decorView.post {
48
+ @Suppress("DEPRECATION")
49
+ decorView.setOnSystemUiVisibilityChangeListener(null)
50
+ }
51
+ }
52
+
27
53
  AsyncFunction("setBackgroundColorAsync") { color: Int, promise: Promise ->
28
54
  NavigationBar.setBackgroundColor(activity, color, { promise.resolve(null) }, { m -> promise.reject(NavigationBarException(m)) })
29
55
  }.runOnQueue(Queues.MAIN)
30
56
 
31
- AsyncFunction("getBackgroundColorAsync") {
57
+ AsyncFunction<String>("getBackgroundColorAsync") {
32
58
  return@AsyncFunction colorToHex(activity.window.navigationBarColor)
33
59
  }.runOnQueue(Queues.MAIN)
34
60
 
@@ -36,7 +62,7 @@ class NavigationBarModule : Module() {
36
62
  NavigationBar.setBorderColor(activity, color, { promise.resolve(null) }, { m -> promise.reject(NavigationBarException(m)) })
37
63
  }.runOnQueue(Queues.MAIN)
38
64
 
39
- AsyncFunction("getBorderColorAsync") {
65
+ AsyncFunction<String>("getBorderColorAsync") {
40
66
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
41
67
  return@AsyncFunction colorToHex(activity.window.navigationBarDividerColor)
42
68
  } else {
@@ -55,7 +81,7 @@ class NavigationBarModule : Module() {
55
81
  )
56
82
  }.runOnQueue(Queues.MAIN)
57
83
 
58
- AsyncFunction("getButtonStyleAsync") {
84
+ AsyncFunction<String>("getButtonStyleAsync") {
59
85
  WindowInsetsControllerCompat(activity.window, activity.window.decorView).let { controller ->
60
86
  return@AsyncFunction if (controller.isAppearanceLightNavigationBars) "dark" else "light"
61
87
  }
@@ -65,7 +91,7 @@ class NavigationBarModule : Module() {
65
91
  NavigationBar.setVisibility(activity, visibility, { promise.resolve(null) }, { m -> promise.reject(NavigationBarException(m)) })
66
92
  }.runOnQueue(Queues.MAIN)
67
93
 
68
- AsyncFunction("getVisibilityAsync") {
94
+ AsyncFunction<String>("getVisibilityAsync") {
69
95
  val isVisible = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
70
96
  activity.window.decorView.rootWindowInsets.isVisible(WindowInsets.Type.navigationBars())
71
97
  } else {
@@ -79,7 +105,7 @@ class NavigationBarModule : Module() {
79
105
  NavigationBar.setPosition(activity, position, { promise.resolve(null) }, { m -> promise.reject(NavigationBarException(m)) })
80
106
  }.runOnQueue(Queues.MAIN)
81
107
 
82
- AsyncFunction("unstable_getPositionAsync") {
108
+ AsyncFunction<String>("unstable_getPositionAsync") {
83
109
  return@AsyncFunction if (ViewCompat.getFitsSystemWindows(activity.window.decorView)) "relative" else "absolute"
84
110
  }.runOnQueue(Queues.MAIN)
85
111
 
@@ -87,7 +113,7 @@ class NavigationBarModule : Module() {
87
113
  NavigationBar.setBehavior(activity, behavior, { promise.resolve(null) }, { m -> promise.reject(NavigationBarException(m)) })
88
114
  }.runOnQueue(Queues.MAIN)
89
115
 
90
- AsyncFunction("getBehaviorAsync") {
116
+ AsyncFunction<String>("getBehaviorAsync") {
91
117
  WindowInsetsControllerCompat(activity.window, activity.window.decorView).let { controller ->
92
118
  val behavior = when (controller.systemBarsBehavior) {
93
119
  // TODO: Maybe relative / absolute
@@ -100,30 +126,6 @@ class NavigationBarModule : Module() {
100
126
  return@AsyncFunction behavior
101
127
  }
102
128
  }.runOnQueue(Queues.MAIN)
103
-
104
- // We are not using `OnStartObserving` and `OnStopObserving` here because when switching threads
105
- // they will resolve the promise quicker and the JS won't wait for observer removal
106
- AsyncFunction("startObserving") {
107
- val decorView = activity.window.decorView
108
- @Suppress("DEPRECATION")
109
- decorView.setOnSystemUiVisibilityChangeListener { visibility: Int ->
110
- val isNavigationBarVisible = (visibility and View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0
111
- val stringVisibility = if (isNavigationBarVisible) "visible" else "hidden"
112
- sendEvent(
113
- VISIBILITY_EVENT_NAME,
114
- Bundle().apply {
115
- putString("visibility", stringVisibility)
116
- putInt("rawVisibility", visibility)
117
- }
118
- )
119
- }
120
- }.runOnQueue(Queues.MAIN)
121
-
122
- AsyncFunction("stopObserving") {
123
- val decorView = activity.window.decorView
124
- @Suppress("DEPRECATION")
125
- decorView.setOnSystemUiVisibilityChangeListener(null)
126
- }.runOnQueue(Queues.MAIN)
127
129
  }
128
130
 
129
131
  companion object {
@@ -7,9 +7,6 @@ import android.util.Log
7
7
  import expo.modules.core.interfaces.ReactActivityLifecycleListener
8
8
  import expo.modules.navigationbar.singletons.NavigationBar
9
9
 
10
- // this needs to stay for versioning to work
11
- // EXPO_VERSIONING_NEEDS_PACKAGE_R
12
-
13
10
  class NavigationBarReactActivityLifecycleListener : ReactActivityLifecycleListener {
14
11
  override fun onCreate(activity: Activity, savedInstanceState: Bundle?) {
15
12
  // Execute static tasks before the JS engine starts.
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNavigationBar.d.ts","sourceRoot":"","sources":["../src/ExpoNavigationBar.ts"],"names":[],"mappings":";AAAA,wBAAyB"}
1
+ {"version":3,"file":"ExpoNavigationBar.d.ts","sourceRoot":"","sources":["../src/ExpoNavigationBar.ts"],"names":[],"mappings":"wBAAqB,GAAG;AAAxB,wBAAyB"}
@@ -60,7 +60,7 @@ export declare function getBorderColorAsync(): Promise<ColorValue>;
60
60
  * ```ts
61
61
  * NavigationBar.setVisibilityAsync("hidden");
62
62
  * ```
63
- * @param color Based on CSS visibility property.
63
+ * @param visibility Based on CSS visibility property.
64
64
  */
65
65
  export declare function setVisibilityAsync(visibility: NavigationBarVisibility): Promise<void>;
66
66
  /**
@@ -102,7 +102,7 @@ export async function getBorderColorAsync() {
102
102
  * ```ts
103
103
  * NavigationBar.setVisibilityAsync("hidden");
104
104
  * ```
105
- * @param color Based on CSS visibility property.
105
+ * @param visibility Based on CSS visibility property.
106
106
  */
107
107
  export async function setVisibilityAsync(visibility) {
108
108
  if (Platform.OS !== 'android') {
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationBar.js","sourceRoot":"","sources":["../src/NavigationBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AASpD,IAAI,QAAsB,CAAC;AAE3B,yEAAyE;AACzE,0DAA0D;AAC1D,SAAS,UAAU;IACjB,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;KAChD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAuD;IAEvD,sCAAsC;IACtC,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE;QAClC,MAAM,IAAI,mBAAmB,CAAC,e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AI,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"]}
1
+ {"version":3,"file":"NavigationBar.js","sourceRoot":"","sources":["../src/NavigationBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AASpD,IAAI,QAAsB,CAAC;AAE3B,yEAAyE;AACzE,0DAA0D;AAC1D,SAAS,UAAU;IACjB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAA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;;;;;;;;;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,CAAC;YAC9B,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YACvC,IAAI,SAAS,EAAE,CAAC;gBACd,UAAU,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,qBAAqB,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;YACxD,IAAI,SAAS,EAAE,CAAC;gBACd,UAAU,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;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 visibility 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-navigation-bar",
3
- "version": "2.8.1",
3
+ "version": "3.0.0",
4
4
  "description": "Interact with the system navigation bar",
5
5
  "main": "build/NavigationBar.js",
6
6
  "types": "build/NavigationBar.d.ts",
@@ -33,7 +33,7 @@
33
33
  "license": "MIT",
34
34
  "homepage": "https://docs.expo.dev/versions/latest/sdk/navigation-bar",
35
35
  "dependencies": {
36
- "@react-native/normalize-color": "^2.0.0",
36
+ "@react-native/normalize-colors": "~0.74.80",
37
37
  "debug": "^4.3.2"
38
38
  },
39
39
  "devDependencies": {
@@ -43,5 +43,5 @@
43
43
  "peerDependencies": {
44
44
  "expo": "*"
45
45
  },
46
- "gitHead": "43f1b4f8a5a9bca649e4e7ca6e4155482a162431"
46
+ "gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
47
47
  }
@@ -3,9 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setNavigationBarStyles = exports.setNavigationBarColors = exports.setStrings = exports.withAndroidNavigationBarExpoGoManifest = exports.resolveProps = void 0;
6
+ exports.withAndroidNavigationBarExpoGoManifest = void 0;
7
+ exports.resolveProps = resolveProps;
8
+ exports.setStrings = setStrings;
9
+ exports.setNavigationBarColors = setNavigationBarColors;
10
+ exports.setNavigationBarStyles = setNavigationBarStyles;
7
11
  // @ts-ignore: uses flow
8
- const normalize_color_1 = __importDefault(require("@react-native/normalize-color"));
12
+ const normalize_colors_1 = __importDefault(require("@react-native/normalize-colors"));
9
13
  // @ts-ignore
10
14
  const debug_1 = __importDefault(require("debug"));
11
15
  const config_plugins_1 = require("expo/config-plugins");
@@ -25,7 +29,7 @@ const LEGACY_BAR_STYLE_MAP = {
25
29
  'light-content': 'light',
26
30
  };
27
31
  function convertColorAndroid(input) {
28
- let color = (0, normalize_color_1.default)(input);
32
+ let color = (0, normalize_colors_1.default)(input);
29
33
  if (!color) {
30
34
  throw new Error('Invalid color value: ' + input);
31
35
  }
@@ -61,7 +65,6 @@ function resolveProps(config, _props) {
61
65
  }
62
66
  return props;
63
67
  }
64
- exports.resolveProps = resolveProps;
65
68
  /**
66
69
  * Ensure the Expo Go manifest is updated when the project is using config plugin properties instead
67
70
  * of the static values that Expo Go reads from (`androidNavigationBar`).
@@ -120,7 +123,6 @@ function setStrings(strings, { borderColor, visibility, position, behavior, lega
120
123
  }
121
124
  return config_plugins_1.AndroidConfig.Strings.setStringItem(stringItems, strings);
122
125
  }
123
- exports.setStrings = setStrings;
124
126
  const withNavigationBarColors = (config, props) => {
125
127
  return (0, config_plugins_1.withAndroidColors)(config, (config) => {
126
128
  config.modResults = setNavigationBarColors(props, config.modResults);
@@ -142,7 +144,6 @@ function setNavigationBarColors({ backgroundColor }, colors) {
142
144
  }
143
145
  return colors;
144
146
  }
145
- exports.setNavigationBarColors = setNavigationBarColors;
146
147
  function setNavigationBarStyles({ backgroundColor, barStyle }, styles) {
147
148
  styles = config_plugins_1.AndroidConfig.Styles.assignStylesValue(styles, {
148
149
  add: !!backgroundColor,
@@ -160,5 +161,4 @@ function setNavigationBarStyles({ backgroundColor, barStyle }, styles) {
160
161
  });
161
162
  return styles;
162
163
  }
163
- exports.setNavigationBarStyles = setNavigationBarStyles;
164
164
  exports.default = (0, config_plugins_1.createRunOncePlugin)(withNavigationBar, pkg.name, pkg.version);
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore: uses flow
2
- import normalizeColor from '@react-native/normalize-color';
2
+ import normalizeColor from '@react-native/normalize-colors';
3
3
  // @ts-ignore
4
4
  import Debug from 'debug';
5
5
  import { ExpoConfig } from 'expo/config';
@@ -121,7 +121,7 @@ export async function getBorderColorAsync(): Promise<ColorValue> {
121
121
  * ```ts
122
122
  * NavigationBar.setVisibilityAsync("hidden");
123
123
  * ```
124
- * @param color Based on CSS visibility property.
124
+ * @param visibility Based on CSS visibility property.
125
125
  */
126
126
  export async function setVisibilityAsync(visibility: NavigationBarVisibility): Promise<void> {
127
127
  if (Platform.OS !== 'android') {