@applicaster/zapp-react-native-ui-components 15.0.0-rc.13 → 15.0.0-rc.131

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 (189) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/BaseFocusable/index.ios.ts +12 -2
  3. package/Components/Cell/Cell.tsx +14 -3
  4. package/Components/Cell/CellWithFocusable.tsx +9 -0
  5. package/Components/Cell/FocusableWrapper.tsx +3 -0
  6. package/Components/Cell/TvOSCellComponent.tsx +30 -6
  7. package/Components/Focusable/Focusable.tsx +4 -2
  8. package/Components/Focusable/FocusableTvOS.tsx +18 -1
  9. package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
  10. package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
  11. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +39 -28
  12. package/Components/GeneralContentScreen/__tests__/GeneralContentScreen.test.tsx +104 -0
  13. package/Components/GeneralContentScreen/utils/__tests__/getScreenDataSource.test.ts +19 -0
  14. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
  15. package/Components/GeneralContentScreen/utils/getScreenDataSource.ts +9 -0
  16. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -6
  17. package/Components/HandlePlayable/HandlePlayable.tsx +33 -94
  18. package/Components/HandlePlayable/const.ts +3 -0
  19. package/Components/HandlePlayable/utils.ts +105 -0
  20. package/Components/HookRenderer/HookRenderer.tsx +40 -10
  21. package/Components/HookRenderer/__tests__/HookRenderer.test.tsx +60 -0
  22. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  23. package/Components/Layout/TV/NavBarContainer.tsx +1 -10
  24. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  25. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
  26. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
  27. package/Components/Layout/TV/index.tsx +3 -4
  28. package/Components/Layout/TV/index.web.tsx +3 -4
  29. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  30. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
  31. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
  32. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
  33. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
  34. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
  35. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
  36. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
  37. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
  38. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
  39. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  40. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  41. package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
  42. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  43. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  44. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  45. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  46. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +352 -0
  47. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +136 -0
  48. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +43 -22
  49. package/Components/MasterCell/DefaultComponents/PressableView.tsx +196 -0
  50. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
  51. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
  52. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
  53. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
  54. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  55. package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
  56. package/Components/MasterCell/DefaultComponents/Text/index.tsx +10 -14
  57. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  58. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +46 -0
  59. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +126 -0
  60. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ButtonContainerView.ts +23 -0
  61. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
  62. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
  63. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +32 -0
  64. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +191 -0
  65. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +140 -0
  66. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +222 -0
  67. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
  68. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +104 -0
  69. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
  70. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +73 -0
  71. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +86 -0
  72. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +35 -48
  73. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
  74. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +39 -144
  75. package/Components/MasterCell/elementMapper.tsx +1 -0
  76. package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
  77. package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
  78. package/Components/MasterCell/index.tsx +2 -0
  79. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  80. package/Components/MasterCell/utils/index.ts +61 -31
  81. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  82. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  83. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
  84. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
  85. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  86. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  87. package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
  88. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  89. package/Components/PlayerContainer/PlayerContainer.tsx +43 -64
  90. package/Components/PlayerImageBackground/index.tsx +3 -22
  91. package/Components/PreloaderWrapper/__tests__/index.test.tsx +26 -0
  92. package/Components/PreloaderWrapper/index.tsx +15 -0
  93. package/Components/River/ComponentsMap/ComponentsMap.tsx +16 -0
  94. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  95. package/Components/River/RefreshControl.tsx +36 -13
  96. package/Components/River/RiverItem.tsx +26 -20
  97. package/Components/River/TV/River.tsx +31 -14
  98. package/Components/River/TV/index.tsx +8 -4
  99. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  100. package/Components/River/TV/utils/index.ts +4 -0
  101. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  102. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  103. package/Components/River/__tests__/componentsMap.test.js +38 -0
  104. package/Components/Screen/TV/index.web.tsx +4 -2
  105. package/Components/Screen/__tests__/Screen.test.tsx +66 -42
  106. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  107. package/Components/Screen/hooks.ts +75 -6
  108. package/Components/Screen/index.tsx +9 -4
  109. package/Components/Screen/navigationHandler.ts +49 -24
  110. package/Components/Screen/orientationHandler.ts +10 -13
  111. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +46 -0
  112. package/Components/ScreenFeedLoader/__tests__/ScreenFeedLoader.test.tsx +94 -0
  113. package/Components/ScreenFeedLoader/index.ts +1 -0
  114. package/Components/ScreenResolver/__tests__/screenResolver.test.js +24 -0
  115. package/Components/ScreenResolver/hooks/index.ts +3 -0
  116. package/Components/ScreenResolver/hooks/useGetComponent.ts +15 -0
  117. package/Components/ScreenResolver/hooks/useScreenComponentResolver.tsx +90 -0
  118. package/Components/ScreenResolver/index.tsx +15 -111
  119. package/Components/ScreenResolver/utils/__tests__/getScreenTypeProps.test.ts +45 -0
  120. package/Components/ScreenResolver/utils/getScreenTypeProps.ts +43 -0
  121. package/Components/ScreenResolver/utils/index.ts +1 -0
  122. package/Components/ScreenResolver/withDefaultScreenContext.tsx +16 -0
  123. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +25 -0
  124. package/Components/ScreenResolverFeedProvider/__tests__/ScreenResolverFeedProvider.test.tsx +44 -0
  125. package/Components/ScreenResolverFeedProvider/index.ts +1 -0
  126. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  127. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  128. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
  129. package/Components/Tabs/TV/Tabs.tsx +20 -3
  130. package/Components/Tabs/TabContent.tsx +7 -4
  131. package/Components/Transitioner/Scene.tsx +10 -3
  132. package/Components/Transitioner/index.js +3 -3
  133. package/Components/VideoLive/LiveImageManager.ts +199 -54
  134. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -33
  135. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +2 -17
  136. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  137. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  138. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  139. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  140. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  141. package/Components/VideoModal/VideoModal.tsx +1 -5
  142. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  143. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  144. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  145. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  146. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  147. package/Components/VideoModal/utils.ts +19 -9
  148. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
  149. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  150. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  151. package/Components/ZappUIComponent/index.tsx +12 -6
  152. package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
  153. package/Components/index.js +1 -1
  154. package/Contexts/ScreenContext/__tests__/index.test.tsx +57 -0
  155. package/Contexts/ScreenContext/index.tsx +71 -19
  156. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  157. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  158. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
  159. package/Contexts/index.ts +0 -2
  160. package/Decorators/Analytics/index.tsx +6 -5
  161. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  162. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  163. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
  164. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
  165. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
  166. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  167. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  168. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  169. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
  170. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  171. package/Helpers/DataSourceHelper/index.ts +19 -0
  172. package/events/index.ts +3 -0
  173. package/events/scrollEndReached.ts +15 -0
  174. package/index.d.ts +7 -0
  175. package/package.json +6 -5
  176. package/Components/MasterCell/DefaultComponents/Text/utils/__tests__/withAdjustedLineHeight.test.ts +0 -46
  177. package/Components/MasterCell/DefaultComponents/Text/utils/index.ts +0 -21
  178. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
  179. package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
  180. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  181. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  182. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
  183. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  184. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  185. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  186. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  187. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  188. package/Helpers/DataSourceHelper/index.js +0 -19
  189. /package/Components/HookRenderer/{index.tsx → index.ts} +0 -0
@@ -1,500 +0,0 @@
1
- import React, { useRef, useState } from "react";
2
- import { Animated, View } from "react-native";
3
-
4
- import { useSafeAreaInsets } from "react-native-safe-area-context";
5
-
6
- import {
7
- PlayerAnimationStateEnum,
8
- useModalAnimationContext,
9
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
10
-
11
- import {
12
- useDimensions,
13
- useGetBottomTabBarHeight,
14
- useNavigation,
15
- } from "@applicaster/zapp-react-native-utils/reactHooks";
16
- import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
17
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
- import { useAppState } from "@applicaster/zapp-react-native-utils/reactHooks/app";
19
-
20
- import {
21
- AUDIO_PLAYER_HORIZONTAL_PADDING,
22
- ComponentAnimationType,
23
- defaultAspectRatioWidth,
24
- gestureListenerHelper,
25
- getAnimationDefaultValue,
26
- getAnimationStyle,
27
- getMoveUpValue,
28
- } from "./utils";
29
-
30
- import { DURATION_TO_MINIMIZE, DEFAULT_DURATION_FOR_ANIMATION } from "./const";
31
-
32
- type Props = {
33
- animationType: string;
34
- children: React.ReactNode;
35
- style?: Record<string, any>;
36
- additionalData?: { [key: string]: any };
37
- };
38
-
39
- export const AnimationView = ({
40
- animationType,
41
- style,
42
- children,
43
- additionalData = {},
44
- }: Props) => {
45
- const {
46
- startComponentsAnimation,
47
- setStartComponentsAnimation,
48
- playerAnimationState,
49
- minimisedHeight,
50
- animatedValues: { dragScrollY, dragVideoPlayerY },
51
- lastScrollYValue,
52
- scrollPosition,
53
- tabletLandscapePlayerTopPosition,
54
- setTabletLandscapePlayerTopPosition,
55
- modalSnapPoints,
56
- startComponentsAnimationDistance,
57
- progressBarHeight,
58
- } = useModalAnimationContext();
59
-
60
- const isRTL = useIsRTL();
61
- const isAppActive = useAppState(true);
62
-
63
- const {
64
- width: screenWidth,
65
- deviceInfo: { isTablet, isTabletLandscape },
66
- } = useDimensions("window", {
67
- deviceInfo: true,
68
- updateForInactiveScreens: true,
69
- });
70
-
71
- const { videoModalState } = useNavigation();
72
- const { mode: videoModalMode, item: videoModalItem } = videoModalState;
73
-
74
- const insets = useSafeAreaInsets();
75
- const bottomTabBarHeight = useGetBottomTabBarHeight() + (insets.bottom || 0);
76
- const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
77
- const animationComponentRef = useRef(null);
78
-
79
- // retrieving top position of the player for tablet landscape mode
80
- const measureView = React.useCallback(() => {
81
- if (isTabletLandscape && tabletLandscapePlayerTopPosition === 0) {
82
- animationComponentRef.current.measure(
83
- (_x, _y, _width, _height, _pageX, pageY) => {
84
- setTabletLandscapePlayerTopPosition(pageY - 20);
85
- }
86
- );
87
- }
88
- }, [tabletLandscapePlayerTopPosition]);
89
-
90
- const [defaultValue, setDefaultValue] = useState<any>(
91
- getAnimationDefaultValue(animationType, bottomTabBarHeight)
92
- );
93
-
94
- const isAudioItem = React.useMemo(
95
- () =>
96
- videoModalItem?.content?.type?.includes?.("audio") ||
97
- videoModalItem?.type?.value?.includes?.("audio"),
98
- [videoModalItem]
99
- );
100
-
101
- const inlineAudioPlayer = additionalData.inlineAudioPlayer;
102
-
103
- const moveUpValue = getMoveUpValue({
104
- additionalData,
105
- insets,
106
- isAudioItem,
107
- progressBarHeight,
108
- isTablet,
109
- isTabletLandscape,
110
- tabletLandscapePlayerTopPosition,
111
- });
112
-
113
- const moveComponentHorizontalValue = additionalData.moveValue
114
- ? isRTL
115
- ? additionalData.moveValue
116
- : -additionalData.moveValue
117
- : 0;
118
-
119
- const animationValueType: string =
120
- animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
121
-
122
- const getAnimationValue = React.useCallback(
123
- (animationType, state) => {
124
- const defaultConfig = {
125
- toValue: 0,
126
- duration:
127
- state === PlayerAnimationStateEnum.minimize
128
- ? DURATION_TO_MINIMIZE
129
- : DEFAULT_DURATION_FOR_ANIMATION,
130
- useNativeDriver: true,
131
- };
132
-
133
- switch (animationType) {
134
- case ComponentAnimationType.bottomBar: {
135
- if (state === PlayerAnimationStateEnum.minimize) {
136
- return defaultConfig;
137
- }
138
-
139
- defaultConfig.toValue = defaultValue;
140
-
141
- return defaultConfig;
142
- }
143
-
144
- case ComponentAnimationType.player: {
145
- if (state === PlayerAnimationStateEnum.minimize) {
146
- const minWidth =
147
- isAudioItem && !inlineAudioPlayer
148
- ? minimisedHeight
149
- : minimisedWidth;
150
-
151
- return {
152
- ...defaultConfig,
153
- toValue: { x: minWidth, y: minimisedHeight },
154
- useNativeDriver: false,
155
- };
156
- }
157
-
158
- return {
159
- ...defaultConfig,
160
- toValue: defaultValue,
161
- useNativeDriver: false,
162
- };
163
- }
164
-
165
- case ComponentAnimationType.componentFade: {
166
- if (state === PlayerAnimationStateEnum.minimize) {
167
- defaultConfig.toValue = 0;
168
-
169
- return defaultConfig;
170
- }
171
-
172
- defaultConfig.toValue = defaultValue;
173
-
174
- return defaultConfig;
175
- }
176
-
177
- case ComponentAnimationType.componentAppears: {
178
- if (state === PlayerAnimationStateEnum.minimize) {
179
- defaultConfig.toValue = 1;
180
-
181
- return defaultConfig;
182
- }
183
-
184
- defaultConfig.toValue = defaultValue;
185
-
186
- return defaultConfig;
187
- }
188
-
189
- case ComponentAnimationType.moveUpComponent: {
190
- if (state === PlayerAnimationStateEnum.minimize) {
191
- defaultConfig.toValue = moveUpValue;
192
-
193
- return defaultConfig;
194
- }
195
-
196
- defaultConfig.toValue = defaultValue;
197
-
198
- return defaultConfig;
199
- }
200
-
201
- case ComponentAnimationType.moveComponentHorizontal: {
202
- if (state === PlayerAnimationStateEnum.minimize) {
203
- defaultConfig.toValue = moveComponentHorizontalValue;
204
-
205
- return defaultConfig;
206
- }
207
-
208
- defaultConfig.toValue = defaultValue;
209
-
210
- return defaultConfig;
211
- }
212
-
213
- case ComponentAnimationType.audioPlayerPaddingHorizontal: {
214
- if (state === PlayerAnimationStateEnum.minimize) {
215
- defaultConfig.toValue = isRTL
216
- ? AUDIO_PLAYER_HORIZONTAL_PADDING
217
- : -AUDIO_PLAYER_HORIZONTAL_PADDING;
218
-
219
- return defaultConfig;
220
- }
221
-
222
- defaultConfig.toValue = 0;
223
-
224
- return defaultConfig;
225
- }
226
-
227
- default:
228
- return defaultConfig;
229
- }
230
- },
231
- [
232
- defaultValue,
233
- minimisedWidth,
234
- minimisedHeight,
235
- isAudioItem,
236
- moveUpValue,
237
- moveComponentHorizontalValue,
238
- isRTL,
239
- inlineAudioPlayer,
240
- ]
241
- );
242
-
243
- const getInitialValue = React.useCallback(() => {
244
- const { mode: videoModalMode, previousMode } = videoModalState;
245
- const mode = videoModalMode === "PIP" ? previousMode : videoModalMode;
246
-
247
- switch (mode) {
248
- case "MINIMIZED":
249
- return getAnimationValue(
250
- animationType,
251
- PlayerAnimationStateEnum.minimize
252
- ).toValue;
253
-
254
- case "MAXIMIZED":
255
- default:
256
- return getAnimationValue(
257
- animationType,
258
- PlayerAnimationStateEnum.maximize
259
- ).toValue;
260
- }
261
- }, [defaultValue, videoModalState]);
262
-
263
- const animatedValue = useRef(
264
- new Animated[animationValueType](getInitialValue())
265
- ).current;
266
-
267
- const calculationData = React.useMemo(
268
- () => ({
269
- isAudioItem,
270
- bottomTabBarHeight,
271
- minimisedHeight,
272
- minimisedWidth,
273
- defaultValue,
274
- moveUpValue,
275
- moveComponentHorizontalValue,
276
- isTablet,
277
- isTabletLandscape,
278
- isRTL,
279
- fromMiniPlayer: videoModalMode === "MINIMIZED",
280
- inlineAudioPlayer,
281
- }),
282
- [
283
- bottomTabBarHeight,
284
- minimisedHeight,
285
- minimisedWidth,
286
- defaultValue,
287
- moveUpValue,
288
- moveComponentHorizontalValue,
289
- videoModalMode,
290
- isAudioItem,
291
- isTablet,
292
- isTabletLandscape,
293
- isRTL,
294
- inlineAudioPlayer,
295
- ]
296
- );
297
-
298
- React.useEffect(() => {
299
- if (additionalData.resetAnimationValue) {
300
- animatedValue.setValue(defaultValue);
301
- }
302
- }, [additionalData.resetAnimationValue, defaultValue]);
303
-
304
- React.useEffect(() => {
305
- if (animationType === ComponentAnimationType.player) {
306
- let width, height;
307
-
308
- if (additionalData.aspectRatio) {
309
- width = isTabletLandscape ? additionalData.width : screenWidth;
310
-
311
- height =
312
- (isTabletLandscape ? additionalData.width : screenWidth) /
313
- additionalData.aspectRatio;
314
- } else {
315
- width =
316
- typeof additionalData.width === "number" && additionalData.width;
317
-
318
- height =
319
- typeof additionalData.height === "number" && additionalData.height;
320
- }
321
-
322
- if (
323
- (videoModalMode === "MAXIMIZED" || videoModalMode === "MINIMIZED") &&
324
- defaultValue.x !== screenWidth &&
325
- width &&
326
- height
327
- ) {
328
- const value = { x: width, y: height };
329
- setDefaultValue(value);
330
- animatedValue.setValue(value);
331
- }
332
- }
333
- }, [screenWidth]);
334
-
335
- React.useEffect(() => {
336
- const { mode, previousMode } = videoModalState;
337
-
338
- if (mode === "MINIMIZED" && previousMode === "MAXIMIZED") {
339
- // set animation to the minimize values if moving from the player to another screen
340
- if (playerAnimationState === null) {
341
- const value = getAnimationValue(
342
- animationType,
343
- PlayerAnimationStateEnum.minimize
344
- ).toValue;
345
-
346
- animatedValue.setValue(value);
347
- }
348
- }
349
- }, [
350
- animatedValue,
351
- animationType,
352
- getAnimationValue,
353
- playerAnimationState,
354
- videoModalState,
355
- ]);
356
-
357
- React.useEffect(() => {
358
- if (
359
- playerAnimationState === PlayerAnimationStateEnum.minimize &&
360
- startComponentsAnimation &&
361
- videoModalMode === "MAXIMIZED"
362
- ) {
363
- Animated.timing(
364
- animatedValue,
365
- getAnimationValue(animationType, playerAnimationState)
366
- ).start();
367
- } else if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
368
- animatedValue.setValue(defaultValue);
369
- }
370
- }, [playerAnimationState, startComponentsAnimation, defaultValue]);
371
-
372
- React.useEffect(() => {
373
- const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
374
- ({ value }) => {
375
- if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
376
- const preparedValue = Math.round(Math.abs(value));
377
-
378
- gestureListenerHelper({
379
- listenerValue: value,
380
- preparedValue,
381
- animationType,
382
- animatedValue,
383
- calculationData,
384
- modalSnapPoint: modalSnapPoints[1],
385
- startComponentsAnimationDistance,
386
- startComponentsAnimation,
387
- setStartComponentsAnimation,
388
- getAnimationValue,
389
- });
390
- }
391
- }
392
- );
393
-
394
- const dragListenerId = dragScrollY.addListener(({ value }) => {
395
- if (
396
- scrollPosition.current === 0 &&
397
- playerAnimationState === PlayerAnimationStateEnum.drag_scroll
398
- ) {
399
- const preparedValue = Math.round(
400
- Math.abs(value) - lastScrollYValue.current
401
- );
402
-
403
- gestureListenerHelper({
404
- listenerValue: value,
405
- preparedValue,
406
- animationType,
407
- animatedValue,
408
- calculationData,
409
- modalSnapPoint: modalSnapPoints[1],
410
- startComponentsAnimationDistance,
411
- startComponentsAnimation,
412
- setStartComponentsAnimation,
413
- getAnimationValue,
414
- });
415
- }
416
- });
417
-
418
- return () => {
419
- dragScrollY.removeListener(dragListenerId);
420
- dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
421
- };
422
- }, [playerAnimationState, calculationData, startComponentsAnimation]);
423
-
424
- const preparedStyles = Array.isArray(style) ? style : [style];
425
-
426
- return (
427
- <Animated.View
428
- onLayout={additionalData.useLayoutMeasure ? measureView : undefined}
429
- ref={animationComponentRef}
430
- style={[
431
- ...preparedStyles,
432
- (videoModalMode === "MAXIMIZED" ||
433
- videoModalMode === "MINIMIZED" ||
434
- (videoModalMode === "PIP" && isAppActive)) &&
435
- getAnimationStyle(animationType, animatedValue),
436
- ]}
437
- >
438
- {children}
439
- </Animated.View>
440
- );
441
- };
442
-
443
- export const AnimationComponent = (props: Props) => {
444
- const { additionalData = {}, style } = props;
445
-
446
- const {
447
- videoModalState: { visible },
448
- } = useNavigation();
449
-
450
- if (additionalData?.disableAnimatedComponent) {
451
- return <>{props.children}</>;
452
- }
453
-
454
- const useAnimation =
455
- visible && !additionalData.disableAnimatedComponent && !isTV();
456
-
457
- const isReactFragment = !useAnimation && !style;
458
-
459
- const Component = useAnimation
460
- ? AnimationView
461
- : style
462
- ? View
463
- : React.Fragment;
464
-
465
- if (
466
- additionalData.extraAnimation &&
467
- typeof additionalData.extraAnimation === "object" &&
468
- !Array.isArray(additionalData.extraAnimation) &&
469
- !!Object.keys(additionalData.extraAnimation).length
470
- ) {
471
- const animationType = Object.keys(additionalData.extraAnimation)[0];
472
- const animationProps = additionalData.extraAnimation[animationType] || {};
473
- delete additionalData.extraAnimation[animationType];
474
-
475
- return (
476
- // @ts-ignore
477
- <Component {...(isReactFragment ? null : props)}>
478
- <AnimationComponent
479
- {...animationProps}
480
- animationType={animationType}
481
- additionalData={{
482
- ...animationProps.additionalData,
483
- extraAnimation:
484
- !!Object.keys(additionalData.extraAnimation).length &&
485
- additionalData.extraAnimation,
486
- }}
487
- >
488
- {props.children}
489
- </AnimationComponent>
490
- </Component>
491
- );
492
- }
493
-
494
- if (isReactFragment) {
495
- // @ts-ignore
496
- return <Component>{props.children}</Component>;
497
- }
498
-
499
- return <Component {...props}>{props.children}</Component>;
500
- };
@@ -1,108 +0,0 @@
1
- import { getMoveUpValue } from "../utils";
2
-
3
- describe("getMoveUpValue", () => {
4
- it("returns correct value when additionalData.saveArea is true and isAudioItem is false", () => {
5
- const result = getMoveUpValue({
6
- additionalData: { saveArea: true },
7
- insets: { top: 20 },
8
- isAudioItem: false,
9
- progressBarHeight: 10,
10
- isTablet: false,
11
- isTabletLandscape: false,
12
- inlineAudioPlayer: false,
13
- tabletLandscapePlayerTopPosition: 100,
14
- });
15
-
16
- expect(result).toBe(-20 + 10);
17
- });
18
-
19
- it("returns correct value when additionalData.saveArea is true and isAudioItem is true", () => {
20
- const result = getMoveUpValue({
21
- additionalData: { saveArea: true },
22
- insets: { top: 15 },
23
- isAudioItem: true,
24
- progressBarHeight: 5,
25
- isTablet: false,
26
- isTabletLandscape: false,
27
- inlineAudioPlayer: false,
28
- tabletLandscapePlayerTopPosition: 100,
29
- });
30
-
31
- expect(result).toBe(-15 + 0);
32
- });
33
-
34
- it("returns correct value for audio item (tablet or not)", () => {
35
- const result = getMoveUpValue({
36
- additionalData: { marginTop: 30 },
37
- insets: { top: 0 },
38
- isAudioItem: true,
39
- progressBarHeight: 0,
40
- isTablet: false,
41
- isTabletLandscape: false,
42
- inlineAudioPlayer: false,
43
- tabletLandscapePlayerTopPosition: 0,
44
- });
45
-
46
- expect(result).toBe(-30);
47
- });
48
-
49
- it("returns correct value for tablet landscape with inline audio player", () => {
50
- const result = getMoveUpValue({
51
- additionalData: {},
52
- insets: { top: 0 },
53
- isAudioItem: true,
54
- progressBarHeight: 8,
55
- isTablet: true,
56
- isTabletLandscape: true,
57
- inlineAudioPlayer: true,
58
- tabletLandscapePlayerTopPosition: 50,
59
- });
60
-
61
- expect(result).toBe(-0);
62
- });
63
-
64
- it("returns correct value for tablet landscape without audio item", () => {
65
- const result = getMoveUpValue({
66
- additionalData: {},
67
- insets: { top: 0 },
68
- isAudioItem: false,
69
- progressBarHeight: 12,
70
- isTablet: true,
71
- isTabletLandscape: true,
72
- inlineAudioPlayer: false,
73
- tabletLandscapePlayerTopPosition: 60,
74
- });
75
-
76
- expect(result).toBe(-60 + 12);
77
- });
78
-
79
- it("returns -130 for tablet portrait (not landscape)", () => {
80
- const result = getMoveUpValue({
81
- additionalData: {},
82
- insets: { top: 0 },
83
- isAudioItem: false,
84
- progressBarHeight: 0,
85
- isTablet: true,
86
- isTabletLandscape: false,
87
- inlineAudioPlayer: false,
88
- tabletLandscapePlayerTopPosition: 0,
89
- });
90
-
91
- expect(result).toBe(-130);
92
- });
93
-
94
- it("returns -50 + progressBarHeight for mobile audio player in docked mode", () => {
95
- const result = getMoveUpValue({
96
- additionalData: {},
97
- insets: { top: 0 },
98
- isAudioItem: false,
99
- progressBarHeight: 7,
100
- isTablet: false,
101
- isTabletLandscape: false,
102
- inlineAudioPlayer: false,
103
- tabletLandscapePlayerTopPosition: 0,
104
- });
105
-
106
- expect(result).toBe(-50 + 7);
107
- });
108
- });
@@ -1,19 +0,0 @@
1
- import * as R from "ramda";
2
-
3
- export function itemLimitForData(entry = [], component) {
4
- const itemLimitValue = Number(R.path(["rules", "item_limit"], component));
5
-
6
- const itemLimit =
7
- itemLimitValue && itemLimitValue > 0
8
- ? itemLimitValue
9
- : Number.MAX_SAFE_INTEGER;
10
-
11
- const isInRange = (min, max) => R.both(R.gte(R.__, min), R.lt(R.__, max));
12
-
13
- const entryShouldBeSliced = (entry) =>
14
- isInRange(0, R.length(entry))(itemLimit);
15
-
16
- const sliceEntriesUpToItemLimit = R.slice(0, itemLimit);
17
-
18
- return R.when(entryShouldBeSliced, sliceEntriesUpToItemLimit)(entry);
19
- }
File without changes