@applicaster/zapp-react-native-utils 16.0.0-rc.37 → 16.0.0-rc.39
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.39",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "16.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "16.0.0-rc.39",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -38,3 +38,7 @@ export const useNavigationPluginData = jest.fn().mockReturnValue(mockMenu);
|
|
|
38
38
|
export const useIsNavBarVisible = jest.fn().mockReturnValue(true);
|
|
39
39
|
|
|
40
40
|
export const useIsScreenActive = jest.fn().mockReturnValue(true);
|
|
41
|
+
|
|
42
|
+
export const isScreenActiveForRoute = jest.fn(
|
|
43
|
+
(route, currentRoute) => route === currentRoute
|
|
44
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isScreenActiveForRoute } from "../useIsScreenActive";
|
|
2
|
+
|
|
3
|
+
describe("isScreenActiveForRoute", () => {
|
|
4
|
+
const route = "/river/home/river/tabs";
|
|
5
|
+
const currentRoute = "/river/home/river/tabs";
|
|
6
|
+
|
|
7
|
+
it("returns false when route does not match", () => {
|
|
8
|
+
expect(
|
|
9
|
+
isScreenActiveForRoute(route, "/river/home", { visible: false })
|
|
10
|
+
).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("keeps underlying screen active when video modal is docked", () => {
|
|
14
|
+
expect(
|
|
15
|
+
isScreenActiveForRoute(route, currentRoute, {
|
|
16
|
+
visible: true,
|
|
17
|
+
mode: "MINIMIZED",
|
|
18
|
+
})
|
|
19
|
+
).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it.each(["FULLSCREEN", "MAXIMIZED", "PIP"])(
|
|
23
|
+
"deactivates underlying screen when video modal is visible",
|
|
24
|
+
(mode) => {
|
|
25
|
+
expect(
|
|
26
|
+
isScreenActiveForRoute(route, currentRoute, {
|
|
27
|
+
visible: true,
|
|
28
|
+
mode,
|
|
29
|
+
})
|
|
30
|
+
).toBe(false);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
it("keeps video-modal route active when video modal is open", () => {
|
|
35
|
+
expect(
|
|
36
|
+
isScreenActiveForRoute("video-modal/123", currentRoute, {
|
|
37
|
+
visible: true,
|
|
38
|
+
mode: "FULLSCREEN",
|
|
39
|
+
})
|
|
40
|
+
).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -32,7 +32,7 @@ export { useNavigationType } from "./useNavigationType";
|
|
|
32
32
|
|
|
33
33
|
export { useGetBottomTabBarHeight } from "./useGetBottomTabBarHeight";
|
|
34
34
|
|
|
35
|
-
export { useIsScreenActive } from "./useIsScreenActive";
|
|
35
|
+
export { useIsScreenActive, isScreenActiveForRoute } from "./useIsScreenActive";
|
|
36
36
|
|
|
37
37
|
export { useProfilerLogging } from "./useProfilerLogging";
|
|
38
38
|
|
|
@@ -2,20 +2,41 @@ import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtil
|
|
|
2
2
|
import { useNavigation } from "./useNavigation";
|
|
3
3
|
import { usePathname } from "./usePathname";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
type VideoModalState = {
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
mode?: string;
|
|
8
|
+
} | null;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Whether a navigation route should be treated as the active/focused screen.
|
|
12
|
+
* Docked (MINIMIZED) video modal does not deactivate the underlying screen —
|
|
13
|
+
* only FULLSCREEN / MAXIMIZED / PIP do.
|
|
14
|
+
*/
|
|
15
|
+
export function isScreenActiveForRoute(
|
|
16
|
+
route: string,
|
|
17
|
+
currentRoute: string,
|
|
18
|
+
videoModalState: VideoModalState
|
|
19
|
+
) {
|
|
20
|
+
if (videoModalState?.visible) {
|
|
21
|
+
if (route.includes(ROUTE_TYPES.VIDEO_MODAL)) {
|
|
12
22
|
return true;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
if (
|
|
25
|
+
if (
|
|
26
|
+
["FULLSCREEN", "MAXIMIZED", "PIP"].includes(videoModalState.mode ?? "")
|
|
27
|
+
) {
|
|
16
28
|
return false;
|
|
17
29
|
}
|
|
30
|
+
// MINIMIZED (docked): fall through — underlying screen stays active
|
|
18
31
|
}
|
|
19
32
|
|
|
20
|
-
return
|
|
33
|
+
return route === currentRoute;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// If current screen is active/focused (visible to the user)
|
|
37
|
+
export const useIsScreenActive = () => {
|
|
38
|
+
const pathname = usePathname();
|
|
39
|
+
const { currentRoute, videoModalState } = useNavigation();
|
|
40
|
+
|
|
41
|
+
return isScreenActiveForRoute(pathname, currentRoute, videoModalState);
|
|
21
42
|
};
|