react-native-navigation-mode 1.2.0 → 1.2.2-beta.1
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/android/src/main/java/com/navigationmode/NavigationModeModule.kt +1 -1
- package/lib/module/index.js +6 -5
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeNavigationMode.d.ts +2 -2
- package/lib/typescript/src/NativeNavigationMode.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +18 -2
- package/src/NativeNavigationMode.ts +2 -2
- package/src/index.tsx +6 -5
|
@@ -30,7 +30,7 @@ class NavigationModeModule(reactContext: ReactApplicationContext) :
|
|
|
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) {
|
|
33
|
-
val navBar = insets.getInsets(WindowInsets.Type.navigationBars())
|
|
33
|
+
val navBar = insets.getInsets(WindowInsets.Type.navigationBars()) ?: return 0
|
|
34
34
|
return (navBar.bottom / density).toInt() // Convert pixels to dp
|
|
35
35
|
}
|
|
36
36
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
|
-
import
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
5
|
import NavigationModeModule from "./NativeNavigationMode.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get detailed navigation mode information
|
|
@@ -14,6 +14,7 @@ export function getNavigationMode() {
|
|
|
14
14
|
return Promise.resolve({
|
|
15
15
|
type: 'gesture',
|
|
16
16
|
isGestureNavigation: true,
|
|
17
|
+
interactionMode: 2,
|
|
17
18
|
navigationBarHeight: 0 // iOS doesn't have a navigation bar like Android
|
|
18
19
|
});
|
|
19
20
|
}
|
|
@@ -56,10 +57,10 @@ export function getNavigationBarHeight() {
|
|
|
56
57
|
* Hook for React components to get navigation mode
|
|
57
58
|
*/
|
|
58
59
|
export function useNavigationMode() {
|
|
59
|
-
const [navigationMode, setNavigationMode] =
|
|
60
|
-
const [loading, setLoading] =
|
|
61
|
-
const [error, setError] =
|
|
62
|
-
|
|
60
|
+
const [navigationMode, setNavigationMode] = useState(null);
|
|
61
|
+
const [loading, setLoading] = useState(true);
|
|
62
|
+
const [error, setError] = useState(null);
|
|
63
|
+
useEffect(() => {
|
|
63
64
|
let mounted = true;
|
|
64
65
|
async function fetchNavigationMode() {
|
|
65
66
|
try {
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
1
|
+
{"version":3,"names":["Platform","useEffect","useState","NavigationModeModule","getNavigationMode","OS","Promise","resolve","type","isGestureNavigation","interactionMode","navigationBarHeight","getNavigationBarHeight","useNavigationMode","navigationMode","setNavigationMode","loading","setLoading","error","setError","mounted","fetchNavigationMode","mode","err","Error"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,oBAAoB,MAEpB,2BAAwB;AAI/B;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAgC;EAC/D;EACA,IAAIJ,QAAQ,CAACK,EAAE,KAAK,KAAK,IAAIF,oBAAoB,KAAK,IAAI,EAAE;IAC1D;IACA,OAAOG,OAAO,CAACC,OAAO,CAAC;MACrBC,IAAI,EAAE,SAAS;MACfC,mBAAmB,EAAE,IAAI;MACzBC,eAAe,EAAE,CAAC;MAClBC,mBAAmB,EAAE,CAAC,CAAE;IAC1B,CAAC,CAAC;EACJ;;EAEA;EACA,OAAOR,oBAAoB,CAACC,iBAAiB,CAAC,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,mBAAmBA,CAAA,EAAqB;EACtD;EACA,I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,KAAK,CAAC;QACnB;MACF;IACF;IAEAI,mBAAmB,CAAC,CAAC;IAErB,OAAO,MAAM;MACXD,OAAO,GAAG,KAAK;IACjB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEN,cAAc;IAAEE,OAAO;IAAEE;EAAM,CAAC;AAC3C;AAEA,eAAe;EACbd,iBAAiB;EACjBK,mBAAmB;EACnBG,sBAAsB;EACtBC;AACF,CAAC","ignoreList":[]}
|
|
@@ -2,8 +2,8 @@ import type { TurboModule } from 'react-native';
|
|
|
2
2
|
export interface NavigationModeInfo {
|
|
3
3
|
type: '3_button' | '2_button' | 'gesture' | 'unknown';
|
|
4
4
|
isGestureNavigation: boolean;
|
|
5
|
-
interactionMode
|
|
6
|
-
navigationBarHeight
|
|
5
|
+
interactionMode: number;
|
|
6
|
+
navigationBarHeight: number;
|
|
7
7
|
}
|
|
8
8
|
export interface Spec extends TurboModule {
|
|
9
9
|
getNavigationMode(): Promise<NavigationModeInfo>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeNavigationMode.d.ts","sourceRoot":"","sources":["../../../src/NativeNavigationMode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACtD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,
|
|
1
|
+
{"version":3,"file":"NativeNavigationMode.d.ts","sourceRoot":"","sources":["../../../src/NativeNavigationMode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACtD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjD,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAID,QAAA,MAAM,YAAY,aAGR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAA6B,EAC3B,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAA6B,EAC3B,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAc/D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAStD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CASxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB;;;;EAmChC;;;;;;;AAED,wBAKW"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-navigation-mode",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-beta.1",
|
|
4
4
|
"description": "Detect Android navigation mode (3-button, 2-button, or gesture)",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
|
+
"react-native": "./lib/module/index.js",
|
|
7
|
+
"source": "src/index.tsx",
|
|
6
8
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
10
|
"src",
|
|
@@ -176,5 +178,19 @@
|
|
|
176
178
|
"languages": "kotlin-objc",
|
|
177
179
|
"type": "turbo-module",
|
|
178
180
|
"version": "0.50.3"
|
|
179
|
-
}
|
|
181
|
+
},
|
|
182
|
+
"funding": [
|
|
183
|
+
{
|
|
184
|
+
"type": "individual",
|
|
185
|
+
"url": "https://www.paypal.com/paypalme/jairajjangle001/usd"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "individual",
|
|
189
|
+
"url": "https://liberapay.com/FutureJJ/donate"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "individual",
|
|
193
|
+
"url": "https://ko-fi.com/futurejj"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
180
196
|
}
|
|
@@ -4,8 +4,8 @@ import { TurboModuleRegistry, Platform } from 'react-native';
|
|
|
4
4
|
export interface NavigationModeInfo {
|
|
5
5
|
type: '3_button' | '2_button' | 'gesture' | 'unknown';
|
|
6
6
|
isGestureNavigation: boolean;
|
|
7
|
-
interactionMode
|
|
8
|
-
navigationBarHeight
|
|
7
|
+
interactionMode: number;
|
|
8
|
+
navigationBarHeight: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface Spec extends TurboModule {
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import NavigationModeModule, {
|
|
4
4
|
type NavigationModeInfo,
|
|
5
5
|
} from './NativeNavigationMode';
|
|
@@ -17,6 +17,7 @@ export function getNavigationMode(): Promise<NavigationModeInfo> {
|
|
|
17
17
|
return Promise.resolve({
|
|
18
18
|
type: 'gesture',
|
|
19
19
|
isGestureNavigation: true,
|
|
20
|
+
interactionMode: 2,
|
|
20
21
|
navigationBarHeight: 0, // iOS doesn't have a navigation bar like Android
|
|
21
22
|
});
|
|
22
23
|
}
|
|
@@ -60,11 +61,11 @@ export function getNavigationBarHeight(): Promise<number> {
|
|
|
60
61
|
*/
|
|
61
62
|
export function useNavigationMode() {
|
|
62
63
|
const [navigationMode, setNavigationMode] =
|
|
63
|
-
|
|
64
|
-
const [loading, setLoading] =
|
|
65
|
-
const [error, setError] =
|
|
64
|
+
useState<NavigationModeInfo | null>(null);
|
|
65
|
+
const [loading, setLoading] = useState(true);
|
|
66
|
+
const [error, setError] = useState<Error | null>(null);
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
useEffect(() => {
|
|
68
69
|
let mounted = true;
|
|
69
70
|
|
|
70
71
|
async function fetchNavigationMode() {
|