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

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 (58) 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 +47 -6
  12. package/appUtils/playerManager/playerFactory.ts +12 -10
  13. package/appUtils/playerManager/playerNative.ts +28 -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 +33 -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/generalContent.js +6 -0
  26. package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
  27. package/manifestUtils/index.js +5 -1
  28. package/manifestUtils/secondaryImage/index.js +18 -15
  29. package/modalState/index.ts +57 -0
  30. package/navigationUtils/index.ts +56 -7
  31. package/package.json +3 -2
  32. package/playerUtils/configurationGenerator.ts +11 -1
  33. package/pluginUtils/index.ts +2 -2
  34. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  35. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  36. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  37. package/reactHooks/index.ts +2 -0
  38. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
  39. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  40. package/reactHooks/layout/types/index.ts +2 -0
  41. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  42. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  43. package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
  44. package/reactHooks/navigation/__mocks__/index.ts +2 -0
  45. package/reactHooks/navigation/__mocks__/useNavigation.ts +4 -0
  46. package/reactHooks/navigation/__tests__/index.test.tsx +234 -78
  47. package/reactHooks/navigation/index.ts +251 -85
  48. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  49. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  50. package/reactHooks/screen/index.ts +2 -0
  51. package/reactHooks/screen/useScreenContext.ts +1 -1
  52. package/reactHooks/screen/useScreenData.ts +1 -1
  53. package/reactHooks/state/useRivers.ts +3 -1
  54. package/reactHooks/useListenEventBusEvent.ts +1 -4
  55. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  56. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  57. package/screenState/index.ts +8 -0
  58. package/testUtils/index.tsx +15 -2
@@ -17,18 +17,103 @@ import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-component
17
17
  import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
18
18
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
19
19
  import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
20
- import { getNavigationProps } from "@applicaster/zapp-react-native-utils/navigationUtils";
21
20
  import { HOOKS_EVENTS } from "../../appUtils/HooksManager/constants";
22
- import { getRiverFromRoute, getTargetRoute } from "../../navigationUtils";
21
+ import {
22
+ getNavigationProps,
23
+ getRiverFromRoute,
24
+ getTargetRoute,
25
+ } from "../../navigationUtils";
23
26
  import { platformSelect } from "../../reactUtils";
24
27
  import { useConnectionInfo } from "../connection";
25
28
  import { getTargetScreenData } from "../screen/useTargetScreenData";
26
- import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
27
29
 
30
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
31
+ import { useNavbarState } from "../screen";
28
32
  import { useNavigation } from "./useNavigation";
33
+ import { useModalStore } from "../../modalState";
29
34
 
30
35
  export { useNavigation } from "./useNavigation";
31
36
 
37
+ /**
38
+ * This function helps to decide wether the navbar should be presented on the screen
39
+ * based on route and / or screen Data
40
+ *
41
+ * Currently the scenarios include
42
+ * - players => false
43
+ * - search screen plugin => false
44
+ * - hooks with `showNavBar: true` or `presentFullScreen` not set to true, defaults to no navbar for hook screens
45
+ * - screens with `allow_screen_plugin_presentation` in general property => false
46
+ *
47
+ * @param {String} route current route of the screen
48
+ * @param {Object} screenData payload associated with the currently presented screen
49
+ * @returns {Boolean}
50
+ */
51
+ export function isNavBarVisible(
52
+ route: string,
53
+ screenData: ZappRiver = {} as ZappRiver,
54
+ showNavBar: boolean,
55
+ canGoBack: boolean,
56
+ videoModalState: QuickBrickVideoModalState | null = null
57
+ ) {
58
+ /* screenData is not actual navigator.data
59
+ * or navigator.screenData,
60
+ * but navigator.data.screen */
61
+ if (route.includes("playable")) {
62
+ return false;
63
+ }
64
+
65
+ if (
66
+ videoModalState?.mode === "FULLSCREEN" &&
67
+ videoModalState?.visible === true
68
+ ) {
69
+ return false;
70
+ }
71
+
72
+ if (screenData?.type === "qb_search_screen" && !isTV()) {
73
+ return false;
74
+ }
75
+
76
+ /* Match if screen is Hook */
77
+ if (route.startsWith("/hooks/")) {
78
+ const module = screenData?.module;
79
+
80
+ if (module?.presentFullScreen) {
81
+ return false;
82
+ }
83
+
84
+ return module?.showNavBar ?? false;
85
+ }
86
+
87
+ if (screenData?.hookPlugin) {
88
+ const hookPlugin = screenData?.hookPlugin?.module;
89
+
90
+ return (
91
+ hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true || false
92
+ );
93
+ }
94
+
95
+ if (
96
+ screenData?.general?.allow_screen_plugin_presentation ||
97
+ screenData?.general?.hide_app_nav_bar
98
+ ) {
99
+ return false;
100
+ }
101
+
102
+ const hideSecondaryLevel = screenData?.navigations?.some(
103
+ (navigation) => navigation.styles?.hide_secondary_level_menu
104
+ );
105
+
106
+ if (canGoBack && hideSecondaryLevel) {
107
+ return false;
108
+ }
109
+
110
+ if (typeof showNavBar === "boolean" && !showNavBar) {
111
+ return false;
112
+ }
113
+
114
+ return true;
115
+ }
116
+
32
117
  const { ProfilerBridge } = NativeModules;
33
118
 
34
119
  export const usePathname = () => React.useContext(PathnameContext);
@@ -43,6 +128,137 @@ export const useBackHandler = (cb: () => boolean) => {
43
128
  }, [cb]);
44
129
  };
45
130
 
131
+ // starts with modal/
132
+ const isModalPathname = (pathname: string) => /^modal\//.test(pathname);
133
+
134
+ const isVideoModalPathname = (pathname: string) =>
135
+ /^video-modal\//.test(pathname);
136
+
137
+ const isHookModalPathname = (pathname: string) =>
138
+ /^hooks-modal\//.test(pathname);
139
+
140
+ const isHookPathname = (pathname: string) => /^\/hooks\//.test(pathname);
141
+
142
+ type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
143
+
144
+ export const useRoute = (): {
145
+ screenData: VariousScreenData;
146
+ pathname: string;
147
+ } => {
148
+ const pathname = usePathname() || "";
149
+
150
+ /**
151
+ * compose `useRoute()` output data
152
+ */
153
+ const composeRouteData = (screenData: VariousScreenData) => ({
154
+ screenData,
155
+ pathname,
156
+ });
157
+
158
+ const navigator = useNavigation();
159
+
160
+ const { plugins, contentTypes, rivers } = usePickFromState([
161
+ "plugins",
162
+ "rivers",
163
+ "contentTypes",
164
+ ]);
165
+
166
+ const currentStack = navigator.getStackForPathname(pathname);
167
+ const { modalState } = useModalStore();
168
+ const hookModalState = useZappHooksModalState();
169
+ const modalScreenData = modalState.screen;
170
+ const hookModalScreenData = hookModalState.state.screenData?.payload;
171
+
172
+ const videoModalScreenData =
173
+ navigator.videoModalState?.item &&
174
+ legacyScreenData(
175
+ {
176
+ entry: navigator.videoModalState?.item as ZappEntry,
177
+ screen: getTargetScreenData(
178
+ navigator.videoModalState?.item as ZappEntry,
179
+ rivers,
180
+ contentTypes
181
+ ),
182
+ },
183
+ plugins
184
+ );
185
+
186
+ const currentRouteScreenData = legacyScreenData(
187
+ {
188
+ screen: currentStack?.state?.screen ?? navigator.data?.screen ?? {},
189
+ entry: currentStack?.state?.entry ?? {},
190
+ } as NavigationScreenData,
191
+
192
+ plugins
193
+ );
194
+
195
+ // There are 4 route scenarios
196
+ // For regular screens take date from navigator stack.
197
+ // is path is model grab screenData from modal state
198
+ // if path is video modal grab screenData from video state
199
+ // if path is hook modal grab screenData from hook state
200
+ // if path is hook grab screenData from screenData
201
+
202
+ if (isModalPathname(pathname)) {
203
+ return composeRouteData(modalScreenData ?? ({} as ZappEntry));
204
+ }
205
+
206
+ if (isVideoModalPathname(pathname)) {
207
+ return composeRouteData(videoModalScreenData as LegacyNavigationScreenData);
208
+ }
209
+
210
+ if (isHookModalPathname(pathname)) {
211
+ return composeRouteData(hookModalScreenData);
212
+ }
213
+
214
+ if (isHookPathname(pathname)) {
215
+ /**
216
+ * HACK
217
+ *
218
+ * This condition relies on hacky approach to get the current hook screen data
219
+ * using navigator.screenData for some cases.
220
+ * This is used when hook is in sequence.
221
+ */
222
+
223
+ // case 1: stack not yet updated in navigator context, but navigator.screenData is updated already.
224
+ if (!currentStack) {
225
+ return composeRouteData(navigator.screenData);
226
+ }
227
+
228
+ const isValidHookInCurrentRouteScreenData =
229
+ "hookPlugin" in currentRouteScreenData &&
230
+ !!currentRouteScreenData.hookPlugin?.module;
231
+
232
+ let screenData;
233
+
234
+ // case 2: stack has valid hook data
235
+ if (isValidHookInCurrentRouteScreenData) {
236
+ screenData = currentRouteScreenData;
237
+ }
238
+
239
+ const navigatorScreenData = navigator.screenData as NavigatorEntry;
240
+
241
+ // case 3: current hookPlugin is missing weight, but navigator.screenData has weight, use navigator.screenData
242
+ if (
243
+ screenData.hookPlugin.identifier ===
244
+ navigatorScreenData?.hookPlugin?.identifier &&
245
+ !screenData.hookPlugin?.weight &&
246
+ navigatorScreenData?.hookPlugin?.weight
247
+ ) {
248
+ screenData = navigator.screenData;
249
+ }
250
+
251
+ return composeRouteData(screenData);
252
+ }
253
+
254
+ // case 1: stack not yet updated in navigator context, but navigator.screenData is updated already.
255
+ if (!currentStack) {
256
+ return composeRouteData(navigator.screenData);
257
+ }
258
+
259
+ return composeRouteData(currentRouteScreenData);
260
+ };
261
+
46
262
  type Callbacks = Partial<{
47
263
  handleHookPresent: ({
48
264
  route,
@@ -209,7 +425,7 @@ export const useRunIfLongPress = (
209
425
  React.useRef<Nullable<ReturnType<typeof setTimeout>>>(null);
210
426
 
211
427
  const resetTimeout = () => {
212
- clearTimeout(pressTimeout.current);
428
+ clearTimeout(pressTimeout.current as ReturnType<typeof setTimeout>);
213
429
  };
214
430
 
215
431
  const startTimeout = (cb: () => void) => {
@@ -231,82 +447,12 @@ export const useRunIfLongPress = (
231
447
  * @returns boolean - navbar visiblity status
232
448
  */
233
449
  export const useIsNavBarVisible = (): boolean => {
234
- const visible = useNavbarState().visible;
450
+ const { visible } = useNavbarState();
235
451
 
236
452
  return useMemo(() => visible, [visible]);
237
453
  };
238
454
 
239
- const isModalPathname = (pathname: string) => /^modal\//.test(pathname);
240
-
241
- const isVideoModalPathname = (pathname: string) =>
242
- /^video-modal\//.test(pathname);
243
-
244
- const isHookModalPathname = (pathname: string) =>
245
- /^hooks-modal\//.test(pathname);
246
-
247
- export const useRoute = () => {
248
- const pathname = usePathname() || "";
249
- const navigator = useNavigation();
250
-
251
- const { plugins, contentTypes, rivers } = usePickFromState([
252
- "plugins",
253
- "rivers",
254
- "contentTypes",
255
- ]);
256
-
257
- const currentStack = navigator.getStackForPathname(pathname);
258
- const modalState = navigator.modalState;
259
- const hookModalState = useZappHooksModalState();
260
-
261
- const modalScreenData = modalState.screen;
262
-
263
- const hookModalScreenData = hookModalState.state.screenData?.payload;
264
-
265
- const videoModalScreenData =
266
- navigator.videoModalState?.item &&
267
- legacyScreenData(
268
- {
269
- entry: navigator.videoModalState?.item,
270
- screen: getTargetScreenData(
271
- navigator.videoModalState?.item,
272
- rivers,
273
- contentTypes
274
- ),
275
- },
276
- plugins
277
- );
278
-
279
- const currentRouteScreenData = legacyScreenData(
280
- {
281
- screen:
282
- currentStack?.state?.screen ??
283
- navigator.data?.screen ??
284
- ({} as ZappRiver),
285
- entry: currentStack?.state?.entry ?? ({} as ZappEntry),
286
- },
287
-
288
- plugins
289
- );
290
-
291
- // There are 4 route scenarios
292
- // For regular screens take date from navigator stack.
293
- // is path is model grab screenData from modal state
294
- // if path is video modal grab screenData from video state
295
- // if path is hook modal grab screenData from hook state
296
-
297
- const screenData = isModalPathname(pathname)
298
- ? modalScreenData
299
- : isVideoModalPathname(pathname)
300
- ? videoModalScreenData
301
- : isHookModalPathname(pathname)
302
- ? hookModalScreenData
303
- : currentRouteScreenData;
304
-
305
- return { screenData, pathname };
306
- };
307
-
308
- export const useGetBottomTabBarHeight = (): number => {
309
- const insets = useSafeAreaInsets();
455
+ const useGetNavBarTopBorderWidth = (): number => {
310
456
  const navigator = useNavigation();
311
457
 
312
458
  const navProps = getNavigationProps({
@@ -315,18 +461,38 @@ export const useGetBottomTabBarHeight = (): number => {
315
461
  category: "menu",
316
462
  });
317
463
 
318
- const navType = useNavigationType();
319
- const isBottomBarNavigation = navType === MenuTypes.bottomTabBar;
320
-
321
- const TAB_BAR_HEIGHT_IOS = 49;
322
- const TAB_BAR_HEIGHT_ANDROID = 56;
464
+ return Number(((navProps?.styles as any)?.top_border_width as number) ?? 0);
465
+ };
323
466
 
324
- if (!isBottomBarNavigation) return 0;
467
+ const TAB_BAR_HEIGHT_IOS = 49;
468
+ const TAB_BAR_HEIGHT_ANDROID = 56;
325
469
 
326
- const tabBarHeight = platformSelect({
327
- ios: TAB_BAR_HEIGHT_IOS + insets.bottom,
470
+ const useGetTabBarHeight = () =>
471
+ platformSelect({
472
+ ios: TAB_BAR_HEIGHT_IOS + (useSafeAreaInsets().bottom ?? 0),
328
473
  android: TAB_BAR_HEIGHT_ANDROID,
329
474
  }) as number;
330
475
 
331
- return tabBarHeight + Number(navProps?.styles?.top_border_width ?? 0);
476
+ export const useGetBottomTabBarHeight = (): number => {
477
+ const topBorderWidth = useGetNavBarTopBorderWidth();
478
+ const tabBarHeight = useGetTabBarHeight();
479
+
480
+ const isBottomBarNavigation = useNavigationType() === MenuTypes.bottomTabBar;
481
+
482
+ return !isBottomBarNavigation ? 0 : tabBarHeight + topBorderWidth;
483
+ };
484
+
485
+ // If current screen is active/focused (visible to the user)
486
+ export const useIsScreenActive = () => {
487
+ const pathname = usePathname();
488
+ const { currentRoute, videoModalState } = useNavigation();
489
+
490
+ if (
491
+ videoModalState.visible &&
492
+ ["FULLSCREEN", "MAXIMIZED", "PIP"].includes(videoModalState.mode)
493
+ ) {
494
+ return false;
495
+ }
496
+
497
+ return pathname === currentRoute;
332
498
  };
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { renderHook, cleanup } from "@testing-library/react-hooks";
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", () => {
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
2
  import { View } from "react-native";
3
3
 
4
- const mockData: NavigationScreenData = {
4
+ const mockData = {
5
5
  screen: {
6
6
  id: "screen-id",
7
7
  name: "screen",
@@ -40,3 +40,5 @@ const mockData: NavigationScreenData = {
40
40
  };
41
41
 
42
42
  export const useScreenContext = jest.fn().mockReturnValue(mockData);
43
+
44
+ export const useNavbarState = () => ({ visible: true });
@@ -2,6 +2,8 @@ export { useCurrentScreenData } from "./useCurrentScreenData";
2
2
 
3
3
  export { useTargetScreenData } from "./useTargetScreenData";
4
4
 
5
+ export { useScreenData } from "./useScreenData";
6
+
5
7
  export {
6
8
  useScreenContext,
7
9
  useLegacyScreenData,
@@ -2,7 +2,7 @@ import { useContext, useMemo } from "react";
2
2
 
3
3
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
4
4
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
5
- import { useNavigation } from "../navigation";
5
+ import { useNavigation } from "../navigation/useNavigation";
6
6
 
7
7
  import { ScreenContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
8
8
 
@@ -4,7 +4,7 @@ import { useRivers } from "../state";
4
4
 
5
5
  const logger = utilsLogger.addSubsystem("useScreenData");
6
6
 
7
- export const useScreenData = (screenId?: string): ZappRiver => {
7
+ export const useScreenData = (screenId: string): ZappRiver => {
8
8
  const rivers = useRivers();
9
9
 
10
10
  React.useEffect(() => {
@@ -1,7 +1,9 @@
1
1
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
2
 
3
+ const riversSelector = ["rivers"];
4
+
3
5
  export const useRivers = () => {
4
- const { rivers } = usePickFromState(["rivers"]);
6
+ const { rivers } = usePickFromState(riversSelector as any);
5
7
 
6
8
  return rivers;
7
9
  };
@@ -13,10 +13,7 @@ export const useListenEventBusEvent = (
13
13
  // TODO: remove after implementing ReactNativeEventBusBridge on iOS
14
14
  if (Platform.OS === "android") {
15
15
  // subscribe to DeviceEventEmitter using subsciption ID
16
- const sub = DeviceEventEmitter.addListener(
17
- subscriptionID,
18
- handler
19
- );
16
+ const sub = DeviceEventEmitter.addListener(subscriptionID, handler);
20
17
 
21
18
  // ask native to start routing these events to RN
22
19
  ReactNativeEventBusBridge.subscribe(subscriptionID, { [source]: events });
@@ -1,8 +1,7 @@
1
- import {
2
- useContentTypes,
3
- usePickFromState,
4
- } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import React from "react";
2
+ import { useContentTypes } from "@applicaster/zapp-react-native-redux/hooks";
5
3
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
4
+ import { useRivers } from "../../state";
6
5
 
7
6
  export const useVideoModalScreenData = ():
8
7
  | (ZappEntry & { targetScreen: any }) // TODO: fix ZappEntry type ( was ZappRiver but conflict )
@@ -12,11 +11,13 @@ export const useVideoModalScreenData = ():
12
11
  } = useNavigation();
13
12
 
14
13
  const contentTypes = useContentTypes();
15
- const { rivers } = usePickFromState(["rivers"]);
14
+ const rivers = useRivers();
16
15
 
17
- if (item?.type?.value) {
18
- const screenId = contentTypes[item?.type?.value].screen_id;
16
+ return React.useMemo(() => {
17
+ if (item?.type?.value) {
18
+ const screenId = contentTypes[item?.type?.value].screen_id;
19
19
 
20
- return { ...item, targetScreen: rivers?.[screenId] };
21
- }
20
+ return { ...item, targetScreen: rivers?.[screenId] };
21
+ }
22
+ }, [item]);
22
23
  };
@@ -3,7 +3,7 @@ import { NativeModules, StyleSheet, View } from "react-native";
3
3
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
4
4
 
5
5
  import { isApplePlatform, isWeb } from "../reactUtils";
6
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
+ import { useRivers } from "../reactHooks/state";
7
7
 
8
8
  const layoutReducer = (state, { payload }) => {
9
9
  return state.map((item, index, _state) => ({
@@ -58,7 +58,7 @@ export const ScreenLoadingMeasurements = ({
58
58
  numberOfComponents,
59
59
  riverId,
60
60
  }: Props) => {
61
- const { rivers } = usePickFromState(["rivers"]);
61
+ const rivers = useRivers();
62
62
  const screenData = rivers?.[riverId];
63
63
 
64
64
  const [itemsLayout, dispatchItemLayout] = React.useReducer(
@@ -49,3 +49,11 @@ export function useScreenState(
49
49
  setSelectedEntry: (entryId) => setSelectedEntry(screenId, entryId),
50
50
  };
51
51
  }
52
+
53
+ export const useScreenScrollStore = create<{
54
+ scrollPosition: number;
55
+ scrollingVelocity: number;
56
+ }>(() => ({
57
+ scrollPosition: 0,
58
+ scrollingVelocity: 0,
59
+ }));
@@ -6,8 +6,10 @@ import { View } from "react-native";
6
6
  import { Provider } from "react-redux";
7
7
  import thunk from "redux-thunk";
8
8
  import configureStore from "redux-mock-store";
9
+ import { SafeAreaProvider } from "react-native-safe-area-context";
9
10
 
10
11
  import { render } from "@testing-library/react-native";
12
+ import { AnalyticsProvider } from "../analyticsUtils";
11
13
 
12
14
  /**
13
15
  * Function to be used in tandem with enzyme findWhere(node => node.prop('testID') === 'yourID')
@@ -69,9 +71,20 @@ const initialState = {
69
71
  };
70
72
 
71
73
  export const WrappedWithProviders = ({ children, store = {} }: any) => {
72
- const _store = configureStore([thunk])({ ...initialState, store });
74
+ const _store = configureStore([thunk])({ ...initialState, ...store });
73
75
 
74
- return <Provider store={_store}>{children}</Provider>;
76
+ return (
77
+ <SafeAreaProvider
78
+ initialMetrics={{
79
+ insets: { top: 0, left: 0, right: 0, bottom: 0 },
80
+ frame: { x: 0, y: 0, width: 0, height: 0 },
81
+ }}
82
+ >
83
+ <Provider store={_store}>
84
+ <AnalyticsProvider>{children}</AnalyticsProvider>
85
+ </Provider>
86
+ </SafeAreaProvider>
87
+ );
75
88
  };
76
89
 
77
90
  /**