@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 14.0.0-rc.91

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 (179) hide show
  1. package/Components/AnimatedInOut/index.tsx +68 -23
  2. package/Components/AudioPlayer/index.tsx +15 -0
  3. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  4. package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
  5. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  6. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  7. package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
  8. package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
  9. package/Components/AudioPlayer/tv/Layout.tsx +168 -0
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
  14. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
  15. package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
  16. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
  19. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
  20. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
  21. package/Components/AudioPlayer/types.ts +40 -0
  22. package/Components/BaseFocusable/index.tsx +23 -12
  23. package/Components/Cell/Cell.tsx +91 -64
  24. package/Components/Cell/CellWithFocusable.tsx +3 -0
  25. package/Components/Cell/FocusableWrapper.tsx +44 -0
  26. package/Components/Cell/TvOSCellComponent.tsx +92 -17
  27. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  28. package/Components/Cell/index.js +7 -3
  29. package/Components/ComponentResolver/index.ts +1 -1
  30. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  31. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  32. package/Components/FeedLoader/index.js +2 -8
  33. package/Components/Focusable/Focusable.tsx +12 -3
  34. package/Components/Focusable/FocusableTvOS.tsx +5 -5
  35. package/Components/Focusable/FocusableiOS.tsx +2 -2
  36. package/Components/Focusable/Touchable.tsx +5 -3
  37. package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
  38. package/Components/Focusable/index.android.tsx +19 -11
  39. package/Components/Focusable/index.tsx +1 -1
  40. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  41. package/Components/FocusableList/FocusableItem.tsx +4 -3
  42. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  43. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  44. package/Components/FocusableList/index.tsx +20 -9
  45. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  46. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  47. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -21
  48. package/Components/HandlePlayable/HandlePlayable.tsx +39 -74
  49. package/Components/HandlePlayable/const.ts +3 -0
  50. package/Components/HandlePlayable/utils.ts +74 -0
  51. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  52. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  53. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  54. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  55. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
  56. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  57. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  58. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  59. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  60. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  61. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  62. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  63. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  64. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  65. package/Components/MasterCell/elementMapper.tsx +1 -2
  66. package/Components/MasterCell/index.tsx +1 -1
  67. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  68. package/Components/MasterCell/utils/index.ts +11 -5
  69. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  70. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  71. package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
  72. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  73. package/Components/PlayerContainer/PlayerContainer.tsx +45 -47
  74. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  75. package/Components/PlayerContainer/index.ts +1 -1
  76. package/Components/PlayerImageBackground/index.tsx +4 -23
  77. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -43
  78. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  79. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  80. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
  81. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
  82. package/Components/River/RefreshControl.tsx +11 -17
  83. package/Components/River/TV/River.tsx +2 -17
  84. package/Components/River/TV/index.tsx +3 -1
  85. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  86. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  87. package/Components/River/TV/withTVEventHandler.tsx +1 -1
  88. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  89. package/Components/River/__tests__/river.test.js +12 -26
  90. package/Components/River/index.tsx +1 -1
  91. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  92. package/Components/Screen/__tests__/Screen.test.tsx +28 -29
  93. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  94. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  95. package/Components/Screen/index.tsx +22 -5
  96. package/Components/Screen/navigationHandler.ts +20 -2
  97. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  98. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  99. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  100. package/Components/ScreenRevealManager/index.ts +1 -0
  101. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  102. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +109 -0
  103. package/Components/Tabs/TV/Tabs.android.tsx +1 -3
  104. package/Components/Tabs/Tabs.tsx +2 -3
  105. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  106. package/Components/TextInputTv/index.tsx +11 -0
  107. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  108. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  109. package/Components/Transitioner/Scene.tsx +15 -2
  110. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  111. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  112. package/Components/VideoLive/animationUtils.ts +3 -3
  113. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +120 -133
  114. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  115. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  116. package/Components/VideoModal/PlayerDetails.tsx +29 -7
  117. package/Components/VideoModal/PlayerWrapper.tsx +25 -215
  118. package/Components/VideoModal/VideoModal.tsx +4 -22
  119. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  120. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +2 -7
  121. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  122. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  123. package/Components/VideoModal/hooks/index.ts +0 -2
  124. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  125. package/Components/VideoModal/hooks/useModalSize.ts +23 -2
  126. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  127. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  128. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  129. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  130. package/Components/VideoModal/utils.ts +13 -0
  131. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  132. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  133. package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
  134. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
  135. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  136. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  137. package/Contexts/ScreenContext/index.tsx +46 -6
  138. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  139. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  140. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  141. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  142. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  143. package/Decorators/RiverFeedLoader/index.tsx +22 -4
  144. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  145. package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
  146. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  147. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  148. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  149. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  150. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  151. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  152. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  153. package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
  154. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  155. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  156. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
  157. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  158. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  159. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  160. package/events/index.ts +3 -0
  161. package/package.json +5 -10
  162. package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
  163. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
  164. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
  165. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
  166. package/Components/AudioPlayer/index.ts +0 -1
  167. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  168. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  169. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -421
  170. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  171. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  172. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  173. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
  174. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
  175. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
  176. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
  177. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
  178. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
  179. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +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,10 +0,0 @@
1
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
2
- import { useConfiguration } from "../utils";
3
-
4
- export const useBackgroundColor = (): string => {
5
- const { modal_background_color: modalBackgroundColor } = useConfiguration();
6
-
7
- const theme = useTheme<BaseThemePropertiesMobile>();
8
-
9
- return modalBackgroundColor || theme?.status_background_color;
10
- };