@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,421 +0,0 @@
1
- import React from "react";
2
- import { Animated, Platform, StyleSheet, View } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
- import {
6
- GestureHandlerRootView,
7
- NativeViewGestureHandler,
8
- PanGestureHandler,
9
- State,
10
- TapGestureHandler,
11
- } from "react-native-gesture-handler";
12
-
13
- import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
14
- import {
15
- PlayerAnimationStateEnum,
16
- useModalAnimationContext,
17
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
18
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
19
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
20
-
21
- import {
22
- resetScrollAnimatedValues,
23
- setScrollModalAnimatedValue,
24
- } from "./utils";
25
-
26
- import { DURATION_TO_MINIMIZE } from "./const";
27
-
28
- const getAnimatedConfig = (toValue) => {
29
- return {
30
- toValue,
31
- duration: DURATION_TO_MINIMIZE,
32
- useNativeDriver: true,
33
- };
34
- };
35
-
36
- const generalStyles = StyleSheet.create({
37
- container: {
38
- flex: 1,
39
- },
40
- });
41
-
42
- type Props = {
43
- children: React.ReactNode;
44
- };
45
-
46
- export const AnimatedScrollModalComponent = ({ children }: Props) => {
47
- const {
48
- isActiveGesture,
49
- playerAnimationState,
50
- setPlayerAnimationState,
51
- resetPlayerAnimationState,
52
- animatedValues: {
53
- lastScrollY,
54
- dragScrollY,
55
- dragVideoPlayerY,
56
- translateYOffset,
57
- },
58
- lastScrollYValue,
59
- scrollPosition,
60
- modalSnapPoints,
61
- lastSnap,
62
- setLastSnap,
63
- setStartComponentsAnimation,
64
- } = useModalAnimationContext();
65
-
66
- const [enableGesture, setIEnableGesture] = React.useState<boolean>(true);
67
-
68
- const { isLanguageOverlayVisible, isSeekBarTouch } = React.useContext(
69
- PlayerContainerContext
70
- );
71
-
72
- const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
73
- useNavigation();
74
-
75
- const {
76
- mode: videoModalMode,
77
- previousMode: previousVideoModalMode,
78
- item: videoModalItem,
79
- } = videoModalState;
80
-
81
- const isMaximizedModal: boolean = videoModalMode === "MAXIMIZED";
82
- const isMinimizedModal: boolean = videoModalMode === "MINIMIZED";
83
- const previousItemId = usePrevious(videoModalItem?.id);
84
-
85
- const isNotMinimizeMaximazeAnimation =
86
- playerAnimationState !== PlayerAnimationStateEnum.minimize &&
87
- playerAnimationState !== PlayerAnimationStateEnum.maximize;
88
-
89
- const isEnablePanGesture =
90
- enableGesture &&
91
- !isLanguageOverlayVisible &&
92
- isNotMinimizeMaximazeAnimation &&
93
- !isSeekBarTouch &&
94
- (isMaximizedModal || isMinimizedModal);
95
-
96
- const isAudioItem = React.useMemo(
97
- () =>
98
- videoModalItem?.content?.type?.includes?.("audio") ||
99
- videoModalItem?.type?.value === "audio",
100
- [videoModalItem]
101
- );
102
-
103
- // Refs for components
104
- const scrollRef = React.useRef(null);
105
- const tapHandlerRef = React.useRef(null);
106
- const panHandlerRef = React.useRef(null);
107
-
108
- const onRegisterLastScroll = Animated.event(
109
- [{ nativeEvent: { contentOffset: { y: lastScrollY } } }],
110
- { useNativeDriver: true }
111
- );
112
-
113
- const onGestureEvent = Animated.event(
114
- [{ nativeEvent: { translationY: dragScrollY } }],
115
- { useNativeDriver: true }
116
- );
117
-
118
- const onHandlerStateChange = React.useCallback(
119
- ({ nativeEvent }) => {
120
- if (
121
- nativeEvent.oldState === State.ACTIVE &&
122
- scrollPosition.current === 0
123
- ) {
124
- // eslint-disable-next-line prefer-const
125
- const { velocityY, translationY } = nativeEvent;
126
- const dragToss = 0.05;
127
-
128
- const preparedTranslationY =
129
- Math.abs(translationY) - lastScrollYValue.current;
130
-
131
- if (isMaximizedModal) {
132
- const endOffsetY =
133
- lastSnap + preparedTranslationY + dragToss * velocityY + 150;
134
-
135
- let destSnapPoint = modalSnapPoints[0];
136
-
137
- for (const snapPoint of modalSnapPoints) {
138
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
139
-
140
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
141
- destSnapPoint = snapPoint;
142
- }
143
- }
144
-
145
- setLastSnap(destSnapPoint);
146
-
147
- if (destSnapPoint === modalSnapPoints[0]) {
148
- translateYOffset.extractOffset();
149
- translateYOffset.setValue(preparedTranslationY);
150
- translateYOffset.flattenOffset();
151
- dragScrollY.setValue(0);
152
-
153
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
154
- } else if (destSnapPoint !== modalSnapPoints[0] && isMaximizedModal) {
155
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
156
- }
157
- } else {
158
- if (translationY < 0) {
159
- // from mini to full
160
- setLastSnap(modalSnapPoints[0]);
161
-
162
- translateYOffset.setValue(
163
- modalSnapPoints[1] - preparedTranslationY
164
- );
165
-
166
- dragScrollY.setValue(0);
167
-
168
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
169
- } else {
170
- resetPlayerAnimationState();
171
- }
172
- }
173
- } else {
174
- playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
175
- resetPlayerAnimationState();
176
- }
177
- },
178
- [
179
- lastSnap,
180
- modalSnapPoints,
181
- playerAnimationState,
182
- isMinimizedModal,
183
- isMaximizedModal,
184
- ]
185
- );
186
-
187
- const onScroll = React.useCallback(({ nativeEvent }) => {
188
- scrollPosition.current = nativeEvent.contentOffset.y;
189
- }, []);
190
-
191
- // Workaround for onMomentumScrollEnd issue
192
- // https://github.com/facebook/react-native/issues/32696#issuecomment-1104217223
193
- const canMomentum = React.useRef(false);
194
-
195
- const onMomentumScrollBegin = React.useCallback(() => {
196
- canMomentum.current = true;
197
- }, []);
198
-
199
- const onMomentumScrollEnd = React.useCallback(
200
- ({ nativeEvent }) => {
201
- if (canMomentum.current && !isActiveGesture) {
202
- if (nativeEvent.contentOffset.y === 0) {
203
- resetScrollAnimatedValues(
204
- lastScrollY,
205
- lastScrollYValue,
206
- dragScrollY,
207
- dragVideoPlayerY
208
- );
209
-
210
- setIEnableGesture(true);
211
- } else {
212
- setIEnableGesture(false);
213
- }
214
-
215
- canMomentum.current = false;
216
- }
217
- },
218
- [isActiveGesture]
219
- );
220
-
221
- React.useEffect(() => {
222
- return () => {
223
- scrollPosition.current = 0;
224
-
225
- resetScrollAnimatedValues(
226
- lastScrollY,
227
- lastScrollYValue,
228
- dragScrollY,
229
- dragVideoPlayerY
230
- );
231
- };
232
- }, []);
233
-
234
- React.useEffect(() => {
235
- if (
236
- videoModalMode === "MAXIMIZED" &&
237
- !enableGesture &&
238
- scrollPosition.current === 0
239
- ) {
240
- setIEnableGesture(true);
241
- }
242
-
243
- if (
244
- videoModalMode === "MINIMIZED" &&
245
- previousVideoModalMode === "MAXIMIZED"
246
- ) {
247
- // set animation to the minimize values if moving from the player to another screen
248
- if (playerAnimationState === null) {
249
- setScrollModalAnimatedValue(
250
- translateYOffset,
251
- modalSnapPoints[1],
252
- setLastSnap
253
- );
254
-
255
- resetScrollAnimatedValues(
256
- lastScrollY,
257
- lastScrollYValue,
258
- dragScrollY,
259
- dragVideoPlayerY
260
- );
261
- }
262
- } else if (
263
- playerAnimationState === null &&
264
- ((previousItemId === videoModalItem?.id &&
265
- videoModalMode === "MAXIMIZED" &&
266
- (previousVideoModalMode === "MINIMIZED" ||
267
- previousVideoModalMode === "MAXIMIZED")) ||
268
- (previousItemId !== videoModalItem?.id &&
269
- videoModalMode !== "FULLSCREEN"))
270
- ) {
271
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
272
- }
273
- }, [videoModalMode, previousVideoModalMode, videoModalItem]);
274
-
275
- React.useEffect(() => {
276
- if (playerAnimationState === PlayerAnimationStateEnum.minimize) {
277
- if (
278
- (scrollPosition.current === 0 &&
279
- (lastScrollY as any)._value !== 0 &&
280
- (dragScrollY as any)._value === 0 &&
281
- (dragVideoPlayerY as any)._value === 0) ||
282
- (scrollPosition.current !== 0 &&
283
- ((dragScrollY as any)._value !== 0 ||
284
- (dragVideoPlayerY as any)._value !== 0))
285
- ) {
286
- resetScrollAnimatedValues(
287
- lastScrollY,
288
- lastScrollYValue,
289
- dragScrollY,
290
- dragVideoPlayerY
291
- );
292
- }
293
-
294
- Animated.timing(
295
- translateYOffset,
296
- getAnimatedConfig(modalSnapPoints[1])
297
- ).start(() => {
298
- minimiseVideoModal();
299
-
300
- setScrollModalAnimatedValue(
301
- translateYOffset,
302
- modalSnapPoints[1],
303
- setLastSnap
304
- );
305
-
306
- resetScrollAnimatedValues(
307
- lastScrollY,
308
- lastScrollYValue,
309
- dragScrollY,
310
- dragVideoPlayerY
311
- );
312
-
313
- resetPlayerAnimationState();
314
- });
315
- } else if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
316
- Animated.timing(translateYOffset, getAnimatedConfig(0)).start(() => {
317
- maximiseVideoModal();
318
- setScrollModalAnimatedValue(translateYOffset, 0, setLastSnap);
319
-
320
- resetScrollAnimatedValues(
321
- lastScrollY,
322
- lastScrollYValue,
323
- dragScrollY,
324
- dragVideoPlayerY
325
- );
326
-
327
- resetPlayerAnimationState();
328
- });
329
- }
330
- }, [playerAnimationState]);
331
-
332
- React.useEffect(() => {
333
- const lastScrollYListenerId = lastScrollY.addListener(({ value }) => {
334
- lastScrollYValue.current = value;
335
- });
336
-
337
- const dragListenerId = dragScrollY.addListener(({ value }) => {
338
- const preparedValue =
339
- isMinimizedModal && value >= 0
340
- ? 0
341
- : Math.round(isAudioItem ? Math.abs(value) : value);
342
-
343
- if (
344
- preparedValue > 0 &&
345
- scrollPosition.current === 0 &&
346
- playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
347
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
348
- ) {
349
- isMinimizedModal && setStartComponentsAnimation(true);
350
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
351
- }
352
- });
353
-
354
- return () => {
355
- lastScrollY.removeListener(lastScrollYListenerId);
356
- dragScrollY.removeListener(dragListenerId);
357
- };
358
- }, [playerAnimationState, isAudioItem, isMinimizedModal]);
359
-
360
- const Wrapper = React.useMemo(
361
- () => (Platform.OS === "android" ? GestureHandlerRootView : View),
362
- []
363
- );
364
-
365
- const scrollEnabled = isMaximizedModal && isNotMinimizeMaximazeAnimation;
366
-
367
- return (
368
- <Wrapper style={generalStyles.container}>
369
- <TapGestureHandler
370
- maxDurationMs={100000}
371
- ref={tapHandlerRef}
372
- maxDeltaY={lastSnap - modalSnapPoints[0]}
373
- numberOfTaps={1}
374
- >
375
- <View pointerEvents="box-none">
376
- <PanGestureHandler
377
- enabled={isEnablePanGesture}
378
- ref={panHandlerRef}
379
- simultaneousHandlers={[scrollRef, tapHandlerRef]}
380
- shouldCancelWhenOutside={isMaximizedModal}
381
- onGestureEvent={onGestureEvent}
382
- onHandlerStateChange={onHandlerStateChange}
383
- activeOffsetY={[-5, 5]}
384
- >
385
- <Animated.View>
386
- <NativeViewGestureHandler
387
- ref={scrollRef}
388
- waitFor={tapHandlerRef}
389
- simultaneousHandlers={panHandlerRef}
390
- >
391
- <Animated.ScrollView
392
- scrollEnabled={scrollEnabled}
393
- bounces={false}
394
- onScrollBeginDrag={onRegisterLastScroll}
395
- onScroll={onScroll}
396
- onMomentumScrollBegin={onMomentumScrollBegin}
397
- onMomentumScrollEnd={onMomentumScrollEnd}
398
- scrollEventThrottle={1}
399
- showsVerticalScrollIndicator={false}
400
- >
401
- {children}
402
- </Animated.ScrollView>
403
- </NativeViewGestureHandler>
404
- </Animated.View>
405
- </PanGestureHandler>
406
- </View>
407
- </TapGestureHandler>
408
- </Wrapper>
409
- );
410
- };
411
-
412
- export const AnimatedScrollModal = ({ children }: Props) => {
413
- const {
414
- videoModalState: { visible },
415
- } = useNavigation();
416
-
417
- const Component =
418
- !isTV() && visible ? AnimatedScrollModalComponent : React.Fragment;
419
-
420
- return <Component>{children}</Component>;
421
- };
@@ -1,176 +0,0 @@
1
- import React from "react";
2
- import { Animated, StyleSheet } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
- import { PanGestureHandler, State } from "react-native-gesture-handler";
6
-
7
- import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
8
- import {
9
- useModalAnimationContext,
10
- PlayerAnimationStateEnum,
11
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
12
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
13
-
14
- const generalStyles = StyleSheet.create({
15
- container: {
16
- flex: 1,
17
- width: "100%",
18
- position: "absolute",
19
- zIndex: 201,
20
- },
21
- });
22
-
23
- type Props = {
24
- children: React.ReactNode;
25
- };
26
-
27
- export const AnimatedVideoPlayer = ({ children }: Props) => {
28
- const {
29
- playerAnimationState,
30
- setPlayerAnimationState,
31
- animatedValues: { translateYOffset, dragVideoPlayerY, lastScrollY },
32
- lastScrollYValue,
33
- modalSnapPoints,
34
- lastSnap,
35
- setLastSnap,
36
- resetPlayerAnimationState,
37
- setStartComponentsAnimation,
38
- } = useModalAnimationContext();
39
-
40
- const {
41
- videoModalState: { mode: videoModalMode },
42
- } = useNavigation();
43
-
44
- const { isLanguageOverlayVisible, isSeekBarTouch } = React.useContext(
45
- PlayerContainerContext
46
- );
47
-
48
- const isMaximazedModal = videoModalMode === "MAXIMIZED";
49
- const isMinimizedModal = videoModalMode === "MINIMIZED";
50
-
51
- const isNotMinimizeMaximazeAnimation =
52
- playerAnimationState !== PlayerAnimationStateEnum.minimize &&
53
- playerAnimationState !== PlayerAnimationStateEnum.maximize;
54
-
55
- const isEnablePanGesture =
56
- !isLanguageOverlayVisible &&
57
- isNotMinimizeMaximazeAnimation &&
58
- !isSeekBarTouch &&
59
- (isMaximazedModal || isMinimizedModal);
60
-
61
- const onGestureEvent = Animated.event(
62
- [{ nativeEvent: { translationY: dragVideoPlayerY } }],
63
- { useNativeDriver: true }
64
- );
65
-
66
- const onHandlerStateChange = React.useCallback(
67
- ({ nativeEvent }) => {
68
- if (nativeEvent.oldState === State.ACTIVE) {
69
- // eslint-disable-next-line prefer-const
70
- const { velocityY, translationY } = nativeEvent;
71
- const preparedTranslationY = Math.abs(translationY);
72
- const dragToss = 0.05;
73
-
74
- if (videoModalMode === "MAXIMIZED") {
75
- if (translationY > 0) {
76
- const endOffsetY =
77
- lastSnap + preparedTranslationY + dragToss * velocityY + 200;
78
-
79
- let destSnapPoint = modalSnapPoints[0];
80
-
81
- for (const snapPoint of modalSnapPoints) {
82
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
83
-
84
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
85
- destSnapPoint = snapPoint;
86
- }
87
- }
88
-
89
- setLastSnap(destSnapPoint);
90
-
91
- if (destSnapPoint === modalSnapPoints[0]) {
92
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
93
- } else {
94
- lastScrollY.setValue(0);
95
- lastScrollYValue.current = 0;
96
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
97
- }
98
- }
99
- } else if (videoModalMode === "MINIMIZED") {
100
- if (translationY < 0) {
101
- // from mini to full
102
- setLastSnap(modalSnapPoints[0]);
103
-
104
- translateYOffset.setValue(
105
- modalSnapPoints[1] - preparedTranslationY
106
- );
107
-
108
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
109
- } else {
110
- resetPlayerAnimationState();
111
- }
112
- }
113
- }
114
- },
115
- [lastSnap, modalSnapPoints, videoModalMode]
116
- );
117
-
118
- React.useEffect(() => {
119
- const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
120
- ({ value }) => {
121
- if (
122
- (isMinimizedModal && value >= 0) ||
123
- (isMaximazedModal && value <= 0)
124
- ) {
125
- if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
126
- translateYOffset.setValue(
127
- modalSnapPoints[isMinimizedModal ? 1 : 0]
128
- );
129
- }
130
- } else {
131
- const preparedValue = Math.round(Math.abs(value));
132
-
133
- if (
134
- preparedValue > 0 &&
135
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
136
- ) {
137
- if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
138
- isMinimizedModal && setStartComponentsAnimation(true);
139
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
140
- }
141
-
142
- translateYOffset.setValue(
143
- isMaximazedModal
144
- ? preparedValue
145
- : modalSnapPoints[1] - preparedValue
146
- );
147
- }
148
- }
149
- }
150
- );
151
-
152
- return () => {
153
- dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
154
- };
155
- }, [playerAnimationState, isMinimizedModal, isMaximazedModal]);
156
-
157
- return (
158
- <PanGestureHandler
159
- enabled={isEnablePanGesture}
160
- onGestureEvent={onGestureEvent}
161
- onHandlerStateChange={onHandlerStateChange}
162
- >
163
- <Animated.View style={generalStyles.container}>{children}</Animated.View>
164
- </PanGestureHandler>
165
- );
166
- };
167
-
168
- export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
169
- const {
170
- videoModalState: { visible },
171
- } = useNavigation();
172
-
173
- const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
174
-
175
- return <Component>{children}</Component>;
176
- };