@applicaster/zapp-react-native-utils 12.0.0-rc.35 → 12.0.0-rc.37
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 +2 -2
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.ts +2 -0
- package/reactHooks/layout/__tests__/index.test.js +1 -0
- package/reactHooks/layout/types/index.ts +1 -0
- package/reactHooks/layout/useDimensions/useDimensions.ts +8 -5
- package/reactHooks/navigation/__mocks__/index.ts +2 -0
- package/reactHooks/navigation/index.ts +16 -1
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.37",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "12.0.0-rc.37",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"create-react-context": "^0.2.3",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import * as R from "ramda";
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ import { isTV } from "../../../reactUtils";
|
|
|
8
8
|
import { Options, UseDimensions } from "../types";
|
|
9
9
|
import { getDeviceInfo } from "../getDeviceInfo";
|
|
10
10
|
import { getInitialDimensions } from "./helpers";
|
|
11
|
+
import { useIsScreenActive } from "../../navigation";
|
|
11
12
|
|
|
12
13
|
function compensateForScaleIfNeeded(context) {
|
|
13
14
|
return function () {
|
|
@@ -32,8 +33,10 @@ const statusBarHeight = StatusBar?.currentHeight;
|
|
|
32
33
|
*/
|
|
33
34
|
export const useDimensions: UseDimensions = (
|
|
34
35
|
context = "window",
|
|
35
|
-
fullDimensions = { fullDimensions: false }
|
|
36
|
+
fullDimensions = { fullDimensions: false, updateForInactiveScreens: true }
|
|
36
37
|
) => {
|
|
38
|
+
const isActive = useIsScreenActive();
|
|
39
|
+
|
|
37
40
|
if (typeof fullDimensions === "boolean") {
|
|
38
41
|
// eslint-disable-next-line no-console
|
|
39
42
|
console.warn(
|
|
@@ -73,7 +76,7 @@ export const useDimensions: UseDimensions = (
|
|
|
73
76
|
|
|
74
77
|
if (newDimensions.width === newDimensions.height) {
|
|
75
78
|
/**
|
|
76
|
-
* Ignoring case
|
|
79
|
+
* Ignoring case occurred on iOS when Dimensions.get sometimes returning
|
|
77
80
|
* wrong `window` sizes
|
|
78
81
|
* when switch background -> foreground state.
|
|
79
82
|
* ( TODO fix when 1:1 aspect ratio will be used )
|
|
@@ -81,7 +84,7 @@ export const useDimensions: UseDimensions = (
|
|
|
81
84
|
|
|
82
85
|
// eslint-disable-next-line no-console
|
|
83
86
|
console.log("change: wrong values - width equal to height, ignoring");
|
|
84
|
-
} else {
|
|
87
|
+
} else if (isActive || options.updateForInactiveScreens) {
|
|
85
88
|
deviceInfo.current = getDeviceInfo(newDimensions);
|
|
86
89
|
setDimensions(newDimensions);
|
|
87
90
|
}
|
|
@@ -92,7 +95,7 @@ export const useDimensions: UseDimensions = (
|
|
|
92
95
|
return () => {
|
|
93
96
|
activeSubscription.remove();
|
|
94
97
|
};
|
|
95
|
-
}, []);
|
|
98
|
+
}, [isActive]);
|
|
96
99
|
|
|
97
100
|
const memoizedDimensions = useMemo(() => {
|
|
98
101
|
return { ...applyOptions(dimensions), statusBarHeight };
|
|
@@ -23,3 +23,5 @@ export const useNavigation = jest.fn(() => ({
|
|
|
23
23
|
export const useNavigationPluginData = jest.fn().mockReturnValue(mockMenu);
|
|
24
24
|
|
|
25
25
|
export const useIsNavBarVisible = jest.fn().mockReturnValue(true);
|
|
26
|
+
|
|
27
|
+
export const useIsScreenActive = jest.fn().mockReturnValue(true);
|
|
@@ -19,9 +19,9 @@ import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Co
|
|
|
19
19
|
import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
|
|
20
20
|
import { HOOKS_EVENTS } from "../../appUtils/HooksManager/constants";
|
|
21
21
|
import {
|
|
22
|
+
getNavigationProps,
|
|
22
23
|
getRiverFromRoute,
|
|
23
24
|
getTargetRoute,
|
|
24
|
-
getNavigationProps,
|
|
25
25
|
} from "../../navigationUtils";
|
|
26
26
|
import { platformSelect } from "../../reactUtils";
|
|
27
27
|
import { useConnectionInfo } from "../connection";
|
|
@@ -447,3 +447,18 @@ export const useGetBottomTabBarHeight = (): number => {
|
|
|
447
447
|
|
|
448
448
|
return !isBottomBarNavigation ? 0 : tabBarHeight + topBorderWidth;
|
|
449
449
|
};
|
|
450
|
+
|
|
451
|
+
// If current screen is active/focused (visible to the user)
|
|
452
|
+
export const useIsScreenActive = () => {
|
|
453
|
+
const pathname = usePathname();
|
|
454
|
+
const { currentRoute, videoModalState } = useNavigation();
|
|
455
|
+
|
|
456
|
+
if (
|
|
457
|
+
videoModalState.visible &&
|
|
458
|
+
["FULLSCREEN", "MAXIMIZED", "PIP"].includes(videoModalState.mode)
|
|
459
|
+
) {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return pathname === currentRoute;
|
|
464
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { cleanup, renderHook } from "@testing-library/react-hooks";
|
|
4
4
|
import configureStore from "redux-mock-store";
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
|
|
@@ -12,6 +12,8 @@ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
|
12
12
|
useIsRTL: jest.fn(() => mock_rtl_flag),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
|
|
16
|
+
|
|
15
17
|
const { useCellResolver } = require("../useCellResolver");
|
|
16
18
|
|
|
17
19
|
describe("cellResolver", () => {
|