@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 15.0.0-rc.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.
Files changed (163) hide show
  1. package/Components/AnimatedInOut/index.tsx +5 -3
  2. package/Components/AudioPlayer/index.tsx +15 -0
  3. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  4. package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
  5. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  6. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  7. package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
  8. package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
  9. package/Components/AudioPlayer/tv/Layout.tsx +168 -0
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
  14. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
  15. package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
  16. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
  19. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
  20. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
  21. package/Components/AudioPlayer/types.ts +40 -0
  22. package/Components/BaseFocusable/index.tsx +23 -12
  23. package/Components/Cell/Cell.tsx +91 -64
  24. package/Components/Cell/CellWithFocusable.tsx +3 -0
  25. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  26. package/Components/Cell/index.js +7 -3
  27. package/Components/ComponentResolver/index.ts +1 -1
  28. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  29. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  30. package/Components/FeedLoader/index.js +2 -8
  31. package/Components/Focusable/Focusable.tsx +12 -3
  32. package/Components/Focusable/FocusableTvOS.tsx +5 -5
  33. package/Components/Focusable/FocusableiOS.tsx +2 -2
  34. package/Components/Focusable/Touchable.tsx +5 -3
  35. package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
  36. package/Components/Focusable/index.android.tsx +19 -11
  37. package/Components/Focusable/index.tsx +1 -1
  38. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  39. package/Components/FocusableList/FocusableItem.tsx +4 -3
  40. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  41. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  42. package/Components/FocusableList/index.tsx +20 -9
  43. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  44. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  45. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -10
  46. package/Components/HandlePlayable/HandlePlayable.tsx +25 -9
  47. package/Components/HookRenderer/HookRenderer.tsx +5 -1
  48. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  49. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  50. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  51. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  52. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
  53. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  54. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  55. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  56. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  57. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  58. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  59. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  60. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  61. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  62. package/Components/MasterCell/elementMapper.tsx +1 -2
  63. package/Components/MasterCell/index.tsx +1 -1
  64. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  65. package/Components/MasterCell/utils/index.ts +11 -5
  66. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  67. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  68. package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
  69. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  70. package/Components/PlayerContainer/PlayerContainer.tsx +46 -33
  71. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  72. package/Components/PlayerContainer/index.ts +1 -1
  73. package/Components/PlayerImageBackground/index.tsx +1 -1
  74. package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
  75. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
  76. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
  77. package/Components/River/RefreshControl.tsx +11 -17
  78. package/Components/River/RiverItem.tsx +3 -0
  79. package/Components/River/TV/River.tsx +2 -17
  80. package/Components/River/TV/index.tsx +3 -1
  81. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  82. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  83. package/Components/River/TV/withTVEventHandler.tsx +1 -1
  84. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  85. package/Components/River/__tests__/river.test.js +12 -26
  86. package/Components/River/index.tsx +1 -1
  87. package/Components/Screen/__tests__/Screen.test.tsx +28 -29
  88. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  89. package/Components/Screen/navigationHandler.ts +20 -2
  90. package/Components/ScreenResolver/index.tsx +15 -0
  91. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  92. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  93. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  94. package/Components/ScreenRevealManager/index.ts +1 -0
  95. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
  96. package/Components/Tabs/TV/Tabs.android.tsx +1 -3
  97. package/Components/Tabs/Tabs.tsx +2 -3
  98. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  99. package/Components/TextInputTv/index.tsx +11 -0
  100. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  101. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  102. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  103. package/Components/VideoLive/animationUtils.ts +3 -3
  104. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -9
  105. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
  106. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
  107. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +73 -29
  108. package/Components/VideoModal/PlayerDetails.tsx +24 -2
  109. package/Components/VideoModal/PlayerWrapper.tsx +26 -142
  110. package/Components/VideoModal/VideoModal.tsx +3 -17
  111. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  112. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
  113. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  114. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  115. package/Components/VideoModal/hooks/index.ts +0 -2
  116. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  117. package/Components/VideoModal/hooks/useModalSize.ts +18 -2
  118. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  119. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  120. package/Components/VideoModal/utils.ts +6 -0
  121. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  122. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  123. package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
  124. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
  125. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  126. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  127. package/Contexts/ScreenContext/index.tsx +46 -6
  128. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  129. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  130. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  131. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  132. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  133. package/Decorators/RiverFeedLoader/index.tsx +22 -4
  134. package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
  135. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  136. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  137. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  138. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  139. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  140. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  141. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  142. package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
  143. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  144. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  145. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
  146. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  147. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  148. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  149. package/events/index.ts +3 -0
  150. package/package.json +5 -10
  151. package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
  152. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
  153. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
  154. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
  155. package/Components/AudioPlayer/index.ts +0 -1
  156. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  157. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
  158. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
  159. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
  160. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
  161. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
  162. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
  163. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +0 -0
@@ -2,6 +2,8 @@ import { renderHook } from "@testing-library/react-hooks";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
4
4
 
5
+ jest.useFakeTimers();
6
+
5
7
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
6
8
  useIsTablet: jest.fn().mockReturnValue(false),
7
9
  }));
@@ -11,11 +13,15 @@ describe("useDelayedPlayerDetails", () => {
11
13
  jest.clearAllMocks();
12
14
  });
13
15
 
14
- it("should return true initially", () => {
16
+ it("should return false initially, that changes after 1 second", () => {
15
17
  const { result } = renderHook(() =>
16
18
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
17
19
  );
18
20
 
21
+ expect(result.current).toBe(false);
22
+
23
+ jest.advanceTimersByTime(1000);
24
+
19
25
  expect(result.current).toBe(true);
20
26
  });
21
27
 
@@ -46,6 +52,8 @@ describe("useDelayedPlayerDetails", () => {
46
52
  })
47
53
  );
48
54
 
55
+ jest.advanceTimersByTime(1000);
56
+
49
57
  expect(result.current).toBe(true);
50
58
  });
51
59
  });
@@ -1,5 +1,3 @@
1
- export { useBackgroundColor } from "./useBackgroundColor";
2
-
3
1
  export { useDelayedPlayerDetails } from "./useDelayedPlayerDetails";
4
2
 
5
3
  export { useInitialPlayerState } from "./useInitialPlayerState";
@@ -1,22 +1,26 @@
1
+ // const showPlayerDetails = (
2
+ // isInline: boolean,
3
+ // isDocked: boolean,
4
+ // isPip: boolean,
5
+ // isTablet: boolean
6
+ // ) => {
7
+ // return showDetails({
8
+ // isMobile: !isTablet,
9
+ // isInline,
10
+ // isDocked,
11
+ // isPip,
12
+ // });
13
+ // };
14
+
15
+ import * as React from "react";
1
16
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
17
+ import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
2
18
 
3
19
  import { showDetails } from "./utils";
4
20
 
5
- type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
21
+ const TIMEOUT = 1000; // ms
6
22
 
7
- const showPlayerDetails = (
8
- isInline: boolean,
9
- isDocked: boolean,
10
- isPip: boolean,
11
- isTablet: boolean
12
- ) => {
13
- return showDetails({
14
- isMobile: !isTablet,
15
- isInline,
16
- isDocked,
17
- isPip,
18
- });
19
- };
23
+ type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
20
24
 
21
25
  /**
22
26
  * Custom hook to determine whether to show player details with a delay.
@@ -32,7 +36,28 @@ export const useDelayedPlayerDetails = ({
32
36
  isDocked,
33
37
  isPip,
34
38
  }: Props): boolean => {
39
+ const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
40
+
35
41
  const isTablet = useIsTablet();
36
42
 
37
- return showPlayerDetails(isInline, isDocked, isPip, isTablet);
43
+ React.useEffect(() => {
44
+ const subscription = withTimeout$(TIMEOUT).subscribe({
45
+ next: () => {
46
+ setShouldShowDetails(() => {
47
+ return showDetails({
48
+ isMobile: !isTablet,
49
+ isInline,
50
+ isDocked,
51
+ isPip,
52
+ });
53
+ });
54
+ },
55
+ });
56
+
57
+ return () => {
58
+ subscription.unsubscribe();
59
+ };
60
+ }, [isDocked, isTablet, isInline, isPip]);
61
+
62
+ return shouldShowDetails;
38
63
  };
@@ -9,6 +9,12 @@ import {
9
9
 
10
10
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
11
11
  import { useSafeAreaFrame } from "react-native-safe-area-context";
12
+ import {
13
+ isAndroidPlatform,
14
+ isAndroidVersionAtLeast,
15
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
16
+ import { StatusBar } from "react-native";
17
+ import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
12
18
 
13
19
  const { Logger } = getXray();
14
20
 
@@ -27,12 +33,17 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
27
33
  height: "100%",
28
34
  };
29
35
 
36
+ const isOldAndroidDevice =
37
+ isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
38
+
30
39
  export const useModalSize = (): Size => {
31
40
  const frame = useSafeAreaFrame();
32
41
 
33
42
  const [modalSize, setModalSize] = React.useState<Size>({
34
43
  width: frame.width,
35
- height: frame.height,
44
+ height: isOldAndroidDevice
45
+ ? frame.height + StatusBar.currentHeight
46
+ : frame.height,
36
47
  });
37
48
 
38
49
  const setNewModalSize = React.useCallback((newSize, log) => {
@@ -44,7 +55,12 @@ export const useModalSize = (): Size => {
44
55
  return oldSize;
45
56
  }
46
57
 
47
- return newSize;
58
+ return {
59
+ width: newSize.width,
60
+ height: isOldAndroidDevice
61
+ ? newSize.height + StatusBar.currentHeight
62
+ : newSize.height,
63
+ };
48
64
  });
49
65
 
50
66
  logger.debug({
@@ -12,7 +12,7 @@ describe("showDetails", () => {
12
12
  expect(result).toBe(false);
13
13
  });
14
14
 
15
- it("should return false if isDocked is true", () => {
15
+ it("should return true if isDocked & mobile", () => {
16
16
  const result = showDetails({
17
17
  isMobile: true,
18
18
  isInline: true,
@@ -20,7 +20,7 @@ describe("showDetails", () => {
20
20
  isPip: false,
21
21
  });
22
22
 
23
- expect(result).toBe(false);
23
+ expect(result).toBe(true);
24
24
  });
25
25
 
26
26
  it("should return true if isMobile is true and isInline is true", () => {
@@ -52,6 +52,10 @@ export const showDetails = ({
52
52
  }
53
53
 
54
54
  if (isDocked) {
55
+ if (isMobile) {
56
+ return true;
57
+ }
58
+
55
59
  return false;
56
60
  }
57
61
 
@@ -34,6 +34,9 @@ export const useConfiguration = () => {
34
34
  minimised_height = 0,
35
35
  minimised_height_tablet = 0,
36
36
  modal_background_color,
37
+ tablet_landscape_player_container_background_color,
38
+ screen_background_color,
39
+ audio_player_background_color,
37
40
  } = config;
38
41
 
39
42
  const minimisedHeight = useIsTablet()
@@ -43,6 +46,9 @@ export const useConfiguration = () => {
43
46
  return {
44
47
  minimised_height: Number(minimisedHeight),
45
48
  modal_background_color,
49
+ tablet_landscape_player_container_background_color,
50
+ audio_player_background_color,
51
+ screen_background_color,
46
52
  };
47
53
  };
48
54
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  import * as React from "react";
4
4
 
5
- import { act, create as render } from "react-test-renderer";
5
+ import { act, render } from "@testing-library/react-native";
6
6
 
7
7
  import { ViewportAware } from "../";
8
8
  import { ViewportTracker } from "../../ViewportTracker";
@@ -12,21 +12,17 @@ import ReactNative from "react-native";
12
12
 
13
13
  jest.useFakeTimers();
14
14
 
15
- jest.mock("react-native/Libraries/ReactNative/UIManager", () => {
16
- return {
17
- ...jest.requireActual("react-native/Libraries/ReactNative/NativeUIManager"),
18
- measureLayout: (handle, parent, error, success) => {
19
- success(100, 100, 400, 400);
20
- },
21
- };
22
- });
15
+ const { ScrollView } = ReactNative;
23
16
 
24
- jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
25
- ...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
26
- findNodeHandle: () => 1234,
27
- }));
17
+ jest.spyOn(ReactNative, "findNodeHandle").mockImplementation(() => 1234);
28
18
 
29
- const { ScrollView } = ReactNative;
19
+ ReactNative.UIManager.measureLayout = jest.fn(
20
+ (handle, parent, error, success) => {
21
+ success(100, 100, 400, 400);
22
+ }
23
+ );
24
+
25
+ ReactNative.findNodeHandle = () => 1234;
30
26
 
31
27
  const viewportEventsManager = new ViewportEvents(true);
32
28
 
@@ -138,7 +134,7 @@ describe("<ViewportAware />", () => {
138
134
  expect(wrapper.toJSON()).toMatchSnapshot();
139
135
  expect(onViewportEnter).toHaveBeenCalled();
140
136
 
141
- const scrollviews = wrapper.root.findAllByType(ScrollView);
137
+ const scrollviews = wrapper.UNSAFE_getAllByType(ScrollView);
142
138
  expect(scrollviews).toBeArray();
143
139
  expect(scrollviews).toHaveProperty("length", 2);
144
140
 
@@ -179,7 +175,7 @@ describe("<ViewportAware />", () => {
179
175
 
180
176
  expect(wrapper.toJSON()).toMatchSnapshot();
181
177
 
182
- const scrollviews = wrapper.root.findAllByType(ScrollView);
178
+ const scrollviews = wrapper.UNSAFE_getAllByType(ScrollView);
183
179
  expect(scrollviews).toBeArray();
184
180
  expect(scrollviews).toHaveProperty("length", 2);
185
181
 
@@ -1,14 +1,19 @@
1
1
  import * as React from "react";
2
- import { ScrollView } from "react-native";
3
- import TestRenderer, { act } from "react-test-renderer";
2
+ import { act, render } from "@testing-library/react-native";
4
3
  import { ViewportEvents } from "../../ViewportEvents";
4
+ import ReactNative from "react-native";
5
+
6
+ const { ScrollView } = ReactNative;
5
7
 
6
8
  const TestComponent = () => <ScrollView />;
7
9
 
8
- jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
9
- ...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
10
- findNodeHandle: () => 1234,
11
- }));
10
+ jest.spyOn(ReactNative, "findNodeHandle").mockImplementation(() => 1234);
11
+
12
+ ReactNative.UIManager.measureLayout = jest.fn(
13
+ (handle, parent, error, success) => {
14
+ success(100, 100, 400, 400);
15
+ }
16
+ );
12
17
 
13
18
  const viewportEventsManager = new ViewportEvents(true);
14
19
 
@@ -23,32 +28,49 @@ const event = {
23
28
  };
24
29
 
25
30
  describe("<ViewportTracker />", () => {
26
- // eslint-disable-next-line react/prop-types
27
- const ReactWrapper = ({ children }) => (
28
- <ViewportTracker viewportEventsManager={viewportEventsManager}>
29
- <ScrollView>{children}</ScrollView>
30
- </ViewportTracker>
31
- );
32
-
33
- const wrapper = TestRenderer.create(
34
- <ReactWrapper>
35
- <TestComponent />
36
- </ReactWrapper>
37
- );
38
-
39
- const scrollView = wrapper.root.findByType(ScrollView);
40
-
41
31
  beforeEach(() => {
42
32
  viewportEventSpy.mockClear();
43
33
  });
44
34
 
45
35
  it("renders correctly", () => {
36
+ // eslint-disable-next-line react/prop-types
37
+ const ReactWrapper = ({ children }) => (
38
+ <ViewportTracker viewportEventsManager={viewportEventsManager}>
39
+ <ScrollView>{children}</ScrollView>
40
+ </ViewportTracker>
41
+ );
42
+
43
+ const wrapper = render(
44
+ <ReactWrapper>
45
+ <TestComponent />
46
+ </ReactWrapper>
47
+ );
48
+
49
+ const scrollView = wrapper.UNSAFE_getByType(ScrollView);
50
+
46
51
  expect(wrapper.toJSON()).toMatchSnapshot();
47
52
  expect(scrollView.props).toMatchSnapshot();
48
53
  });
49
54
 
50
55
  it("notifies viewport listeners when layout changes", () => {
51
- act(() => scrollView.props.onLayout(event));
56
+ // eslint-disable-next-line react/prop-types
57
+ const ReactWrapper = ({ children }) => (
58
+ <ViewportTracker viewportEventsManager={viewportEventsManager}>
59
+ <ScrollView>{children}</ScrollView>
60
+ </ViewportTracker>
61
+ );
62
+
63
+ const wrapper = render(
64
+ <ReactWrapper>
65
+ <TestComponent />
66
+ </ReactWrapper>
67
+ );
68
+
69
+ const scrollView = wrapper.UNSAFE_getByType(ScrollView);
70
+
71
+ act(() => {
72
+ scrollView.props.onLayout(event);
73
+ });
52
74
 
53
75
  expect(viewportEventSpy).toHaveBeenCalledWith(
54
76
  expect.objectContaining({
@@ -63,12 +85,50 @@ describe("<ViewportTracker />", () => {
63
85
  });
64
86
 
65
87
  it("notifies viewport listeners when content scrolls", () => {
66
- act(() => scrollView.props.onScroll(event));
88
+ // eslint-disable-next-line react/prop-types
89
+ const ReactWrapper = ({ children }) => (
90
+ <ViewportTracker viewportEventsManager={viewportEventsManager}>
91
+ <ScrollView>{children}</ScrollView>
92
+ </ViewportTracker>
93
+ );
94
+
95
+ const wrapper = render(
96
+ <ReactWrapper>
97
+ <TestComponent />
98
+ </ReactWrapper>
99
+ );
100
+
101
+ const scrollView = wrapper.UNSAFE_getByType(ScrollView);
102
+
103
+ act(() => {
104
+ scrollView.props.onLayout(event);
105
+ scrollView.props.onScroll(event);
106
+ });
107
+
67
108
  expect(viewportEventSpy).toHaveBeenCalled();
68
109
  });
69
110
 
70
111
  it("notifies viewport listeners when content size changes", () => {
71
- act(() => scrollView.props.onContentSizeChange(100, 100));
112
+ // eslint-disable-next-line react/prop-types
113
+ const ReactWrapper = ({ children }) => (
114
+ <ViewportTracker viewportEventsManager={viewportEventsManager}>
115
+ <ScrollView>{children}</ScrollView>
116
+ </ViewportTracker>
117
+ );
118
+
119
+ const wrapper = render(
120
+ <ReactWrapper>
121
+ <TestComponent />
122
+ </ReactWrapper>
123
+ );
124
+
125
+ const scrollView = wrapper.UNSAFE_getByType(ScrollView);
126
+
127
+ act(() => {
128
+ scrollView.props.onLayout(event);
129
+ scrollView.props.onContentSizeChange(100, 100);
130
+ });
131
+
72
132
  expect(viewportEventSpy).toHaveBeenCalled();
73
133
  });
74
134
  });
@@ -4,8 +4,8 @@ which helps in detecting whether a given component is visible within the viewpor
4
4
  It is useful for implementing lazy loading or triggering specific actions when a component comes into view.
5
5
  */
6
6
 
7
- import React, { useEffect, useState, useRef, ReactNode, FC } from "react";
8
- import { View, Dimensions } from "react-native";
7
+ import React, { FC, ReactNode, useEffect, useRef, useState } from "react";
8
+ import { Dimensions, View } from "react-native";
9
9
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
10
10
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
11
11
 
@@ -78,7 +78,7 @@ const VisibilitySensorComponent: FC<Props> = ({
78
78
  };
79
79
 
80
80
  const stopWatching = () => {
81
- interval = clearInterval(interval);
81
+ clearInterval(interval);
82
82
  };
83
83
 
84
84
  const isInViewPort = () => {
@@ -1,10 +1,10 @@
1
1
  import {
2
- getColor,
3
2
  ACTIVE_COLOR,
4
3
  BACKGROUND_COLOR,
5
- MAIN_TEXT_COLOR,
6
4
  FOCUSED_TEXT_COLOR,
7
- } from "../../../colors/index";
5
+ getColor,
6
+ MAIN_TEXT_COLOR,
7
+ } from "../../../colors";
8
8
 
9
9
  const Image = "Image";
10
10
  const View = "View";
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ export const CellFocusedStateContext = React.createContext<boolean>(false);
4
+
5
+ export const CellFocusedStateContextProvider = ({
6
+ cellFocused,
7
+ children,
8
+ }: {
9
+ cellFocused: boolean;
10
+ children: ReactNode;
11
+ }) => {
12
+ return (
13
+ <CellFocusedStateContext.Provider value={cellFocused}>
14
+ {children}
15
+ </CellFocusedStateContext.Provider>
16
+ );
17
+ };
18
+
19
+ export function withCellFocusedStateContext(
20
+ Component: React.ComponentType<any>
21
+ ) {
22
+ return function WithCellFocusedStateContextWrapper(props) {
23
+ const cellFocusedState = React.useContext(CellFocusedStateContext);
24
+
25
+ return <Component {...props} cellFocusedState={cellFocusedState} />;
26
+ };
27
+ }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import TestRenderer from "react-test-renderer";
2
+ import { render } from "@testing-library/react-native";
3
3
  import { View } from "react-native";
4
4
  import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
5
5
 
@@ -14,12 +14,12 @@ describe("withConfigurationProvider", () => {
14
14
  };
15
15
 
16
16
  it("provides configuration to children", () => {
17
- const wrapper = TestRenderer.create(
17
+ const { toJSON } = render(
18
18
  <ConfigurationProvider configuration={{ target: "foobar" }}>
19
19
  <TestComponent />
20
20
  </ConfigurationProvider>
21
21
  );
22
22
 
23
- expect(wrapper.toJSON()).toMatchSnapshot();
23
+ expect(toJSON()).toMatchSnapshot();
24
24
  });
25
25
  });
@@ -13,7 +13,8 @@ import {
13
13
  } from "@applicaster/zapp-react-native-utils/reactHooks";
14
14
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
15
15
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
16
- import { create, StoreApi, UseBoundStore } from "zustand";
16
+ import { create } from "zustand";
17
+ import { subscribeWithSelector } from "zustand/middleware";
17
18
  import { useShallow } from "zustand/react/shallow";
18
19
  import { Animated } from "react-native";
19
20
 
@@ -39,11 +40,26 @@ interface NavBarState {
39
40
  setSummary: (subtitle: string) => void;
40
41
  }
41
42
 
42
- type ScreenContextType = {
43
- _navBarStore: UseBoundStore<StoreApi<NavBarStoreState>>;
44
- navBar: NavBarState;
45
- legacyFormatScreenData: LegacyNavigationScreenData | null;
46
- };
43
+ const createStateStore = () =>
44
+ create(
45
+ subscribeWithSelector<ScreenStateStore>((set) => ({
46
+ data: {},
47
+ setValue: (key, value) =>
48
+ set((state) => ({
49
+ data: {
50
+ ...state.data,
51
+ [key]: value,
52
+ },
53
+ })),
54
+ removeValue: (key) =>
55
+ set((state) => {
56
+ const newData = { ...state.data };
57
+ delete newData[key];
58
+
59
+ return { data: newData };
60
+ }),
61
+ }))
62
+ );
47
63
 
48
64
  const createStore = () =>
49
65
  create<NavBarStoreState>((set) => ({
@@ -65,7 +81,15 @@ const createStore = () =>
65
81
  },
66
82
  }));
67
83
 
84
+ type ScreenContextType = {
85
+ _navBarStore: ReturnType<typeof createStore>;
86
+ _stateStore: ReturnType<typeof createStateStore>;
87
+ navBar: NavBarState;
88
+ legacyFormatScreenData: LegacyNavigationScreenData | null;
89
+ };
90
+
68
91
  export const ScreenContext = createContext<ScreenContextType>({
92
+ _stateStore: createStateStore(),
69
93
  _navBarStore: createStore(),
70
94
  navBar: {
71
95
  visible: true,
@@ -103,6 +127,21 @@ export function ScreenContextProvider({
103
127
  null
104
128
  );
105
129
 
130
+ const screenStateRef = useRef<null | ReturnType<typeof createStateStore>>(
131
+ null
132
+ );
133
+
134
+ const getScreenState = useCallback(() => {
135
+ if (screenStateRef.current !== null) {
136
+ return screenStateRef.current;
137
+ }
138
+
139
+ const stateStore = createStateStore();
140
+ screenStateRef.current = stateStore;
141
+
142
+ return stateStore;
143
+ }, []);
144
+
106
145
  const getScreenNavBarState = useCallback(() => {
107
146
  if (screenNavBarStateRef.current !== null) {
108
147
  return screenNavBarStateRef.current;
@@ -163,6 +202,7 @@ export function ScreenContextProvider({
163
202
  value={useMemo(
164
203
  () => ({
165
204
  _navBarStore: getScreenNavBarState(),
205
+ _stateStore: getScreenState(),
166
206
  navBar: navBarState,
167
207
  legacyFormatScreenData: routeScreenData,
168
208
  }),
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import TestRenderer from "react-test-renderer";
2
+ import { render } from "@testing-library/react-native";
3
3
  import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
4
4
  import { View } from "react-native";
5
5
  import { withConfigurationProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ConfigurationWrapper";
@@ -15,12 +15,12 @@ describe("withConfigurationProvider", () => {
15
15
  it("correctly passes all the configuration keys child component", () => {
16
16
  const Component = withConfigurationProvider(TestComponent);
17
17
 
18
- const wrapper = TestRenderer.create(
18
+ const { toJSON } = render(
19
19
  <Component
20
20
  screenData={{ styles: {}, general: {}, data: { source: "test" } }}
21
21
  />
22
22
  );
23
23
 
24
- expect(wrapper.toJSON()).toMatchSnapshot();
24
+ expect(toJSON()).toMatchSnapshot();
25
25
  });
26
26
  });
@@ -21,13 +21,13 @@ const prepareConfiguration = (
21
21
  keys: [string]
22
22
  ) => R.compose(R.evolve(keysMap), R.pickAll(keys))(configuration);
23
23
 
24
+ const configurationKeys = R.keys(keysMap);
25
+
24
26
  export function withConfigurationProvider(Component: React.ComponentType<any>) {
25
27
  return function WithConfigurationProvider(props: Props) {
26
28
  const styles = props?.screenData?.styles;
27
29
  const general = props?.screenData?.general;
28
30
 
29
- const configurationKeys = React.useMemo(() => R.keys(keysMap), []);
30
-
31
31
  const configuration = React.useMemo(
32
32
  () => prepareConfiguration({ ...general, ...styles }, configurationKeys),
33
33
  []