react-native-navigation-mode 1.2.4 → 1.2.6
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/README.md
CHANGED
|
@@ -73,29 +73,17 @@ npm install react-native-navigation-mode
|
|
|
73
73
|
npx expo install react-native-navigation-mode
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
#####
|
|
77
|
-
|
|
78
|
-
Add the plugin to your `app.json` or `app.config.ts`:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"expo": {
|
|
83
|
-
"plugins": [
|
|
84
|
-
"react-native-navigation-mode"
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
76
|
+
##### Development Builds
|
|
89
77
|
|
|
90
|
-
|
|
78
|
+
Since this library contains native code, it requires a [development build](https://docs.expo.dev/develop/development-builds/introduction/). It cannot be used with Expo Go.
|
|
91
79
|
|
|
92
80
|
```sh
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
# Using EAS Build (recommended)
|
|
82
|
+
eas build --profile development --platform android
|
|
95
83
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
# Or locally
|
|
85
|
+
npx expo run:android # Should auto-run prebuild if needed
|
|
86
|
+
```
|
|
99
87
|
|
|
100
88
|
#### Requirements
|
|
101
89
|
|
|
@@ -396,12 +384,6 @@ The library uses multiple detection methods for maximum accuracy:
|
|
|
396
384
|
- This is normal on devices without navigation bars (some tablets)
|
|
397
385
|
- On older Android versions, fallback detection may not work on all devices
|
|
398
386
|
|
|
399
|
-
**Expo: "Package does not contain a valid config plugin"**
|
|
400
|
-
|
|
401
|
-
- Ensure you've installed the latest version of the library
|
|
402
|
-
- Try clearing your cache: `npx expo start --clear`
|
|
403
|
-
- Make sure the plugin is added to your `app.json`
|
|
404
|
-
|
|
405
387
|
## 🤝 Contributing
|
|
406
388
|
|
|
407
389
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
@@ -13,9 +13,9 @@ import com.facebook.react.bridge.WritableMap
|
|
|
13
13
|
import com.facebook.react.module.annotations.ReactModule
|
|
14
14
|
|
|
15
15
|
@ReactModule(name = NavigationModeModule.NAME)
|
|
16
|
-
class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
16
|
+
class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
17
17
|
NativeNavigationModeSpec(reactContext) {
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
companion object {
|
|
20
20
|
const val NAME = "NavigationMode"
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
26
26
|
// Try to get Activity for WindowInsets
|
|
27
27
|
val activity = if (context is Activity) context else reactApplicationContext.currentActivity
|
|
28
28
|
val density = context.resources.displayMetrics.density // Get device density
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
31
31
|
val insets = activity.window.decorView.rootWindowInsets
|
|
32
32
|
if (insets != null) {
|
|
@@ -34,7 +34,7 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
34
34
|
return (navBar.bottom / density).toInt() // Convert pixels to dp
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// Fallback to resource-based approach for API < 30
|
|
39
39
|
val resources = context.resources
|
|
40
40
|
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
|
|
@@ -60,20 +60,21 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
60
60
|
try {
|
|
61
61
|
val result = Arguments.createMap()
|
|
62
62
|
val context = reactApplicationContext
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
// Use reactApplicationContext for navigation bar height
|
|
65
65
|
val navBarHeight = getNavigationBarHeight(context)
|
|
66
66
|
result.putInt("navigationBarHeight", navBarHeight)
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
69
69
|
val navBarInteractionMode = getNavBarInteractionMode(context)
|
|
70
70
|
result.putInt("interactionMode", navBarInteractionMode)
|
|
71
71
|
result.putString("type", getNavigationTypeFromInteractionMode(navBarInteractionMode))
|
|
72
|
+
result.putBoolean("isGestureNavigation", navBarInteractionMode == 2)
|
|
73
|
+
} else {
|
|
74
|
+
val gestureNavEnabled = isGestureNavigationEnabledLegacy(context)
|
|
75
|
+
result.putBoolean("isGestureNavigation", gestureNavEnabled)
|
|
72
76
|
}
|
|
73
|
-
|
|
74
|
-
val gestureNavEnabled = isGestureNavigationEnabled(context)
|
|
75
|
-
result.putBoolean("isGestureNavigation", gestureNavEnabled)
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
promise.resolve(result)
|
|
78
79
|
} catch (e: Exception) {
|
|
79
80
|
promise.reject("NAVIGATION_MODE_ERROR", "Failed to get navigation mode: ${e.message}", e)
|
|
@@ -83,12 +84,12 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
83
84
|
override fun isGestureNavigation(promise: Promise) {
|
|
84
85
|
try {
|
|
85
86
|
val context = reactApplicationContext
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
88
89
|
val navBarInteractionMode = getNavBarInteractionMode(context)
|
|
89
90
|
promise.resolve(navBarInteractionMode == 2)
|
|
90
91
|
} else {
|
|
91
|
-
val gestureEnabled =
|
|
92
|
+
val gestureEnabled = isGestureNavigationEnabledLegacy(context)
|
|
92
93
|
promise.resolve(gestureEnabled)
|
|
93
94
|
}
|
|
94
95
|
} catch (e: Exception) {
|
|
@@ -119,17 +120,17 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} else false
|
|
123
|
+
private fun isGestureNavigationEnabledLegacy(context: Context): Boolean {
|
|
124
|
+
// Legacy fallback using Settings.Secure (for pre-Android Q devices)
|
|
125
|
+
// or as a backup when config_navBarInteractionMode is not available
|
|
126
|
+
return try {
|
|
127
|
+
val navBarMode = Settings.Secure.getString(
|
|
128
|
+
context.contentResolver,
|
|
129
|
+
"navigation_mode"
|
|
130
|
+
)
|
|
131
|
+
"2" == navBarMode
|
|
132
|
+
} catch (e: Exception) {
|
|
133
|
+
false
|
|
134
134
|
}
|
|
135
|
-
}
|
|
135
|
+
}
|
|
136
|
+
}
|
package/app.plugin.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
const { createRunOncePlugin } = require('@expo/config-plugins');
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Expo Config Plugin for react-native-navigation-mode
|
|
5
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Note: This plugin is optional. The library works without adding it to your
|
|
5
|
+
* plugins array because no native configuration changes are required.
|
|
6
6
|
*/
|
|
7
|
+
|
|
8
|
+
/** @type {import('@expo/config-plugins').ConfigPlugin} */
|
|
7
9
|
const withNavigationMode = (config) => {
|
|
8
|
-
// No additional configuration needed for this module
|
|
9
|
-
// The module will be auto-linked through the Expo modules system
|
|
10
10
|
return config;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
module.exports = createRunOncePlugin(withNavigationMode, pkg.name, pkg.version);
|
|
13
|
+
module.exports = withNavigationMode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-navigation-mode",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Detect Android navigation mode (3-button, 2-button, or gesture)",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"react-native": "./lib/module/index.js",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"react-native.config.js",
|
|
17
17
|
"expo-module.config.json",
|
|
18
18
|
"app.plugin.js",
|
|
19
|
-
"plugin/build",
|
|
20
19
|
"!ios/build",
|
|
21
20
|
"!android/build",
|
|
22
21
|
"!android/gradle",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withNavigationMode.d.ts","sourceRoot":"","sources":["../../../../plugin/src/withNavigationMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,kBAAkB,EAAE,YAEzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|