@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5170277721 → 15.0.0-alpha.5219062121

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 (112) hide show
  1. package/Components/BaseFocusable/index.ios.ts +12 -2
  2. package/Components/Cell/Cell.tsx +14 -3
  3. package/Components/Cell/CellWithFocusable.tsx +9 -0
  4. package/Components/Cell/FocusableWrapper.tsx +3 -0
  5. package/Components/Cell/TvOSCellComponent.tsx +26 -5
  6. package/Components/Focusable/Focusable.tsx +4 -2
  7. package/Components/Focusable/FocusableTvOS.tsx +18 -1
  8. package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
  9. package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
  10. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
  11. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -6
  12. package/Components/HandlePlayable/HandlePlayable.tsx +10 -7
  13. package/Components/HandlePlayable/utils.ts +31 -0
  14. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  15. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  16. package/Components/Layout/TV/index.tsx +3 -4
  17. package/Components/Layout/TV/index.web.tsx +3 -4
  18. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  19. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  20. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  21. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  22. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  23. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  24. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  25. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
  26. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
  27. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
  28. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
  29. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
  30. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  31. package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
  32. package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
  33. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -2
  34. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +233 -11
  35. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +19 -15
  36. package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
  37. package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
  38. package/Components/MasterCell/index.tsx +2 -0
  39. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  40. package/Components/MasterCell/utils/index.ts +61 -31
  41. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  42. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  43. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
  44. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
  45. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  46. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  47. package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
  48. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  49. package/Components/PlayerContainer/PlayerContainer.tsx +50 -55
  50. package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +131 -0
  51. package/Components/PlayerImageBackground/index.tsx +3 -22
  52. package/Components/River/ComponentsMap/ComponentsMap.tsx +16 -0
  53. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  54. package/Components/River/TV/River.tsx +31 -14
  55. package/Components/River/TV/index.tsx +8 -4
  56. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  57. package/Components/River/TV/utils/index.ts +4 -0
  58. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  59. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  60. package/Components/River/__tests__/componentsMap.test.js +38 -0
  61. package/Components/Screen/TV/index.web.tsx +4 -2
  62. package/Components/Screen/__tests__/Screen.test.tsx +65 -42
  63. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  64. package/Components/Screen/hooks.ts +2 -3
  65. package/Components/Screen/index.tsx +2 -3
  66. package/Components/Screen/navigationHandler.ts +49 -24
  67. package/Components/Screen/orientationHandler.ts +10 -13
  68. package/Components/ScreenResolver/index.tsx +13 -7
  69. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  70. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  71. package/Components/Tabs/TV/Tabs.tsx +20 -3
  72. package/Components/Tabs/TabContent.tsx +7 -4
  73. package/Components/Transitioner/Scene.tsx +15 -2
  74. package/Components/Transitioner/index.js +3 -3
  75. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  76. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  77. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  78. package/Components/VideoModal/PlayerWrapper.tsx +14 -52
  79. package/Components/VideoModal/VideoModal.tsx +1 -5
  80. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  81. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  82. package/Components/VideoModal/hooks/useModalSize.ts +5 -1
  83. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  84. package/Components/VideoModal/playerWrapperUtils.ts +16 -12
  85. package/Components/VideoModal/utils.ts +19 -9
  86. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  87. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  88. package/Contexts/ScreenContext/index.tsx +25 -18
  89. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  90. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  91. package/Contexts/index.ts +0 -2
  92. package/Decorators/Analytics/index.tsx +6 -5
  93. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  94. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  95. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  96. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  97. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  98. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  99. package/Helpers/DataSourceHelper/index.ts +19 -0
  100. package/events/index.ts +3 -0
  101. package/events/scrollEndReached.ts +15 -0
  102. package/index.d.ts +7 -0
  103. package/package.json +6 -5
  104. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  105. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  106. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
  107. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  108. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  109. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  110. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  111. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  112. package/Helpers/DataSourceHelper/index.js +0 -19
@@ -1,19 +1,11 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, ViewStyle } from "react-native";
2
+ import { View, ViewStyle } from "react-native";
3
3
  import { Edge, SafeAreaView } from "react-native-safe-area-context";
4
4
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
6
  import { playerDimensionsHack } from "./utils";
7
- import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
8
- import {
9
- DimensionsT,
10
- Configuration,
11
- getEdges,
12
- getBaseDimensions,
13
- calculateAspectRatio,
14
- getPlayerDimensions,
15
- getContainerDimensions,
16
- } from "./playerWrapperUtils";
7
+ import { DimensionsT, Configuration, getEdges } from "./playerWrapperUtils";
8
+ import { defaultStyles, useStyle } from "./playerWrapperStyle";
17
9
 
18
10
  type Props = {
19
11
  entry: ZappEntry;
@@ -30,10 +22,6 @@ type Props = {
30
22
  playerContent: (styles: ViewStyle) => React.ReactNode;
31
23
  };
32
24
 
33
- const defaultStyles = StyleSheet.create({
34
- playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
35
- });
36
-
37
25
  const PlayerWrapperComponent = (props: Props) => {
38
26
  const {
39
27
  entry,
@@ -47,47 +35,21 @@ const PlayerWrapperComponent = (props: Props) => {
47
35
  playerContent,
48
36
  } = props;
49
37
 
38
+ const styles = useStyle({
39
+ style,
40
+ inline,
41
+ isModal,
42
+ isTabletPortrait,
43
+ configuration,
44
+ pip,
45
+ });
46
+
50
47
  const isTablet = useIsTablet();
51
48
 
52
49
  const isInlineModal = inline && isModal;
53
50
 
54
- const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
55
-
56
- const tabletWidth = getTabletWidth(
57
- configuration.tablet_landscape_sidebar_width,
58
- style
59
- );
60
-
61
- const baseDimensions: DimensionsT = React.useMemo(
62
- () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
63
- [isInlineModal, isTabletLandscape, tabletWidth]
64
- );
65
-
66
- const aspectRatio = React.useMemo(
67
- () => calculateAspectRatio(isInlineModal, pip),
68
- [isInlineModal, pip]
69
- );
70
-
71
- const playerDimensions = React.useMemo(
72
- () => getPlayerDimensions(baseDimensions, aspectRatio),
73
- [baseDimensions, aspectRatio]
74
- );
75
-
76
- const containerDimensions: DimensionsT = React.useMemo(
77
- () => getContainerDimensions(baseDimensions, playerDimensions.aspectRatio),
78
- [baseDimensions, playerDimensions.aspectRatio]
79
- );
80
-
81
51
  const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
82
52
 
83
- const childrenStyles = React.useMemo(
84
- () => ({
85
- ...playerDimensions,
86
- ...playerDimensionsHack,
87
- }),
88
- [playerDimensions]
89
- );
90
-
91
53
  return (
92
54
  <WrapperView
93
55
  edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
@@ -98,11 +60,11 @@ const PlayerWrapperComponent = (props: Props) => {
98
60
  style={[
99
61
  defaultStyles.playerContainer,
100
62
  playerDimensionsHack,
101
- containerDimensions,
63
+ styles.containerDimensions,
102
64
  containerStyle,
103
65
  ]}
104
66
  >
105
- {playerContent(childrenStyles)}
67
+ {playerContent(styles.childrenStyles)}
106
68
  </View>
107
69
  </WrapperView>
108
70
  );
@@ -139,11 +139,7 @@ const VideoModalComponent = () => {
139
139
 
140
140
  {itemIdHooksFinished === item?.id ? (
141
141
  <View pointerEvents="box-none" style={styles.container}>
142
- <HandlePlayable
143
- item={item}
144
- isModal={mode !== "PIP"}
145
- mode={mode}
146
- />
142
+ <HandlePlayable item={item} isModal mode={mode} />
147
143
  </View>
148
144
  ) : (
149
145
  <View style={styles.loaderContainer}>
@@ -46,6 +46,7 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
46
46
 
47
47
  jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
48
48
  isTV: jest.fn(() => false),
49
+ isAndroidPlatform: jest.fn(() => false),
49
50
  isApplePlatform: jest.fn(() => true),
50
51
  platformSelect: jest.fn((props) => props.android),
51
52
  }));
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { act, renderHook, waitFor } from "@testing-library/react-native";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
4
4
 
@@ -13,16 +13,20 @@ describe("useDelayedPlayerDetails", () => {
13
13
  jest.clearAllMocks();
14
14
  });
15
15
 
16
- it("should return false initially, that changes after 1 second", () => {
16
+ it("should return false initially, that changes after 1 second", async () => {
17
17
  const { result } = renderHook(() =>
18
18
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
19
19
  );
20
20
 
21
21
  expect(result.current).toBe(false);
22
22
 
23
- jest.advanceTimersByTime(1000);
23
+ act(() => {
24
+ jest.advanceTimersByTime(1000);
25
+ });
24
26
 
25
- expect(result.current).toBe(true);
27
+ await waitFor(() => {
28
+ expect(result.current).toBe(true);
29
+ });
26
30
  });
27
31
 
28
32
  it("should return false when isPip is true", () => {
@@ -41,7 +45,7 @@ describe("useDelayedPlayerDetails", () => {
41
45
  expect(result.current).toBe(false);
42
46
  });
43
47
 
44
- it("should return true for tablet regardless of other flags", () => {
48
+ it("should return true for tablet regardless of other flags", async () => {
45
49
  (useIsTablet as jest.Mock).mockReturnValue(true);
46
50
 
47
51
  const { result } = renderHook(() =>
@@ -52,8 +56,12 @@ describe("useDelayedPlayerDetails", () => {
52
56
  })
53
57
  );
54
58
 
55
- jest.advanceTimersByTime(1000);
59
+ act(() => {
60
+ jest.advanceTimersByTime(1000);
61
+ });
56
62
 
57
- expect(result.current).toBe(true);
63
+ await waitFor(() => {
64
+ expect(result.current).toBe(true);
65
+ });
58
66
  });
59
67
  });
@@ -33,8 +33,12 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
33
33
  height: "100%",
34
34
  };
35
35
 
36
+ const SAFE_AREA_BREAKING_API_VERSION = 35;
37
+
36
38
  const isOldAndroidDevice =
37
- isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
39
+ isAndroidPlatform() &&
40
+ !isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION) &&
41
+ !isAndroidTablet();
38
42
 
39
43
  export const useModalSize = (): Size => {
40
44
  const frame = useSafeAreaFrame();
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, ViewStyle } from "react-native";
3
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { playerDimensionsHack } from "./utils";
6
+ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
7
+ import {
8
+ getBaseDimensions,
9
+ calculateAspectRatio,
10
+ getPlayerDimensions,
11
+ getContainerDimensions,
12
+ } from "./playerWrapperUtils";
13
+
14
+ export const defaultStyles = StyleSheet.create({
15
+ playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
16
+ });
17
+
18
+ export const useStyle = ({
19
+ style,
20
+ inline,
21
+ isModal,
22
+ isTabletPortrait,
23
+ configuration,
24
+ pip,
25
+ }) => {
26
+ const isTablet = useIsTablet();
27
+
28
+ const isInlineModal = inline && isModal;
29
+
30
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
31
+
32
+ const tabletWidth = getTabletWidth(
33
+ configuration.tablet_landscape_sidebar_width,
34
+ style
35
+ );
36
+
37
+ const baseDimensions: ViewStyle = React.useMemo(
38
+ () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
39
+ [isInlineModal, isTabletLandscape, tabletWidth]
40
+ );
41
+
42
+ const aspectRatio = React.useMemo(
43
+ () => calculateAspectRatio(isInlineModal, pip),
44
+ // ignoring insets - only initial needed
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ [isInlineModal, pip]
47
+ );
48
+
49
+ return React.useMemo(() => {
50
+ const playerDimensions: ViewStyle = getPlayerDimensions(
51
+ baseDimensions,
52
+ aspectRatio
53
+ );
54
+
55
+ const containerDimensions: ViewStyle = getContainerDimensions(
56
+ baseDimensions,
57
+ aspectRatio
58
+ );
59
+
60
+ const childrenStyles = {
61
+ ...playerDimensions,
62
+ ...playerDimensionsHack,
63
+ };
64
+
65
+ return StyleSheet.create({
66
+ containerDimensions,
67
+ childrenStyles,
68
+ });
69
+ }, [baseDimensions, aspectRatio]);
70
+ };
@@ -1,4 +1,4 @@
1
- import { Dimensions, Platform } from "react-native";
1
+ import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
2
2
  import { Edge } from "react-native-safe-area-context";
3
3
 
4
4
  export type DimensionsT = {
@@ -13,6 +13,10 @@ export type Configuration = {
13
13
  tablet_landscape_player_container_background_color?: string;
14
14
  };
15
15
 
16
+ // This is safe, remembering screen dimensions once as they do not change during runtime
17
+ // TODO: consider sharing screen orientation as a shared function for the app
18
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
19
+
16
20
  export const getWindowDimensions = () => {
17
21
  const { width, height } = Dimensions.get("window");
18
22
 
@@ -32,8 +36,8 @@ export const getMinWindowDimension = () => {
32
36
  };
33
37
 
34
38
  export const getScreenAspectRatio = () => {
35
- const longEdge = getMaxWindowDimension();
36
- const shortEdge = getMinWindowDimension();
39
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
40
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
37
41
 
38
42
  return longEdge / shortEdge;
39
43
  };
@@ -56,8 +60,8 @@ export const getEdges = (
56
60
  export const getBaseDimensions = (
57
61
  isInlineModal: boolean,
58
62
  isTabletLandscape: boolean,
59
- tabletWidth: number | string
60
- ): DimensionsT => ({
63
+ tabletWidth: DimensionValue
64
+ ): ViewStyle => ({
61
65
  width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
62
66
  height: undefined,
63
67
  });
@@ -70,18 +74,18 @@ export const calculateAspectRatio = (
70
74
  };
71
75
 
72
76
  export const getPlayerDimensions = (
73
- baseDimensions: DimensionsT,
77
+ baseDimensions: ViewStyle,
74
78
  aspectRatio: number
75
- ): DimensionsT => ({
76
- ...baseDimensions,
79
+ ): ViewStyle => ({
80
+ ...(baseDimensions as any),
77
81
  width: baseDimensions.width,
78
82
  aspectRatio,
79
83
  });
80
84
 
81
85
  export const getContainerDimensions = (
82
- baseDimensions: DimensionsT,
83
- playerAspectRatio?: number
84
- ): DimensionsT => ({
86
+ baseDimensions: ViewStyle,
87
+ aspectRatio?: string | number
88
+ ): ViewStyle => ({
85
89
  ...baseDimensions,
86
- aspectRatio: playerAspectRatio,
90
+ aspectRatio,
87
91
  });
@@ -1,31 +1,35 @@
1
1
  import { mergeRight } from "ramda";
2
2
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
+ import {
4
+ useAppSelector,
5
+ useContentTypes,
6
+ } from "@applicaster/zapp-react-native-redux/hooks";
4
7
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
8
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
6
9
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
+ import { create } from "zustand";
11
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
12
+ import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
7
13
 
8
14
  export const useConfiguration = () => {
9
15
  const {
10
16
  videoModalState: { item },
11
17
  } = useNavigation();
12
18
 
13
- const { rivers, contentTypes, pluginConfigurations } = usePickFromState([
14
- "rivers",
15
- "contentTypes",
16
- "pluginConfigurations",
17
- ]);
19
+ const rivers = useRivers();
20
+ const contentTypes = useContentTypes();
18
21
 
19
22
  const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
20
23
  const targetScreenConfiguration = rivers?.[targetScreenId];
21
24
 
22
- const pluginConfiguration =
23
- pluginConfigurations[targetScreenConfiguration?.type]?.configuration_json;
25
+ const { configuration_json } = useAppSelector((state) =>
26
+ selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
27
+ );
24
28
 
25
29
  const playerPluginConfig = playerManager.getPluginConfiguration();
26
30
 
27
31
  const config = mergeRight(playerPluginConfig, {
28
- ...pluginConfiguration,
32
+ ...configuration_json,
29
33
  ...targetScreenConfiguration?.general,
30
34
  ...targetScreenConfiguration?.styles,
31
35
  });
@@ -52,6 +56,12 @@ export const useConfiguration = () => {
52
56
  };
53
57
  };
54
58
 
59
+ export const useAnimationStateStore = create<{
60
+ isAnimationInProgress: boolean;
61
+ }>(() => ({
62
+ isAnimationInProgress: false,
63
+ }));
64
+
55
65
  const fullSize = {
56
66
  width: "100%",
57
67
  height: "100%",
@@ -32,7 +32,7 @@ function getTestDimensions(testDimensions) {
32
32
  return (process.env.NODE_ENV === "test" && testDimensions) || null;
33
33
  }
34
34
 
35
- function ViewportAwareComponent(props: Props, ref) {
35
+ function ViewportAwareComponent(props: Props, forwardedRef) {
36
36
  const viewportEvents = useViewportEventsContext();
37
37
 
38
38
  const {
@@ -47,13 +47,22 @@ function ViewportAwareComponent(props: Props, ref) {
47
47
  getTestDimensions(testDimensions) || initialDimensions
48
48
  );
49
49
 
50
+ const localRef = React.useRef(null);
51
+
50
52
  const [viewportChangeEvent, setViewportChangeEvent] = React.useState(null);
51
53
 
52
- function assignRef(_ref) {
53
- if (_ref && !ref) {
54
- ref = _ref;
55
- }
56
- }
54
+ const assignRef = React.useCallback(
55
+ (_ref) => {
56
+ localRef.current = _ref;
57
+
58
+ if (typeof forwardedRef === "function") {
59
+ forwardedRef(_ref);
60
+ } else if (forwardedRef) {
61
+ forwardedRef.current = _ref;
62
+ }
63
+ },
64
+ [forwardedRef]
65
+ );
57
66
 
58
67
  const checkInViewport = (viewportChangeEvent, layoutEvent) => {
59
68
  const inVerticalViewport = Utils.isInViewport(
@@ -94,7 +103,7 @@ function ViewportAwareComponent(props: Props, ref) {
94
103
  const onViewportChange = (viewportChangeEvent) => {
95
104
  setViewportChangeEvent(viewportChangeEvent);
96
105
 
97
- const nodeHandle = findNodeHandle(ref);
106
+ const nodeHandle = findNodeHandle(localRef.current);
98
107
 
99
108
  if (!nodeHandle) {
100
109
  return;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook } from "@testing-library/react-hooks";
2
+ import { renderHook } from "@testing-library/react-native";
3
3
  import {
4
4
  ViewportEvents,
5
5
  useViewportEventsContext,
@@ -16,6 +16,7 @@ import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-co
16
16
  import { create } from "zustand";
17
17
  import { subscribeWithSelector } from "zustand/middleware";
18
18
  import { useShallow } from "zustand/react/shallow";
19
+
19
20
  import { Animated } from "react-native";
20
21
 
21
22
  interface NavBarStoreState {
@@ -29,6 +30,8 @@ interface NavBarStoreState {
29
30
  scrollState: number;
30
31
  contentPosition: string;
31
32
  scrollYAnimated: Animated.Value;
33
+ hideOnScrollAnimated: Animated.Value;
34
+ hideOnScroll: boolean;
32
35
  }
33
36
 
34
37
  interface NavBarState {
@@ -62,24 +65,28 @@ const createStateStore = () =>
62
65
  );
63
66
 
64
67
  const createStore = () =>
65
- create<NavBarStoreState>((set) => ({
66
- title: "",
67
- summary: "",
68
- visible: true,
69
- height: 0,
70
- scrollState: 0,
71
- contentPosition: "",
72
- scrollYAnimated: new Animated.Value(0),
73
- setTitle(title) {
74
- set({ title });
75
- },
76
- setSummary(summary) {
77
- set({ summary });
78
- },
79
- setVisible(visible) {
80
- set({ visible });
81
- },
82
- }));
68
+ create(
69
+ subscribeWithSelector<NavBarStoreState>((set) => ({
70
+ title: "",
71
+ summary: "",
72
+ visible: true,
73
+ height: 0,
74
+ scrollState: 0,
75
+ contentPosition: "",
76
+ scrollYAnimated: new Animated.Value(0),
77
+ hideOnScrollAnimated: new Animated.Value(0),
78
+ hideOnScroll: false,
79
+ setTitle(title) {
80
+ set({ title });
81
+ },
82
+ setSummary(summary) {
83
+ set({ summary });
84
+ },
85
+ setVisible(visible) {
86
+ set({ visible });
87
+ },
88
+ }))
89
+ );
83
90
 
84
91
  type ScreenContextType = {
85
92
  _navBarStore: ReturnType<typeof createStore>;
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook } from "@testing-library/react-native";
2
2
  import {
3
3
  useScreenTrackedViewPositionsContext,
4
4
  ScreenTrackedViewPositionsContext,
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from "react";
1
+ import { create } from "zustand";
2
2
 
3
3
  type HookModalState = {
4
4
  path: string;
@@ -10,11 +10,12 @@ export type HookModalContextT = {
10
10
  setIsHooksExecutionInProgress: (hookExecutionState?: boolean) => void;
11
11
  isRunningInBackground: boolean;
12
12
  isPresentationFullScreen: boolean;
13
- setIsRunningInBackground: (hookBackgroundProcessState?: boolean) => void;
14
- setIsPresentingFullScreen: (hookBackgroundProcessState?: boolean) => void;
13
+ setIsRunningInBackground: () => void;
14
+ setIsPresentingFullScreen: () => void;
15
15
  state: HookModalState;
16
16
  setState: (state: HookModalState) => void;
17
17
  resetState: () => void;
18
+ hookPresentationMode: HookPresentationMode;
18
19
  };
19
20
 
20
21
  const initialState = {
@@ -24,68 +25,43 @@ const initialState = {
24
25
 
25
26
  type HookPresentationMode = "background" | "fullScreen";
26
27
 
27
- const ReactContext = React.createContext<HookModalContextT>({
28
- isHooksExecutionInProgress: false,
29
- setIsHooksExecutionInProgress: () => {},
30
- isRunningInBackground: null,
31
- setIsRunningInBackground: () => {},
32
- setIsPresentingFullScreen: () => {},
33
- isPresentationFullScreen: null,
28
+ // Use useZappHookModalStore() in React components (hooks)
29
+ // Use zappHookModalStore.getState() in non-React functions (utility functions, etc.)
30
+ export const useZappHookModalStore = create<HookModalContextT>()((set) => ({
34
31
  state: initialState,
35
- setState: () => null,
36
- resetState: () => null,
37
- });
38
-
39
- const Provider = ({ children }: { children: React.ReactNode }) => {
40
- const [state, setState] = React.useState<HookModalState>(initialState);
41
-
42
- const [hookPresentationMode, setHookPresentationMode] =
43
- React.useState<HookPresentationMode>(null);
44
-
45
- const resetState = useCallback(() => {
46
- setState(initialState);
47
- }, [setState]);
48
-
49
- const [isHooksExecutionInProgress, setIsHooksExecutionInProgress] =
50
- React.useState(false);
32
+ isHooksExecutionInProgress: false,
33
+ hookPresentationMode: null as HookPresentationMode,
34
+ isRunningInBackground: false,
35
+ isPresentationFullScreen: false,
51
36
 
52
- const setIsRunningInBackground = () => {
53
- setHookPresentationMode("background");
54
- };
37
+ setState: (newState: HookModalState) => {
38
+ set({ state: newState });
39
+ },
55
40
 
56
- const setIsPresentingFullScreen = () => {
57
- setHookPresentationMode("fullScreen");
58
- };
41
+ setIsHooksExecutionInProgress: (hookExecutionState?: boolean) => {
42
+ set({ isHooksExecutionInProgress: hookExecutionState ?? false });
43
+ },
59
44
 
60
- return (
61
- <ReactContext.Provider
62
- value={{
63
- isRunningInBackground: hookPresentationMode === "background",
64
- setIsRunningInBackground,
65
- setIsPresentingFullScreen,
66
- isPresentationFullScreen: hookPresentationMode === "fullScreen",
67
- isHooksExecutionInProgress,
68
- setIsHooksExecutionInProgress,
69
- state,
70
- setState,
71
- resetState,
72
- }}
73
- >
74
- {children}
75
- </ReactContext.Provider>
76
- );
77
- };
45
+ setIsRunningInBackground: () => {
46
+ set({
47
+ hookPresentationMode: "background",
48
+ isRunningInBackground: true,
49
+ isPresentationFullScreen: false,
50
+ });
51
+ },
78
52
 
79
- const withProvider = (Component) => {
80
- const WithProvider = (props) => {
81
- return (
82
- <Provider>
83
- <Component {...props} />
84
- </Provider>
85
- );
86
- };
53
+ setIsPresentingFullScreen: () => {
54
+ set({
55
+ hookPresentationMode: "fullScreen",
56
+ isRunningInBackground: false,
57
+ isPresentationFullScreen: true,
58
+ });
59
+ },
87
60
 
88
- return WithProvider;
89
- };
61
+ resetState: () => {
62
+ set({ state: initialState });
63
+ },
64
+ }));
90
65
 
91
- export const ZappHookModalContext = { withProvider, ReactContext };
66
+ // Export an alias for clearer non-React usage (utility functions, etc.)
67
+ export const zappHookModalStore = useZappHookModalStore;
package/Contexts/index.ts CHANGED
@@ -12,8 +12,6 @@ export { HorizontalScrollContext } from "./HorizontalScrollContext";
12
12
 
13
13
  export { RiverOffsetContext } from "./RiverOffsetContext";
14
14
 
15
- export { ZappHookModalContext } from "./ZappHookModalContext";
16
-
17
15
  export { MeasurementContext } from "./MeasurementContext";
18
16
 
19
17
  export * from "./ZappPipesContext";
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
 
3
3
  import { getAnalyticsFunctions } from "@applicaster/zapp-react-native-utils/analyticsUtils";
4
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
4
 
6
5
  type ComponentProps = {
7
6
  component: {
@@ -21,11 +20,13 @@ type ComponentProps = {
21
20
 
22
21
  function withAnalytics(Component) {
23
22
  return function WithAnalytics(props: ComponentProps) {
24
- const { appData } = usePickFromState(["appData"]);
25
-
26
23
  const analyticsFunctions = React.useMemo(
27
- () => getAnalyticsFunctions({ props, appData }),
28
- [props, appData]
24
+ () =>
25
+ getAnalyticsFunctions({
26
+ component: props.component,
27
+ zappPipesData: props.zappPipesData,
28
+ } as any),
29
+ [props.component, props.zappPipesData]
29
30
  );
30
31
 
31
32
  return (