@applicaster/zapp-react-native-ui-components 12.0.0-alpha.9453522405 → 12.0.0-alpha.9834532023

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 (83) hide show
  1. package/Components/AnimatedInOut/index.tsx +18 -10
  2. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  3. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  4. package/Components/AudioPlayer/helpers.tsx +1 -0
  5. package/Components/Cell/Cell.tsx +2 -2
  6. package/Components/Cell/CellWithFocusable.tsx +21 -14
  7. package/Components/Cell/TvOSCellComponent.tsx +2 -2
  8. package/Components/ErrorScreen/index.tsx +1 -1
  9. package/Components/FocusableCell/index.tsx +7 -7
  10. package/Components/FocusableList/FocusableChild.ts +24 -14
  11. package/Components/FocusableList/FocusableItem.tsx +1 -1
  12. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  13. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  14. package/Components/FocusableList/index.tsx +26 -25
  15. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  16. package/Components/HandlePlayable/HandlePlayable.tsx +1 -1
  17. package/Components/HookRenderer/index.tsx +1 -6
  18. package/Components/Image/Image.android.tsx +11 -2
  19. package/Components/Image/Image.tsx +18 -2
  20. package/Components/Image/utils/index.ts +39 -0
  21. package/Components/Layout/TV/__tests__/index.test.tsx +1 -34
  22. package/Components/Layout/TV/index.tsx +20 -36
  23. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +0 -1
  24. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  25. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  26. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  27. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +3 -1
  28. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  29. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  30. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +8 -10
  31. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  32. package/Components/ModalComponent/Button/Item.tsx +82 -0
  33. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  34. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  35. package/Components/ModalComponent/Button/assets.ts +4 -0
  36. package/Components/ModalComponent/Button/index.tsx +111 -0
  37. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  38. package/Components/ModalComponent/Header/Title.tsx +70 -0
  39. package/Components/ModalComponent/Header/assets.ts +4 -0
  40. package/Components/ModalComponent/Header/index.tsx +71 -0
  41. package/Components/ModalComponent/Header/utils.ts +79 -0
  42. package/Components/ModalComponent/index.tsx +38 -0
  43. package/Components/ModalComponent/utils.ts +126 -0
  44. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
  45. package/Components/PlayerContainer/PlayerContainer.tsx +46 -28
  46. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  47. package/Components/River/ComponentsMap/ComponentsMap.tsx +44 -0
  48. package/Components/River/River.tsx +8 -5
  49. package/Components/River/TV/River.tsx +2 -2
  50. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  51. package/Components/River/__tests__/componentsMap.test.js +1 -0
  52. package/Components/River/useScreenConfiguration.ts +5 -6
  53. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  54. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  55. package/Components/RouteManager/index.tsx +5 -3
  56. package/Components/Screen/__tests__/Screen.test.tsx +48 -36
  57. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +20 -6
  58. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  59. package/Components/Screen/index.tsx +103 -44
  60. package/Components/Screen/navigationHandler.ts +0 -82
  61. package/Components/Screen/orientationHandler.ts +1 -1
  62. package/Components/ScreenResolver/index.tsx +1 -1
  63. package/Components/Tabs/TV/styles.ts +1 -1
  64. package/Components/TrackedView/index.tsx +6 -3
  65. package/Components/VideoLive/LiveImageManager.ts +42 -13
  66. package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
  67. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +30 -3
  68. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +22 -27
  69. package/Components/VideoModal/PlayerDetails.tsx +3 -0
  70. package/Components/VideoModal/PlayerWrapper.tsx +66 -63
  71. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  72. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +4 -4
  73. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +202 -162
  74. package/Components/VideoModal/hooks/useModalSize.ts +13 -4
  75. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  76. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  77. package/Components/ZappUIComponent/index.tsx +22 -12
  78. package/Components/index.js +2 -0
  79. package/Contexts/ScreenContext/index.tsx +1 -4
  80. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  81. package/Decorators/RiverResolver/index.tsx +0 -4
  82. package/Decorators/index.tsx +0 -4
  83. package/package.json +5 -6
@@ -1,18 +1,24 @@
1
1
  import * as React from "react";
2
- import { Platform, StyleSheet, View, ViewStyle } from "react-native";
2
+ import {
3
+ Dimensions,
4
+ Platform,
5
+ StyleSheet,
6
+ View,
7
+ ViewStyle,
8
+ } from "react-native";
3
9
  import { Edge, SafeAreaView } from "react-native-safe-area-context";
4
10
 
5
11
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
6
- import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device";
12
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
7
13
  import { PlayerDetails } from "./PlayerDetails";
8
14
  import { playerDimesionsHack } from "./utils";
9
15
  import { PathnameContext } from "../../Contexts/PathnameContext";
10
- import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
11
16
  import { ScreenContextProvider } from "../../Contexts/ScreenContext";
12
17
 
13
- type Dimensions = {
14
- width: number;
15
- height: number;
18
+ type DimensionsT = {
19
+ width: number | string;
20
+ height: number | string;
21
+ aspectRatio?: number;
16
22
  };
17
23
 
18
24
  type Configuration = {
@@ -23,14 +29,15 @@ type Configuration = {
23
29
 
24
30
  type Props = {
25
31
  entry: ZappEntry;
26
- style: ViewStyle & Dimensions;
32
+ style: ViewStyle & DimensionsT;
27
33
  containerStyle?: ViewStyle;
28
34
  inline?: boolean;
29
35
  docked?: boolean;
36
+ pip?: boolean;
30
37
  isModal?: boolean;
31
38
  fullscreen?: boolean;
32
39
  isTabletPortrait?: boolean;
33
- children: (playerDimensions: Dimensions) => React.ReactNode;
40
+ children: (playerDimensions: DimensionsT) => React.ReactNode;
34
41
  configuration: Configuration;
35
42
  };
36
43
 
@@ -52,6 +59,15 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
52
59
  return orientationStyles.portrait;
53
60
  };
54
61
 
62
+ const getScreenAspectRatio = () => {
63
+ const { width, height } = Dimensions.get("screen");
64
+
65
+ const longEdge = Math.max(width, height);
66
+ const shortEdge = Math.min(width, height);
67
+
68
+ return longEdge / shortEdge;
69
+ };
70
+
55
71
  const safeAreaStyles = (
56
72
  configuration: Configuration,
57
73
  isTablet: boolean
@@ -66,34 +82,6 @@ const safeAreaStyles = (
66
82
  };
67
83
  };
68
84
 
69
- const getTabletWidth = (
70
- configuration: Configuration,
71
- dimensions: Dimensions
72
- ) => {
73
- const tablet_landscape_sidebar_width =
74
- configuration?.tablet_landscape_sidebar_width;
75
-
76
- const { width } = dimensions;
77
-
78
- const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
79
-
80
- if (tablet_landscape_sidebar_width?.includes("%")) {
81
- return width * (1 - sidebarWidth / 100);
82
- }
83
-
84
- if (Number.isNaN(sidebarWidth)) {
85
- return width * 0.65;
86
- }
87
-
88
- return width - sidebarWidth;
89
- };
90
-
91
- export const defaultAspectRatioHeight = (width: number): number =>
92
- (width / 16) * 9;
93
-
94
- export const defaultAspectRatioWidth = (height: number): number =>
95
- (height / 9) * 16;
96
-
97
85
  const getEdges = (
98
86
  isTablet: boolean,
99
87
  docked: boolean,
@@ -115,6 +103,28 @@ const getEdges = (
115
103
  return ["top"];
116
104
  };
117
105
 
106
+ const getTabletWidth = (
107
+ configuration: Configuration,
108
+ dimensions: DimensionsT
109
+ ) => {
110
+ const tablet_landscape_sidebar_width =
111
+ configuration?.tablet_landscape_sidebar_width;
112
+
113
+ const { width } = dimensions;
114
+
115
+ const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
116
+
117
+ if (tablet_landscape_sidebar_width?.includes("%")) {
118
+ return Number(width) * (1 - sidebarWidth / 100);
119
+ }
120
+
121
+ if (Number.isNaN(sidebarWidth)) {
122
+ return Number(width) * 0.65;
123
+ }
124
+
125
+ return Number(width) - sidebarWidth;
126
+ };
127
+
118
128
  export const PlayerWrapper = (props: Props) => {
119
129
  const {
120
130
  entry,
@@ -126,6 +136,7 @@ export const PlayerWrapper = (props: Props) => {
126
136
  children,
127
137
  isTabletPortrait,
128
138
  configuration,
139
+ pip,
129
140
  } = props;
130
141
 
131
142
  const isTablet = useIsTablet();
@@ -136,40 +147,38 @@ export const PlayerWrapper = (props: Props) => {
136
147
 
137
148
  const tabletWidth = getTabletWidth(configuration, style);
138
149
 
139
- const { width: screenWidth } = useDimensions("screen");
140
-
141
- const containerDimensions: Dimensions = React.useMemo(
150
+ const baseDimensions: DimensionsT = React.useMemo(
142
151
  () => ({
143
152
  width:
144
- isInlineModal && !docked && isTabletLandscape
145
- ? tabletWidth
146
- : style.width,
147
- height:
148
- isInlineModal && !docked
149
- ? defaultAspectRatioHeight(
150
- isTabletLandscape ? tabletWidth : screenWidth
151
- )
152
- : style.height,
153
+ isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
154
+ height: isInlineModal && docked ? style.height : undefined,
153
155
  }),
154
- [isInlineModal, docked, isTabletLandscape, tabletWidth, style, screenWidth]
156
+ [isInlineModal, tabletWidth, style.height, docked]
155
157
  );
156
158
 
157
- const playerDimensions: Dimensions = React.useMemo(
159
+ const playerDimensions: DimensionsT = React.useMemo(
158
160
  () => ({
159
- width:
160
- isInlineModal && docked
161
- ? defaultAspectRatioWidth(containerDimensions.height)
162
- : containerDimensions.width,
163
- height: containerDimensions.height,
161
+ ...baseDimensions,
162
+ width: isInlineModal && docked ? undefined : baseDimensions.width,
163
+ aspectRatio: !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9,
164
+ }),
165
+ [baseDimensions, isInlineModal, pip]
166
+ );
167
+
168
+ const containerDimensions: DimensionsT = React.useMemo(
169
+ () => ({
170
+ ...baseDimensions,
171
+ aspectRatio:
172
+ isInlineModal && docked ? undefined : playerDimensions.aspectRatio,
164
173
  }),
165
- [isInlineModal, docked, containerDimensions]
174
+ [baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
166
175
  );
167
176
 
168
177
  const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
169
178
 
170
179
  const childrenStyles = React.useMemo(
171
180
  () => ({ ...playerDimensions, ...playerDimesionsHack }),
172
- [playerDimensions, playerDimesionsHack]
181
+ [containerDimensions, playerDimesionsHack]
173
182
  );
174
183
 
175
184
  return (
@@ -190,12 +199,6 @@ export const PlayerWrapper = (props: Props) => {
190
199
  defaultStyles.playerContainer,
191
200
  containerDimensions,
192
201
  containerStyle,
193
- {
194
- height:
195
- isInlineModal && !docked
196
- ? containerDimensions.height + 10
197
- : containerDimensions.height,
198
- },
199
202
  playerDimesionsHack,
200
203
  ]}
201
204
  >
@@ -8,8 +8,6 @@ const props = {
8
8
  configuration: { modal_background_color: "transparent" },
9
9
  };
10
10
 
11
- jest.mock("react-native");
12
-
13
11
  jest.mock("react-native-safe-area-context", () => ({
14
12
  useSafeAreaInsets: jest.fn(() => ({
15
13
  top: 20,
@@ -19,8 +19,6 @@ const props = {
19
19
 
20
20
  const useIsTablet = jest.fn();
21
21
 
22
- jest.mock("react-native");
23
-
24
22
  jest.mock("../PlayerDetails", () => ({ PlayerDetails: View }));
25
23
 
26
24
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
@@ -38,6 +36,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
38
36
  }));
39
37
 
40
38
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
39
+ isNavBarVisible: jest.fn(() => true),
41
40
  useRoute: jest.fn(() => ({
42
41
  pathname: "/river/testId",
43
42
  })),
@@ -50,7 +49,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
50
49
 
51
50
  jest.mock("../utils", () => ({ playerDimesionsHack: {} }));
52
51
 
53
- const { PlayerWrapper, defaultAspectRatioWidth } = require("../PlayerWrapper");
52
+ const { PlayerWrapper } = require("../PlayerWrapper");
54
53
 
55
54
  jest.useFakeTimers();
56
55
  const children = jest.fn(() => {});
@@ -110,7 +109,8 @@ describe("PlayerWrapper", () => {
110
109
 
111
110
  const expectDimensions = {
112
111
  ...dimensions,
113
- width: defaultAspectRatioWidth(dimensions.height),
112
+ width: undefined,
113
+ aspectRatio: 16 / 9,
114
114
  };
115
115
 
116
116
  expect(element).toMatchSnapshot();