@applicaster/zapp-react-native-utils 12.0.0-alpha.7725319213 → 12.0.0-alpha.8433353116

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.
Files changed (56) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +16 -8
  2. package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
  3. package/analyticsUtils/helpers/hooks.ts +1 -1
  4. package/appUtils/HooksManager/index.js +3 -1
  5. package/appUtils/focusManager/treeDataStructure/Utils/index.js +12 -3
  6. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
  7. package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
  8. package/appUtils/keyCodes/keys.web.js +1 -0
  9. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
  10. package/appUtils/playerManager/conts.ts +5 -0
  11. package/appUtils/playerManager/player.ts +46 -6
  12. package/appUtils/playerManager/playerFactory.ts +12 -10
  13. package/appUtils/playerManager/playerNative.ts +26 -0
  14. package/appUtils/playerManager/usePlayerState.tsx +13 -1
  15. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
  16. package/cellUtils/__tests__/cellUtils.test.ts +59 -0
  17. package/cellUtils/__tests__/fixtures.ts +13 -0
  18. package/cellUtils/index.ts +31 -2
  19. package/focusManager/index.ts +1 -1
  20. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
  21. package/functionUtils/__tests__/functionUtils.test.js +244 -248
  22. package/localizationUtils/__tests__/localizationUtils.test.ts +17 -13
  23. package/localizationUtils/index.ts +6 -3
  24. package/logger/index.ts +1 -1
  25. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  26. package/manifestUtils/index.js +5 -1
  27. package/manifestUtils/secondaryImage/index.js +18 -15
  28. package/modalState/index.ts +57 -0
  29. package/navigationUtils/index.ts +56 -7
  30. package/package.json +3 -2
  31. package/playerUtils/configurationGenerator.ts +8 -0
  32. package/pluginUtils/index.ts +2 -2
  33. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  34. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.ts +2 -0
  35. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  36. package/reactHooks/index.ts +2 -0
  37. package/reactHooks/layout/__tests__/index.test.js +23 -30
  38. package/reactHooks/layout/types/index.ts +1 -0
  39. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  40. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  41. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -5
  42. package/reactHooks/navigation/__mocks__/index.ts +2 -0
  43. package/reactHooks/navigation/__mocks__/useNavigation.ts +4 -0
  44. package/reactHooks/navigation/__tests__/index.test.tsx +234 -78
  45. package/reactHooks/navigation/index.ts +246 -85
  46. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  47. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  48. package/reactHooks/screen/index.ts +2 -0
  49. package/reactHooks/screen/useScreenContext.ts +1 -1
  50. package/reactHooks/screen/useScreenData.ts +1 -1
  51. package/reactHooks/state/useRivers.ts +3 -1
  52. package/reactHooks/useListenEventBusEvent.ts +1 -4
  53. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  54. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  55. package/screenState/index.ts +8 -0
  56. package/testUtils/index.tsx +15 -2
@@ -22,7 +22,11 @@ const {
22
22
  const { buttonKey } = require("./buttons");
23
23
  const { tvBadges } = require("./tvBadges");
24
24
  const { mobileProgressBar, tvProgressBar } = require("./progressBar");
25
- const { secondaryImage, getUpdatedSecondaryImageKeys } = require("./secondaryImage");
25
+
26
+ const {
27
+ secondaryImage,
28
+ getUpdatedSecondaryImageKeys,
29
+ } = require("./secondaryImage");
26
30
 
27
31
  module.exports = {
28
32
  fontKey,
@@ -132,29 +132,32 @@ function secondaryImage({
132
132
 
133
133
  const POSITION_OVER_IMAGE = toSnakeCase(position_over_image);
134
134
 
135
- const getUpdatedSecondaryImageKeys = (secondaryImageManifest) => secondaryImageManifest.fields.reduce((acc, item) => {
136
- const key = item.key;
135
+ const getUpdatedSecondaryImageKeys = (secondaryImageManifest) =>
136
+ secondaryImageManifest.fields.reduce((acc, item) => {
137
+ const key = item.key;
137
138
 
138
- const conditionalFields = (item.conditional_fields || []).map((field) => field.key);
139
+ const conditionalFields = (item.conditional_fields || []).map(
140
+ (field) => field.key
141
+ );
139
142
 
140
- const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
141
- const updatedKey = field.replace("secondary_image_", "nested_image_");
143
+ const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
144
+ const updatedKey = field.replace("secondary_image_", "nested_image_");
145
+
146
+ return {
147
+ ...acc,
148
+ [updatedKey]: field,
149
+ };
150
+ }, {});
151
+
152
+ const updatedKey = key.replace("secondary_image_", "nested_image_");
142
153
 
143
154
  return {
144
155
  ...acc,
145
- [updatedKey]: field,
156
+ ...updatedConditionalFields,
157
+ [updatedKey]: key,
146
158
  };
147
159
  }, {});
148
160
 
149
- const updatedKey = key.replace("secondary_image_", "nested_image_");
150
-
151
- return {
152
- ...acc,
153
- ...updatedConditionalFields,
154
- [updatedKey]: key,
155
- };
156
- }, {});
157
-
158
161
  module.exports = {
159
162
  secondaryImage,
160
163
  getUpdatedSecondaryImageKeys,
@@ -0,0 +1,57 @@
1
+ import { create } from "zustand";
2
+
3
+ interface ModalState {
4
+ visible: boolean;
5
+ screen: any;
6
+ options: Record<string, unknown>;
7
+ props: Record<string, unknown>;
8
+ }
9
+
10
+ interface ModalStore {
11
+ modalState: ModalState;
12
+ setModalState: (newState: Partial<ModalState>) => void;
13
+ openModal: (
14
+ item: any,
15
+ options?: Record<string, unknown>,
16
+ props?: Record<string, unknown>
17
+ ) => void;
18
+ dismissModal: () => void;
19
+ }
20
+
21
+ const initialModalState: ModalState = {
22
+ visible: false,
23
+ screen: null,
24
+ options: {},
25
+ props: {},
26
+ };
27
+
28
+ export const useModalStore = create<ModalStore>((set) => ({
29
+ modalState: initialModalState,
30
+ setModalState: (newState) =>
31
+ set((state) => ({
32
+ modalState: { ...state.modalState, ...newState },
33
+ })),
34
+ openModal: ({
35
+ item,
36
+ options = {},
37
+ props = { screenData: {} },
38
+ }: OpenModalArg) =>
39
+ set({
40
+ modalState: {
41
+ visible: true,
42
+ screen: item,
43
+ options: {
44
+ animated: true,
45
+ animationType: "slide",
46
+ onShow: () => {},
47
+ presentationStyle: "overFullScreen",
48
+ transparent: true,
49
+ ...options,
50
+ onDismiss: () => set({ modalState: initialModalState }),
51
+ onRequestClose: () => set({ modalState: initialModalState }),
52
+ },
53
+ props,
54
+ },
55
+ }),
56
+ dismissModal: () => set(() => ({ modalState: initialModalState })),
57
+ }));
@@ -93,19 +93,68 @@ export function resolveNavigationPlugin({
93
93
  * @param {Object} navigator to look for navigation props
94
94
  * @param {String} category to look for in screen navigations
95
95
  * @returns {Object} props
96
+ * @deprecated use getNavigationPropsV2 instead
96
97
  */
97
98
  export function getNavigationProps({
98
- navigator: { activeRiver },
99
+ navigator,
99
100
  title = "",
100
101
  category,
101
102
  }: {
102
103
  navigator: QuickBrickAppNavigator;
103
104
  title: string;
104
105
  category: string;
105
- }): Nullable<
106
- Partial<ZappNavigation> & { selected: string; title: string; home: boolean }
107
- > {
108
- const { navigations, id: selected, home } = activeRiver;
106
+ }): {
107
+ selected: string;
108
+ title: string;
109
+ home: boolean;
110
+ styles: unknown;
111
+ assets: ZappNavBarAssets;
112
+ rules: ZappNavBarRules;
113
+ nav_items: NavBarItem[];
114
+ } | null {
115
+ const { activeRiver } = navigator;
116
+ const { navigations, id: selected, home } = activeRiver; // use useRiver hook instead
117
+
118
+ const navigation: ZappNavigation = R.find(
119
+ R.propEq("category", category),
120
+ navigations
121
+ );
122
+
123
+ if (!navigation) {
124
+ return null;
125
+ }
126
+
127
+ const { styles, assets, nav_items, rules } = navigation;
128
+
129
+ return {
130
+ selected,
131
+ title,
132
+ home,
133
+ styles,
134
+ assets: assets as ZappNavBarAssets,
135
+ nav_items: nav_items as any as NavBarItem[],
136
+ rules: rules as any as ZappNavBarRules,
137
+ };
138
+ }
139
+
140
+ export function getNavigationPropsV2({
141
+ currentRiver,
142
+ title = "",
143
+ category,
144
+ }: {
145
+ currentRiver: ZappRiver;
146
+ title: string;
147
+ category: string;
148
+ }): {
149
+ selected: string;
150
+ title: string;
151
+ home: boolean;
152
+ styles: unknown;
153
+ assets: ZappNavBarAssets;
154
+ rules: ZappNavBarRules;
155
+ nav_items: NavBarItem[];
156
+ } | null {
157
+ const { navigations, id: selected, home } = currentRiver; // use useRiver hook instead
109
158
  const navigation = R.find(R.propEq("category", category), navigations);
110
159
 
111
160
  if (!navigation) {
@@ -170,7 +219,7 @@ export function getScreenIdForContentType(payload, contentTypes) {
170
219
  export function getItemTargetId(
171
220
  item: ZappEntry | ZappRiver,
172
221
  screenType?: string, // todo: creat screen types enum
173
- contentTypes?: ZappContentTypes,
222
+ contentTypes?: ZappContentTypes | null,
174
223
  rivers?: Record<string, ZappRiver>
175
224
  ) {
176
225
  // Pipes v2 resolution
@@ -217,7 +266,7 @@ export function getTargetRoute(
217
266
  layoutVersion = undefined,
218
267
  rivers = {},
219
268
  }: {
220
- contentTypes?: ZappContentTypes;
269
+ contentTypes?: ZappContentTypes | null;
221
270
  layoutVersion?: Maybe<ZappLayoutVersions>;
222
271
  rivers?: Record<string, ZappRiver>;
223
272
  } = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.7725319213",
3
+ "version": "12.0.0-alpha.8433353116",
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-alpha.7725319213",
31
+ "@applicaster/applicaster-types": "12.0.0-alpha.8433353116",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -44,6 +44,7 @@
44
44
  "immer": "*",
45
45
  "react": "17.0.2",
46
46
  "react-native": "0.68.6",
47
+ "validate-color": "*",
47
48
  "zustand": "*"
48
49
  },
49
50
  "devDependencies": {
@@ -46,6 +46,14 @@ function getPlayerConfiguration({ platform }) {
46
46
  label_tooltip:
47
47
  "Enable if you want to have adaptive background gradient based on audio background image.",
48
48
  },
49
+ {
50
+ key: "audio_player_background_image_query",
51
+ label: "Audio Player Image Query",
52
+ initial_value: "",
53
+ type: "text_input",
54
+ label_tooltip:
55
+ "Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time, when magic background is enabled.",
56
+ },
49
57
  ],
50
58
  };
51
59
 
@@ -20,14 +20,14 @@ type Plugin = {
20
20
  * returns the component module for a specific type
21
21
  * Will look in components first, then in plugins
22
22
  */
23
- function getComponentModule({
23
+ export function getComponentModule({
24
24
  componentType,
25
25
  components,
26
26
  plugins,
27
27
  }: {
28
28
  componentType: string;
29
29
  components: ComponentsMap;
30
- plugins: Plugin[];
30
+ plugins: Plugin[] | QuickBrickPlugin[];
31
31
  }) {
32
32
  const component = R.compose(
33
33
  R.prop(R.__, components),
@@ -12,6 +12,8 @@ jest.mock(
12
12
  })
13
13
  );
14
14
 
15
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
16
+
15
17
  jest.useFakeTimers();
16
18
 
17
19
  const {
@@ -17,6 +17,8 @@ jest.mock(
17
17
 
18
18
  jest.useFakeTimers();
19
19
 
20
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
21
+
20
22
  const { useTrackedView } = require("../useTrackedView");
21
23
 
22
24
  describe("useTrackCurrentAutoScrollingElement", () => {
@@ -5,27 +5,34 @@ type Return = (index: number) => void;
5
5
 
6
6
  type Predicate = (
7
7
  entry: ZappUIComponentProps["zappPipesData"]["data"]["entry"],
8
- index: number
8
+ index: number,
9
+ numberOfColumns: number
9
10
  ) => boolean;
10
11
 
11
12
  type Props = {
12
13
  ifNeeded: Predicate;
13
14
  loadNextData: () => void;
14
15
  entry: ZappUIComponentProps["zappPipesData"]["data"]["entry"];
16
+ numberOfColumns?: number;
15
17
  };
16
18
 
17
19
  const handleLoadNextPage =
18
20
  (
19
- ifNeeded: (entry: ZappEntry[], index: number) => boolean,
21
+ ifNeeded: (
22
+ entry: ZappEntry[],
23
+ index: number,
24
+ numberOfColumns?: number
25
+ ) => boolean,
20
26
  loadNextData: () => void,
21
- entry: ZappEntry[]
27
+ entry: ZappEntry[],
28
+ numberOfColumns
22
29
  ) =>
23
30
  (index: number) => {
24
31
  /**
25
32
  * Lazy-Loading, invoke nextLoadData if we reach the end of the List
26
33
  */
27
34
 
28
- if (ifNeeded(entry, index)) {
35
+ if (ifNeeded(entry, index, numberOfColumns)) {
29
36
  loadNextData();
30
37
  }
31
38
  };
@@ -34,10 +41,10 @@ export const useLoadNextPageIfNeeded = ({
34
41
  ifNeeded,
35
42
  loadNextData = noop,
36
43
  entry,
44
+ numberOfColumns = 0,
37
45
  }: Props): Return => {
38
- return React.useCallback(handleLoadNextPage(ifNeeded, loadNextData, entry), [
39
- ifNeeded,
40
- loadNextData,
41
- entry,
42
- ]);
46
+ return React.useCallback(
47
+ handleLoadNextPage(ifNeeded, loadNextData, entry, numberOfColumns),
48
+ [ifNeeded, loadNextData, entry, numberOfColumns]
49
+ );
43
50
  };
@@ -13,3 +13,5 @@ export * from "./navigation";
13
13
  export * from "./device";
14
14
 
15
15
  export * from "./screen";
16
+
17
+ export * from "./state";
@@ -1,5 +1,7 @@
1
1
  import { cleanup, renderHook } from "@testing-library/react-hooks";
2
2
 
3
+ import * as ReactNative from "react-native";
4
+
3
5
  const mocked_return_value = (tv) => ({
4
6
  screen: tv
5
7
  ? { width: 50, height: 50, scale: 2, fontScale: 1 }
@@ -10,41 +12,31 @@ const mocked_return_value = (tv) => ({
10
12
  const platform = "android";
11
13
  let tv_flag = false;
12
14
 
13
- jest.mock("react-native-safe-area-context", () => ({
14
- useSafeAreaInsets: () => ({ top: 50 }),
15
- }));
15
+ ReactNative.Dimensions.get = jest.fn(
16
+ (context) => mocked_return_value(tv_flag)[context]
17
+ );
16
18
 
17
19
  const mockRemoveFn = jest.fn();
18
20
 
19
- jest.mock("react-native", () => {
20
- const RNMock = jest.genMockFromModule("react-native");
21
-
22
- const Dims = {
23
- get: jest.fn((context) => mocked_return_value(tv_flag)[context]),
24
- addEventListener: jest.fn().mockReturnValue({
25
- remove: mockRemoveFn,
26
- }),
27
- };
28
-
29
- const QuickBrickCommunicationModule = {
30
- initialProps: {
31
- is_tablet: false,
32
- },
33
- };
34
-
35
- return {
36
- ...RNMock,
37
- Dimensions: Dims,
38
- Platform: {
39
- OS: platform,
40
- },
41
- NativeModules: {
42
- ...RNMock.NativeModules,
43
- QuickBrickCommunicationModule,
44
- },
45
- };
21
+ ReactNative.Dimensions.addEventListener = jest.fn().mockReturnValue({
22
+ remove: mockRemoveFn,
46
23
  });
47
24
 
25
+ ReactNative.Platform.OS = platform;
26
+
27
+ const QuickBrickCommunicationModule = {
28
+ initialProps: {
29
+ is_tablet: false,
30
+ },
31
+ };
32
+
33
+ ReactNative.NativeModules.QuickBrickCommunicationModule =
34
+ QuickBrickCommunicationModule;
35
+
36
+ jest.mock("react-native-safe-area-context", () => ({
37
+ useSafeAreaInsets: () => ({ top: 50 }),
38
+ }));
39
+
48
40
  jest.mock("../../../reactUtils", () => ({
49
41
  platformSelect: jest.fn((specs) => specs[platform] || specs.default),
50
42
  isTV: jest.fn(() => tv_flag),
@@ -52,6 +44,7 @@ jest.mock("../../../reactUtils", () => ({
52
44
 
53
45
  jest.mock("../../navigation", () => ({
54
46
  useNavigation: () => null,
47
+ useIsScreenActive: () => true,
55
48
  }));
56
49
 
57
50
  const { Dimensions } = require("react-native");
@@ -20,6 +20,7 @@ export type Options = {
20
20
  excludeStatusBar?: boolean;
21
21
  rounded?: boolean;
22
22
  deviceInfo?: boolean;
23
+ updateForInactiveScreens?: boolean;
23
24
  };
24
25
 
25
26
  export type Context = "window" | "screen";
@@ -1,19 +1,14 @@
1
- let mockPlatformOS = "android";
1
+ import * as ReactNative from "react-native";
2
2
 
3
- jest.mock("react-native", () => {
4
- const mockDimensionsGet = jest.fn(
5
- (type) =>
6
- ({
7
- window: { width: 1, height: 1 },
8
- screen: { width: 360, height: 540 },
9
- }[type])
10
- );
3
+ const mockDimensionsGet = jest.fn(
4
+ (type) =>
5
+ ({
6
+ window: { width: 1, height: 1 },
7
+ screen: { width: 360, height: 540 },
8
+ }[type])
9
+ );
11
10
 
12
- return {
13
- Platform: jest.fn(() => ({ OS: mockPlatformOS })),
14
- Dimensions: { get: mockDimensionsGet },
15
- };
16
- });
11
+ ReactNative.Dimensions.get = mockDimensionsGet;
17
12
 
18
13
  const mockGetConstants = jest.fn().mockReturnValue({
19
14
  Dimensions: {
@@ -26,9 +21,10 @@ jest.mock("react-native/Libraries/Utilities/NativeDeviceInfo", () => ({
26
21
  getConstants: mockGetConstants,
27
22
  }));
28
23
 
29
- const { Platform, Dimensions } = require("react-native");
24
+ const { Platform, Dimensions } = ReactNative;
30
25
 
31
26
  Platform.OS = "android";
27
+
32
28
  const { getInitialDimensions } = require("../getInitialDimensions.native.ts");
33
29
 
34
30
  describe("useDimensions > helpers ( native )", () => {
@@ -48,7 +44,6 @@ describe("useDimensions > helpers ( native )", () => {
48
44
 
49
45
  it("should call NativeDeviceInfo.getConstants for ios when width === height", () => {
50
46
  Platform.OS = "ios";
51
- mockPlatformOS = "ios";
52
47
 
53
48
  jest.fn().mockReturnValue({
54
49
  Dimensions: {
@@ -1,21 +1,19 @@
1
- jest.mock("react-native", () => {
2
- const mockDimensionsGet = jest.fn(
3
- (type) =>
4
- ({
5
- window: { width: 1, height: 1 },
6
- screen: { width: 360, height: 540 },
7
- }[type])
8
- );
1
+ import * as ReactNative from "react-native";
9
2
 
10
- return {
11
- Platform: jest.fn(() => ({ OS: "web" })),
12
- Dimensions: { get: mockDimensionsGet },
13
- };
14
- });
3
+ const mockDimensionsGet = jest.fn(
4
+ (type) =>
5
+ ({
6
+ window: { width: 1, height: 1 },
7
+ screen: { width: 360, height: 540 },
8
+ }[type])
9
+ );
10
+
11
+ ReactNative.Dimensions.get = mockDimensionsGet;
15
12
 
16
- const { Platform, Dimensions } = require("react-native");
13
+ const { Platform, Dimensions } = ReactNative;
17
14
 
18
15
  Platform.OS = "web";
16
+
19
17
  const { getInitialDimensions } = require("../getInitialDimensions.ts");
20
18
 
21
19
  describe("useDimensions > helpers (web)", () => {
@@ -1,4 +1,4 @@
1
- import { useState, useLayoutEffect, useRef, useMemo } from "react";
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 occured on iOS when Dimensions.get sometimes returning
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);
@@ -0,0 +1,4 @@
1
+ export const useNavigation = jest.fn(() => ({
2
+ data: {},
3
+ currentRoute: "someRoute",
4
+ }));