@applicaster/zapp-react-native-ui-components 12.0.0-rc.1 → 12.0.0-rc.100

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 (153) 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/BaseFocusable/index.tsx +3 -3
  6. package/Components/Cell/Cell.tsx +32 -11
  7. package/Components/Cell/CellWithFocusable.tsx +40 -19
  8. package/Components/Cell/TvOSCellComponent.tsx +5 -9
  9. package/Components/ErrorScreen/index.tsx +1 -1
  10. package/Components/Focusable/Focusable.tsx +6 -1
  11. package/Components/FocusableCell/index.tsx +7 -7
  12. package/Components/FocusableGroup/index.tsx +11 -2
  13. package/Components/FocusableList/FocusableChild.ts +24 -14
  14. package/Components/FocusableList/FocusableItem.tsx +1 -1
  15. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  16. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  17. package/Components/FocusableList/index.tsx +26 -25
  18. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  19. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  20. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  21. package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
  22. package/Components/HookRenderer/index.tsx +1 -6
  23. package/Components/Image/Image.android.tsx +11 -2
  24. package/Components/Image/Image.tsx +18 -2
  25. package/Components/Image/utils/index.ts +39 -0
  26. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  27. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  28. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  29. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  30. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  31. package/Components/Layout/TV/__tests__/index.test.tsx +20 -108
  32. package/Components/Layout/TV/index.tsx +15 -84
  33. package/Components/Layout/TV/index.web.tsx +33 -0
  34. package/Components/Layout/index.tsx +15 -11
  35. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
  36. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -113
  37. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  38. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  39. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
  40. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  41. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  42. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  43. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  44. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +37 -2
  45. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  46. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  47. package/Components/MasterCell/DefaultComponents/Toggle.tsx +9 -3
  48. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  49. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  50. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  51. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
  52. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  53. package/Components/MasterCell/dataAdapter.ts +21 -7
  54. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  55. package/Components/MasterCell/index.tsx +3 -1
  56. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  57. package/Components/MasterCell/utils/index.ts +33 -35
  58. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  59. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  60. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  61. package/Components/ModalComponent/Button/Item.tsx +82 -0
  62. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  63. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  64. package/Components/ModalComponent/Button/assets.ts +4 -0
  65. package/Components/ModalComponent/Button/index.tsx +111 -0
  66. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  67. package/Components/ModalComponent/Header/Title.tsx +70 -0
  68. package/Components/ModalComponent/Header/assets.ts +4 -0
  69. package/Components/ModalComponent/Header/index.tsx +71 -0
  70. package/Components/ModalComponent/Header/utils.ts +79 -0
  71. package/Components/ModalComponent/index.tsx +38 -0
  72. package/Components/ModalComponent/utils.ts +126 -0
  73. package/Components/Navigator/StackNavigator.tsx +57 -0
  74. package/Components/Navigator/index.ts +1 -0
  75. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
  76. package/Components/PlayerContainer/PlayerContainer.tsx +66 -31
  77. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  78. package/Components/PlayerImageBackground/index.tsx +34 -8
  79. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  80. package/Components/River/RefreshControl.tsx +55 -1
  81. package/Components/River/River.tsx +8 -5
  82. package/Components/River/TV/River.tsx +2 -25
  83. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  84. package/Components/River/__tests__/componentsMap.test.js +7 -0
  85. package/Components/River/useScreenConfiguration.ts +5 -6
  86. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  87. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  88. package/Components/RouteManager/index.tsx +4 -2
  89. package/Components/Screen/TV/hooks/index.ts +3 -0
  90. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  91. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  92. package/Components/Screen/TV/index.web.tsx +165 -0
  93. package/Components/Screen/__tests__/Screen.test.tsx +51 -36
  94. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  95. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  96. package/Components/Screen/index.tsx +110 -54
  97. package/Components/Screen/navigationHandler.ts +5 -82
  98. package/Components/Screen/orientationHandler.ts +1 -1
  99. package/Components/ScreenResolver/index.tsx +10 -13
  100. package/Components/Tabs/TV/styles.ts +1 -1
  101. package/Components/TrackedView/index.tsx +6 -3
  102. package/Components/Transitioner/Scene.tsx +32 -26
  103. package/Components/Transitioner/Transitioner.tsx +21 -28
  104. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
  105. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  106. package/Components/VideoLive/LiveImageManager.ts +70 -14
  107. package/Components/VideoLive/PlayerLiveImageComponent.tsx +132 -95
  108. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  109. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +21 -29
  110. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +66 -0
  111. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +355 -0
  112. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +161 -0
  113. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +456 -0
  114. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +182 -0
  115. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  116. package/Components/VideoModal/ModalAnimation/utils.ts +302 -0
  117. package/Components/VideoModal/PlayerDetails.tsx +6 -3
  118. package/Components/VideoModal/PlayerWrapper.tsx +133 -100
  119. package/Components/VideoModal/VideoModal.tsx +23 -40
  120. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  121. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +15 -3
  122. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +262 -170
  123. package/Components/VideoModal/hooks/useModalSize.ts +23 -16
  124. package/Components/VideoModal/utils.ts +8 -5
  125. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  126. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  127. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  128. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  129. package/Components/Viewport/utils.js +1 -1
  130. package/Components/ZappUIComponent/index.tsx +22 -12
  131. package/Components/index.js +2 -0
  132. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  133. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  134. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  135. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  136. package/Contexts/FocusableGroupContext/index.ts +7 -0
  137. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  138. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  139. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  140. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  141. package/Contexts/ScreenContext/index.tsx +95 -29
  142. package/Contexts/ScreenDataContext/index.tsx +20 -0
  143. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  144. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  145. package/Decorators/RiverResolver/index.tsx +0 -4
  146. package/Decorators/index.tsx +0 -4
  147. package/events/index.ts +1 -0
  148. package/package.json +5 -6
  149. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  150. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  151. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  152. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
  153. /package/Contexts/{index.js → index.ts} +0 -0
@@ -0,0 +1,302 @@
1
+ /* eslint-disable padding-line-between-statements */
2
+
3
+ import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
4
+
5
+ export enum ComponentAnimationType {
6
+ bottomBar = "bottomBar",
7
+ player = "player",
8
+ componentFade = "componentFade",
9
+ componentAppears = "componentAppears",
10
+ moveUpComponent = "moveUpComponent",
11
+ moveComponentHorizontal = "moveComponentHorizontal",
12
+ audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
13
+ }
14
+
15
+ export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
16
+ export const PROGRESS_BAR_HEIGHT = 3;
17
+
18
+ export const defaultAspectRatioWidth = (height: number): number =>
19
+ (height / 9) * 16;
20
+
21
+ export const getAnimationStyle = (component, animatedValue) => {
22
+ switch (component) {
23
+ case ComponentAnimationType.bottomBar: {
24
+ return { zIndex: 99, transform: [{ translateY: animatedValue }] };
25
+ }
26
+
27
+ case ComponentAnimationType.player: {
28
+ return { width: animatedValue.x, height: animatedValue.y };
29
+ }
30
+
31
+ case ComponentAnimationType.componentFade:
32
+ case ComponentAnimationType.componentAppears: {
33
+ return { opacity: animatedValue };
34
+ }
35
+
36
+ case ComponentAnimationType.moveUpComponent: {
37
+ return { transform: [{ translateY: animatedValue }] };
38
+ }
39
+
40
+ case ComponentAnimationType.audioPlayerPaddingHorizontal:
41
+ case ComponentAnimationType.moveComponentHorizontal: {
42
+ return { transform: [{ translateX: animatedValue }] };
43
+ }
44
+
45
+ default:
46
+ return null;
47
+ }
48
+ };
49
+
50
+ export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
51
+ switch (component) {
52
+ case ComponentAnimationType.bottomBar: {
53
+ return bottomTabBarHeight;
54
+ }
55
+
56
+ case ComponentAnimationType.player: {
57
+ return { x: 0, y: 0 };
58
+ }
59
+
60
+ case ComponentAnimationType.componentFade: {
61
+ return 1;
62
+ }
63
+
64
+ case ComponentAnimationType.audioPlayerPaddingHorizontal:
65
+ case ComponentAnimationType.moveComponentHorizontal:
66
+ case ComponentAnimationType.componentAppears:
67
+ case ComponentAnimationType.moveUpComponent: {
68
+ return 0;
69
+ }
70
+ }
71
+ };
72
+
73
+ export const calculateAnimationValue = (animationType, dragPosition, data) => {
74
+ const {
75
+ isAudioItem,
76
+ bottomTabBarHeight,
77
+ minimisedHeight,
78
+ minimisedWidth,
79
+ defaultValue,
80
+ moveUpValue,
81
+ moveComponentHorizontalValue,
82
+ isTablet,
83
+ isTabletLandscape,
84
+ isRTL,
85
+ fromMiniPlayer,
86
+ inlineAudioPlayer,
87
+ } = data;
88
+
89
+ switch (animationType) {
90
+ case ComponentAnimationType.bottomBar: {
91
+ if (fromMiniPlayer) {
92
+ return dragPosition < bottomTabBarHeight
93
+ ? dragPosition
94
+ : bottomTabBarHeight;
95
+ }
96
+
97
+ return dragPosition < bottomTabBarHeight
98
+ ? bottomTabBarHeight - dragPosition
99
+ : 0;
100
+ }
101
+
102
+ case ComponentAnimationType.player: {
103
+ const value =
104
+ isAudioItem && !inlineAudioPlayer
105
+ ? isTabletLandscape
106
+ ? fromMiniPlayer
107
+ ? { forWidth: 4, forHeight: 4.5 }
108
+ : { forWidth: 3, forHeight: 3 }
109
+ : { forWidth: 2, forHeight: 2 }
110
+ : isTabletLandscape
111
+ ? { forWidth: 8, forHeight: 6.5 }
112
+ : { forWidth: 3.5, forHeight: 2 };
113
+
114
+ const minWidth =
115
+ isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
116
+
117
+ if (fromMiniPlayer) {
118
+ const calculationWidth =
119
+ dragPosition * value.forWidth < minWidth
120
+ ? minWidth
121
+ : dragPosition * value.forWidth;
122
+ const calculationHeight =
123
+ dragPosition * value.forHeight < minimisedHeight
124
+ ? minimisedHeight
125
+ : dragPosition * value.forHeight;
126
+
127
+ return {
128
+ x:
129
+ calculationWidth < defaultValue.x
130
+ ? calculationWidth
131
+ : defaultValue.x,
132
+ y:
133
+ calculationHeight < defaultValue.y
134
+ ? calculationHeight
135
+ : defaultValue.y,
136
+ };
137
+ }
138
+
139
+ const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
140
+
141
+ const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
142
+
143
+ return {
144
+ x: calculationWidth > minWidth ? calculationWidth : minWidth,
145
+ y:
146
+ calculationHeight > minimisedHeight
147
+ ? calculationHeight
148
+ : minimisedHeight,
149
+ };
150
+ }
151
+
152
+ case ComponentAnimationType.componentFade: {
153
+ if (fromMiniPlayer) {
154
+ const calculation = dragPosition / (isTablet ? 200 : 150);
155
+
156
+ return calculation < 1 ? calculation : 1;
157
+ }
158
+
159
+ const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
160
+
161
+ return calculation > 0 ? calculation : 0;
162
+ }
163
+
164
+ case ComponentAnimationType.componentAppears: {
165
+ if (fromMiniPlayer) {
166
+ const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
167
+
168
+ return calculation > 0 ? calculation : 0;
169
+ }
170
+
171
+ const calculation = dragPosition / (isTablet ? 200 : 150);
172
+
173
+ return calculation < 1 ? calculation : 1;
174
+ }
175
+
176
+ case ComponentAnimationType.moveUpComponent: {
177
+ if (fromMiniPlayer) {
178
+ const calculation =
179
+ moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
180
+
181
+ return calculation < 0 ? calculation : 0;
182
+ }
183
+
184
+ const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
185
+
186
+ return calculation > moveUpValue ? calculation : moveUpValue;
187
+ }
188
+
189
+ case ComponentAnimationType.moveComponentHorizontal: {
190
+ if (fromMiniPlayer) {
191
+ const calculation = isRTL
192
+ ? moveComponentHorizontalValue - dragPosition * 2
193
+ : moveComponentHorizontalValue + dragPosition * 2;
194
+ const condition = isRTL ? calculation > 0 : calculation < 0;
195
+
196
+ return condition ? calculation : 0;
197
+ }
198
+
199
+ const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
200
+ const condition = isRTL
201
+ ? calculation < moveComponentHorizontalValue
202
+ : calculation > moveComponentHorizontalValue;
203
+
204
+ return condition ? calculation : moveComponentHorizontalValue;
205
+ }
206
+
207
+ case ComponentAnimationType.audioPlayerPaddingHorizontal: {
208
+ const padding = isRTL
209
+ ? AUDIO_PLAYER_HORIZONTAL_PADDING
210
+ : -AUDIO_PLAYER_HORIZONTAL_PADDING;
211
+
212
+ if (fromMiniPlayer) {
213
+ const calculation = isRTL
214
+ ? padding - dragPosition / 5
215
+ : padding + dragPosition / 5;
216
+ const condition = isRTL ? calculation > 0 : calculation < 0;
217
+
218
+ return condition ? calculation : 0;
219
+ }
220
+
221
+ const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
222
+ const condition = isRTL ? calculation < padding : calculation > padding;
223
+
224
+ return condition ? calculation : padding;
225
+ }
226
+ }
227
+ };
228
+
229
+ export const gestureListenerHelper = (data) => {
230
+ const {
231
+ listenerValue,
232
+ preparedValue,
233
+ animationType,
234
+ animatedValue,
235
+ calculationData,
236
+ modalSnapPoint,
237
+ startComponentsAnimationDistance,
238
+ startComponentsAnimation,
239
+ setStartComponentsAnimation,
240
+ getAnimationValue,
241
+ } = data;
242
+
243
+ if (calculationData.fromMiniPlayer) {
244
+ if (listenerValue <= 0) {
245
+ if (
246
+ preparedValue >= 0 &&
247
+ preparedValue <= modalSnapPoint - startComponentsAnimationDistance
248
+ ) {
249
+ !startComponentsAnimation && setStartComponentsAnimation(true);
250
+
251
+ animatedValue.setValue(
252
+ calculateAnimationValue(animationType, preparedValue, calculationData)
253
+ );
254
+ } else {
255
+ animatedValue.setValue(calculationData.defaultValue);
256
+ startComponentsAnimation && setStartComponentsAnimation(false);
257
+ }
258
+ } else {
259
+ const value = getAnimationValue(
260
+ animationType,
261
+ PlayerAnimationStateEnum.minimize
262
+ ).toValue;
263
+
264
+ animatedValue.setValue(value);
265
+ }
266
+ } else {
267
+ if (preparedValue >= startComponentsAnimationDistance) {
268
+ !startComponentsAnimation && setStartComponentsAnimation(true);
269
+ const value = Math.round(
270
+ preparedValue - startComponentsAnimationDistance
271
+ );
272
+
273
+ animatedValue.setValue(
274
+ calculateAnimationValue(animationType, value, calculationData)
275
+ );
276
+ } else {
277
+ animatedValue.setValue(calculationData.defaultValue);
278
+ startComponentsAnimation && setStartComponentsAnimation(false);
279
+ }
280
+ }
281
+ };
282
+
283
+ export const setScrollModalAnimatedValue = (
284
+ animatedValue,
285
+ value,
286
+ setLastSnap
287
+ ) => {
288
+ setLastSnap(value);
289
+ animatedValue.setValue(value);
290
+ };
291
+
292
+ export const resetScrollAnimatedValues = (
293
+ lastScrollY,
294
+ lastScrollYValue,
295
+ dragScrollY,
296
+ dragVideoPlayerY
297
+ ) => {
298
+ lastScrollY.setValue(0);
299
+ lastScrollYValue.current = 0;
300
+ dragScrollY.setValue(0);
301
+ dragVideoPlayerY.setValue(0);
302
+ };
@@ -23,6 +23,8 @@ const containerStyle = ({
23
23
  backgroundColor: modal_background_color,
24
24
  });
25
25
 
26
+ // const audioMarginStyle = { marginTop: 0, marginBottom: 0 };
27
+
26
28
  export const PlayerDetails = ({
27
29
  entry,
28
30
  style,
@@ -40,12 +42,12 @@ export const PlayerDetails = ({
40
42
  : {};
41
43
 
42
44
  // Animation setup
43
- const translateY = useRef(new Animated.Value(100)).current;
45
+ const translateY = useRef(new Animated.Value(50)).current;
44
46
  const opacity = useRef(new Animated.Value(0)).current;
45
47
 
46
48
  const runAnimation = () => {
47
49
  Animated.timing(translateY, {
48
- toValue: 0,
50
+ toValue: -30,
49
51
  duration: 500,
50
52
  easing: Easing.inOut(Easing.ease),
51
53
  useNativeDriver: true,
@@ -61,7 +63,7 @@ export const PlayerDetails = ({
61
63
 
62
64
  useEffect(() => {
63
65
  if (isAudioPlayer) {
64
- setTimeout(() => runAnimation(), 1000);
66
+ setTimeout(() => runAnimation(), 1500);
65
67
  }
66
68
  }, [isAudioPlayer]);
67
69
 
@@ -75,6 +77,7 @@ export const PlayerDetails = ({
75
77
  transform: [{ translateY }],
76
78
  opacity,
77
79
  },
80
+ // isAudioPlayer && audioMarginStyle,
78
81
  ]}
79
82
  >
80
83
  {screenData && (
@@ -1,18 +1,32 @@
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
-
13
- type Dimensions = {
14
- width: number;
15
- height: number;
17
+ import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
18
+
19
+ import {
20
+ AnimatedScrollModal,
21
+ AnimatedVideoPlayerComponent,
22
+ AnimationComponent,
23
+ ComponentAnimationType,
24
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
25
+
26
+ type DimensionsT = {
27
+ width: number | string;
28
+ height: number | string | undefined;
29
+ aspectRatio?: number;
16
30
  };
17
31
 
18
32
  type Configuration = {
@@ -23,20 +37,22 @@ type Configuration = {
23
37
 
24
38
  type Props = {
25
39
  entry: ZappEntry;
26
- style: ViewStyle & Dimensions;
40
+ style: ViewStyle & DimensionsT;
27
41
  containerStyle?: ViewStyle;
28
42
  inline?: boolean;
29
43
  docked?: boolean;
44
+ pip?: boolean;
30
45
  isModal?: boolean;
31
46
  fullscreen?: boolean;
32
47
  isTabletPortrait?: boolean;
33
- children: (playerDimensions: Dimensions) => React.ReactNode;
48
+ children: (playerDimensions: DimensionsT) => React.ReactNode;
34
49
  configuration: Configuration;
35
50
  };
36
51
 
37
52
  const defaultStyles = StyleSheet.create({
38
53
  playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
39
54
  playerDetails: { flex: 1, paddingTop: 20 },
55
+ flex: { flex: 1 },
40
56
  });
41
57
 
42
58
  const orientationStyles = StyleSheet.create({
@@ -52,6 +68,15 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
52
68
  return orientationStyles.portrait;
53
69
  };
54
70
 
71
+ const getScreenAspectRatio = () => {
72
+ const { width, height } = Dimensions.get("screen");
73
+
74
+ const longEdge = Math.max(width, height);
75
+ const shortEdge = Math.min(width, height);
76
+
77
+ return longEdge / shortEdge;
78
+ };
79
+
55
80
  const safeAreaStyles = (
56
81
  configuration: Configuration,
57
82
  isTablet: boolean
@@ -66,9 +91,21 @@ const safeAreaStyles = (
66
91
  };
67
92
  };
68
93
 
94
+ const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
95
+ if (isTablet) {
96
+ return ["top"];
97
+ }
98
+
99
+ if (!isInlineModal && Platform.OS === "android") {
100
+ return [];
101
+ }
102
+
103
+ return ["top"];
104
+ };
105
+
69
106
  const getTabletWidth = (
70
107
  configuration: Configuration,
71
- dimensions: Dimensions
108
+ dimensions: DimensionsT
72
109
  ) => {
73
110
  const tablet_landscape_sidebar_width =
74
111
  configuration?.tablet_landscape_sidebar_width;
@@ -78,41 +115,14 @@ const getTabletWidth = (
78
115
  const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
79
116
 
80
117
  if (tablet_landscape_sidebar_width?.includes("%")) {
81
- return width * (1 - sidebarWidth / 100);
118
+ return Number(width) * (1 - sidebarWidth / 100);
82
119
  }
83
120
 
84
121
  if (Number.isNaN(sidebarWidth)) {
85
- return width * 0.65;
122
+ return Number(width) * 0.65;
86
123
  }
87
124
 
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
- const getEdges = (
98
- isTablet: boolean,
99
- docked: boolean,
100
- isInlineModal: boolean
101
- ) => {
102
- if (isTablet) {
103
- return docked ? ["right", "left"] : ["top"];
104
- }
105
-
106
- // mobile
107
- if (isInlineModal && docked) {
108
- return ["bottom"];
109
- }
110
-
111
- if (!isInlineModal && Platform.OS === "android") {
112
- return [];
113
- }
114
-
115
- return ["top"];
125
+ return Number(width) - sidebarWidth;
116
126
  };
117
127
 
118
128
  export const PlayerWrapper = (props: Props) => {
@@ -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,83 +147,105 @@ 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: undefined,
153
155
  }),
154
- [isInlineModal, docked, isTabletLandscape, tabletWidth, style, screenWidth]
156
+ [isInlineModal, tabletWidth, 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
164
  }),
165
- [isInlineModal, docked, containerDimensions]
165
+ [baseDimensions, isInlineModal, pip]
166
+ );
167
+
168
+ const containerDimensions: DimensionsT = React.useMemo(
169
+ () => ({
170
+ ...baseDimensions,
171
+ aspectRatio:
172
+ isInlineModal && docked ? undefined : playerDimensions.aspectRatio,
173
+ }),
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
 
184
+ const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
185
+
175
186
  return (
176
- <WrapperView
177
- edges={getEdges(isTablet, docked, isInlineModal) as readonly Edge[]}
178
- style={[
179
- directionStyles(isTabletLandscape),
180
- safeAreaStyles(configuration, isTablet),
181
- style,
182
- playerDimesionsHack,
183
- ]}
184
- >
185
- <ScreenContextProvider pathname={"videoModal"}>
186
- <PathnameContext.Provider value={"videoModal"}>
187
- <View
188
- testID={`${entry?.id}-player-container`}
189
- style={[
190
- defaultStyles.playerContainer,
191
- containerDimensions,
192
- containerStyle,
193
- {
194
- height:
195
- isInlineModal && !docked
196
- ? containerDimensions.height + 10
197
- : containerDimensions.height,
198
- },
199
- playerDimesionsHack,
200
- ]}
187
+ <PathnameContext.Provider value={pathname}>
188
+ <ScreenContextProvider pathname={pathname}>
189
+ <WrapperView
190
+ edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
191
+ style={[
192
+ safeAreaStyles(configuration, isTablet),
193
+ style,
194
+ playerDimesionsHack,
195
+ ]}
196
+ >
197
+ <AnimationComponent
198
+ animationType={ComponentAnimationType.moveUpComponent}
199
+ additionalData={{ saveArea: true }}
200
+ style={[directionStyles(isTabletLandscape), defaultStyles.flex]}
201
201
  >
202
- {children(childrenStyles)}
203
- </View>
204
- {isInlineModal && !docked ? (
205
- <PlayerDetails
206
- configuration={configuration}
207
- style={defaultStyles.playerDetails}
208
- entry={entry}
209
- isTabletLandscape={isTabletLandscape}
210
- />
211
- ) : (
212
- <View style={defaultStyles.playerDetails} />
213
- )}
214
- </PathnameContext.Provider>
202
+ <PathnameContext.Provider value={pathname}>
203
+ <ScreenContextProvider pathname={pathname}>
204
+ <View
205
+ testID={`${entry?.id}-player-container`}
206
+ style={[
207
+ defaultStyles.playerContainer,
208
+ containerDimensions,
209
+ containerStyle,
210
+ playerDimesionsHack,
211
+ ]}
212
+ >
213
+ <AnimationComponent
214
+ animationType={ComponentAnimationType.moveUpComponent}
215
+ style={isTabletLandscape ? defaultStyles.flex : undefined}
216
+ additionalData={{
217
+ useLayoutMeasure: isTabletLandscape,
218
+ disableAnimatedComponent: !isTabletLandscape,
219
+ resetAnimationValue: isTabletLandscape && docked,
220
+ }}
221
+ >
222
+ <AnimatedVideoPlayerComponent>
223
+ {children(childrenStyles)}
224
+ </AnimatedVideoPlayerComponent>
225
+ </AnimationComponent>
226
+ </View>
227
+ <AnimatedScrollModal>
228
+ {isInlineModal && !docked ? (
229
+ <AnimationComponent
230
+ animationType={ComponentAnimationType.componentFade}
231
+ style={defaultStyles.flex}
232
+ >
233
+ <PlayerDetails
234
+ configuration={configuration}
235
+ style={defaultStyles.playerDetails}
236
+ entry={entry}
237
+ isTabletLandscape={isTabletLandscape}
238
+ />
239
+ </AnimationComponent>
240
+ ) : (
241
+ <View style={defaultStyles.playerDetails} />
242
+ )}
243
+ </AnimatedScrollModal>
244
+ </ScreenContextProvider>
245
+ </PathnameContext.Provider>
246
+ </AnimationComponent>
247
+ </WrapperView>
215
248
  </ScreenContextProvider>
216
- </WrapperView>
249
+ </PathnameContext.Provider>
217
250
  );
218
251
  };