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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) 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 +47 -0
  6. package/Components/Cell/TvOSCellComponent.tsx +106 -19
  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/utils/__tests__/useCurationAPI.test.js +1 -1
  12. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +31 -17
  13. package/Components/HandlePlayable/HandlePlayable.tsx +17 -65
  14. package/Components/HandlePlayable/const.ts +3 -0
  15. package/Components/HandlePlayable/utils.ts +74 -0
  16. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  17. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  18. package/Components/Layout/TV/index.tsx +3 -4
  19. package/Components/Layout/TV/index.web.tsx +3 -4
  20. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  21. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  22. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  23. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  24. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  25. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  26. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  27. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
  28. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
  29. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
  30. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
  31. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
  32. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  33. package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
  34. package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
  35. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -2
  36. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +233 -11
  37. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +19 -15
  38. package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
  39. package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
  40. package/Components/MasterCell/index.tsx +2 -0
  41. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  42. package/Components/MasterCell/utils/index.ts +61 -31
  43. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  44. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  45. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
  46. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
  47. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  48. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  49. package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
  50. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  51. package/Components/PlayerContainer/PlayerContainer.tsx +51 -55
  52. package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +101 -0
  53. package/Components/PlayerImageBackground/index.tsx +3 -22
  54. package/Components/River/ComponentsMap/ComponentsMap.tsx +65 -42
  55. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  56. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  57. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  58. package/Components/River/TV/River.tsx +31 -14
  59. package/Components/River/TV/index.tsx +8 -4
  60. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  61. package/Components/River/TV/utils/index.ts +4 -0
  62. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  63. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  64. package/Components/River/__tests__/componentsMap.test.js +38 -0
  65. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  66. package/Components/Screen/TV/index.web.tsx +4 -2
  67. package/Components/Screen/__tests__/Screen.test.tsx +65 -42
  68. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -42
  69. package/Components/Screen/hooks.ts +2 -3
  70. package/Components/Screen/index.tsx +24 -8
  71. package/Components/Screen/navigationHandler.ts +49 -24
  72. package/Components/Screen/orientationHandler.ts +10 -13
  73. package/Components/ScreenResolver/index.tsx +21 -9
  74. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  75. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  76. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  77. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
  78. package/Components/Tabs/TV/Tabs.tsx +20 -3
  79. package/Components/Tabs/TabContent.tsx +7 -4
  80. package/Components/Transitioner/Scene.tsx +15 -2
  81. package/Components/Transitioner/index.js +3 -3
  82. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  83. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  84. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  85. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  86. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  87. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  88. package/Components/VideoModal/VideoModal.tsx +1 -5
  89. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  90. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  91. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  92. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  93. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  94. package/Components/VideoModal/utils.ts +19 -9
  95. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  96. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
  97. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  98. package/Contexts/ScreenContext/index.tsx +25 -18
  99. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  100. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  101. package/Contexts/index.ts +0 -2
  102. package/Decorators/Analytics/index.tsx +6 -5
  103. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  104. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  105. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  106. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  107. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  108. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  109. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  110. package/Helpers/DataSourceHelper/index.ts +19 -0
  111. package/events/index.ts +3 -0
  112. package/events/scrollEndReached.ts +15 -0
  113. package/index.d.ts +7 -0
  114. package/package.json +6 -5
  115. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  116. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  117. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -415
  118. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  119. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  120. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  121. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  122. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  123. package/Helpers/DataSourceHelper/index.js +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "15.0.0-rc.1",
3
+ "version": "15.0.0-rc.100",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,11 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "15.0.0-rc.1",
32
- "@applicaster/zapp-react-native-bridge": "15.0.0-rc.1",
33
- "@applicaster/zapp-react-native-redux": "15.0.0-rc.1",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-rc.1",
31
+ "@applicaster/applicaster-types": "15.0.0-rc.100",
32
+ "@applicaster/zapp-react-native-bridge": "15.0.0-rc.100",
33
+ "@applicaster/zapp-react-native-redux": "15.0.0-rc.100",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-rc.100",
35
+ "fast-json-stable-stringify": "^2.1.0",
35
36
  "promise": "^8.3.0",
36
37
  "url": "^0.11.0",
37
38
  "uuid": "^3.3.2"
@@ -1,27 +0,0 @@
1
- /* eslint max-len: off */
2
-
3
- import React from "react";
4
- import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
5
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
6
-
7
- export const withTvEventHandler = (Component) => {
8
- return function WithTVEventHandler(props) {
9
- const navigator = useNavigation();
10
-
11
- const remoteHandler = (event) => {
12
- const { eventType } = event;
13
-
14
- const canGoBack = navigator.canGoBack();
15
-
16
- if (eventType === "menu" && canGoBack) {
17
- navigator.goBack();
18
- }
19
- };
20
-
21
- return (
22
- <TVEventHandlerComponent tvEventHandler={remoteHandler}>
23
- <Component {...props} />
24
- </TVEventHandlerComponent>
25
- );
26
- };
27
- };
@@ -1,60 +0,0 @@
1
- import React from "react";
2
- import { Animated, ViewStyle } from "react-native";
3
-
4
- import {
5
- useModalAnimationContext,
6
- PlayerAnimationStateEnum,
7
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
8
-
9
- type Props = {
10
- style: ViewStyle[];
11
- children: React.ReactNode;
12
- };
13
-
14
- export const AnimatedPlayerModalWrapper = (props: Props) => {
15
- const {
16
- playerAnimationState,
17
- animatedValues: { lastScrollY, dragScrollY, translateYOffset },
18
- modalSnapPoints,
19
- setStartComponentsAnimation,
20
- } = useModalAnimationContext();
21
-
22
- const interpolateConfig: Animated.InterpolationConfigType = React.useMemo(
23
- () => ({
24
- inputRange: modalSnapPoints,
25
- outputRange: modalSnapPoints,
26
- extrapolate: "clamp",
27
- }),
28
- [modalSnapPoints]
29
- );
30
-
31
- let translateY;
32
-
33
- if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
34
- translateY = translateYOffset.interpolate(interpolateConfig);
35
- } else {
36
- const reverseLastScrollY = Animated.multiply(
37
- new Animated.Value(-1),
38
- lastScrollY
39
- );
40
-
41
- translateY = Animated.add(
42
- translateYOffset,
43
- Animated.add(dragScrollY, reverseLastScrollY)
44
- ).interpolate(interpolateConfig);
45
- }
46
-
47
- React.useEffect(() => {
48
- (playerAnimationState === PlayerAnimationStateEnum.minimize ||
49
- playerAnimationState === PlayerAnimationStateEnum.maximize) &&
50
- setStartComponentsAnimation(true);
51
- }, [playerAnimationState]);
52
-
53
- return (
54
- <Animated.View
55
- style={[props.style, { transform: [{ translateY: translateY }] }]}
56
- >
57
- {props.children}
58
- </Animated.View>
59
- );
60
- };
@@ -1,415 +0,0 @@
1
- import React from "react";
2
- import { Animated, StyleSheet, View } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
- import {
6
- NativeViewGestureHandler,
7
- PanGestureHandler,
8
- State,
9
- TapGestureHandler,
10
- } from "react-native-gesture-handler";
11
-
12
- import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
13
- import {
14
- PlayerAnimationStateEnum,
15
- useModalAnimationContext,
16
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
17
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
19
-
20
- import {
21
- resetScrollAnimatedValues,
22
- setScrollModalAnimatedValue,
23
- } from "./utils";
24
-
25
- import { DURATION_TO_MINIMIZE } from "./const";
26
-
27
- const getAnimatedConfig = (toValue) => {
28
- return {
29
- toValue,
30
- duration: DURATION_TO_MINIMIZE,
31
- useNativeDriver: true,
32
- };
33
- };
34
-
35
- const generalStyles = StyleSheet.create({
36
- container: {
37
- flex: 1,
38
- },
39
- });
40
-
41
- type Props = {
42
- children: React.ReactNode;
43
- };
44
-
45
- export const AnimatedScrollModalComponent = ({ children }: Props) => {
46
- const {
47
- isActiveGesture,
48
- playerAnimationState,
49
- setPlayerAnimationState,
50
- resetPlayerAnimationState,
51
- animatedValues: {
52
- lastScrollY,
53
- dragScrollY,
54
- dragVideoPlayerY,
55
- translateYOffset,
56
- },
57
- lastScrollYValue,
58
- scrollPosition,
59
- modalSnapPoints,
60
- lastSnap,
61
- setLastSnap,
62
- setStartComponentsAnimation,
63
- } = useModalAnimationContext();
64
-
65
- const [enableGesture, setIEnableGesture] = React.useState<boolean>(true);
66
-
67
- const { isLanguageOverlayVisible, isSeekBarTouch } = React.useContext(
68
- PlayerContainerContext
69
- );
70
-
71
- const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
72
- useNavigation();
73
-
74
- const {
75
- mode: videoModalMode,
76
- previousMode: previousVideoModalMode,
77
- item: videoModalItem,
78
- } = videoModalState;
79
-
80
- const isMaximizedModal: boolean = videoModalMode === "MAXIMIZED";
81
- const isMinimizedModal: boolean = videoModalMode === "MINIMIZED";
82
- const previousItemId = usePrevious(videoModalItem?.id);
83
-
84
- const isNotMinimizeMaximazeAnimation =
85
- playerAnimationState !== PlayerAnimationStateEnum.minimize &&
86
- playerAnimationState !== PlayerAnimationStateEnum.maximize;
87
-
88
- const isEnablePanGesture =
89
- enableGesture &&
90
- !isLanguageOverlayVisible &&
91
- isNotMinimizeMaximazeAnimation &&
92
- !isSeekBarTouch &&
93
- (isMaximizedModal || isMinimizedModal);
94
-
95
- const isAudioItem = React.useMemo(
96
- () =>
97
- videoModalItem?.content?.type?.includes?.("audio") ||
98
- videoModalItem?.type?.value === "audio",
99
- [videoModalItem]
100
- );
101
-
102
- // Refs for components
103
- const scrollRef = React.useRef(null);
104
- const tapHandlerRef = React.useRef(null);
105
- const panHandlerRef = React.useRef(null);
106
-
107
- const onRegisterLastScroll = Animated.event(
108
- [{ nativeEvent: { contentOffset: { y: lastScrollY } } }],
109
- { useNativeDriver: true }
110
- );
111
-
112
- const onGestureEvent = Animated.event(
113
- [{ nativeEvent: { translationY: dragScrollY } }],
114
- { useNativeDriver: true }
115
- );
116
-
117
- const onHandlerStateChange = React.useCallback(
118
- ({ nativeEvent }) => {
119
- if (
120
- nativeEvent.oldState === State.ACTIVE &&
121
- scrollPosition.current === 0
122
- ) {
123
- // eslint-disable-next-line prefer-const
124
- const { velocityY, translationY } = nativeEvent;
125
- const dragToss = 0.05;
126
-
127
- const preparedTranslationY =
128
- Math.abs(translationY) - lastScrollYValue.current;
129
-
130
- if (isMaximizedModal) {
131
- const endOffsetY =
132
- lastSnap + preparedTranslationY + dragToss * velocityY + 150;
133
-
134
- let destSnapPoint = modalSnapPoints[0];
135
-
136
- for (const snapPoint of modalSnapPoints) {
137
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
138
-
139
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
140
- destSnapPoint = snapPoint;
141
- }
142
- }
143
-
144
- setLastSnap(destSnapPoint);
145
-
146
- if (destSnapPoint === modalSnapPoints[0]) {
147
- translateYOffset.extractOffset();
148
- translateYOffset.setValue(preparedTranslationY);
149
- translateYOffset.flattenOffset();
150
- dragScrollY.setValue(0);
151
-
152
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
153
- } else if (destSnapPoint !== modalSnapPoints[0] && isMaximizedModal) {
154
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
155
- }
156
- } else {
157
- if (translationY < 0) {
158
- // from mini to full
159
- setLastSnap(modalSnapPoints[0]);
160
-
161
- translateYOffset.setValue(
162
- modalSnapPoints[1] - preparedTranslationY
163
- );
164
-
165
- dragScrollY.setValue(0);
166
-
167
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
168
- } else {
169
- resetPlayerAnimationState();
170
- }
171
- }
172
- } else {
173
- playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
174
- resetPlayerAnimationState();
175
- }
176
- },
177
- [
178
- lastSnap,
179
- modalSnapPoints,
180
- playerAnimationState,
181
- isMinimizedModal,
182
- isMaximizedModal,
183
- ]
184
- );
185
-
186
- const onScroll = React.useCallback(({ nativeEvent }) => {
187
- scrollPosition.current = nativeEvent.contentOffset.y;
188
- }, []);
189
-
190
- // Workaround for onMomentumScrollEnd issue
191
- // https://github.com/facebook/react-native/issues/32696#issuecomment-1104217223
192
- const canMomentum = React.useRef(false);
193
-
194
- const onMomentumScrollBegin = React.useCallback(() => {
195
- canMomentum.current = true;
196
- }, []);
197
-
198
- const onMomentumScrollEnd = React.useCallback(
199
- ({ nativeEvent }) => {
200
- if (canMomentum.current && !isActiveGesture) {
201
- if (nativeEvent.contentOffset.y === 0) {
202
- resetScrollAnimatedValues(
203
- lastScrollY,
204
- lastScrollYValue,
205
- dragScrollY,
206
- dragVideoPlayerY
207
- );
208
-
209
- setIEnableGesture(true);
210
- } else {
211
- setIEnableGesture(false);
212
- }
213
-
214
- canMomentum.current = false;
215
- }
216
- },
217
- [isActiveGesture]
218
- );
219
-
220
- React.useEffect(() => {
221
- return () => {
222
- scrollPosition.current = 0;
223
-
224
- resetScrollAnimatedValues(
225
- lastScrollY,
226
- lastScrollYValue,
227
- dragScrollY,
228
- dragVideoPlayerY
229
- );
230
- };
231
- }, []);
232
-
233
- React.useEffect(() => {
234
- if (
235
- videoModalMode === "MAXIMIZED" &&
236
- !enableGesture &&
237
- scrollPosition.current === 0
238
- ) {
239
- setIEnableGesture(true);
240
- }
241
-
242
- if (
243
- videoModalMode === "MINIMIZED" &&
244
- previousVideoModalMode === "MAXIMIZED"
245
- ) {
246
- // set animation to the minimize values if moving from the player to another screen
247
- if (playerAnimationState === null) {
248
- setScrollModalAnimatedValue(
249
- translateYOffset,
250
- modalSnapPoints[1],
251
- setLastSnap
252
- );
253
-
254
- resetScrollAnimatedValues(
255
- lastScrollY,
256
- lastScrollYValue,
257
- dragScrollY,
258
- dragVideoPlayerY
259
- );
260
- }
261
- } else if (
262
- playerAnimationState === null &&
263
- ((previousItemId === videoModalItem?.id &&
264
- videoModalMode === "MAXIMIZED" &&
265
- (previousVideoModalMode === "MINIMIZED" ||
266
- previousVideoModalMode === "MAXIMIZED")) ||
267
- (previousItemId !== videoModalItem?.id &&
268
- videoModalMode !== "FULLSCREEN"))
269
- ) {
270
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
271
- }
272
- }, [videoModalMode, previousVideoModalMode, videoModalItem]);
273
-
274
- React.useEffect(() => {
275
- if (playerAnimationState === PlayerAnimationStateEnum.minimize) {
276
- if (
277
- (scrollPosition.current === 0 &&
278
- (lastScrollY as any)._value !== 0 &&
279
- (dragScrollY as any)._value === 0 &&
280
- (dragVideoPlayerY as any)._value === 0) ||
281
- (scrollPosition.current !== 0 &&
282
- ((dragScrollY as any)._value !== 0 ||
283
- (dragVideoPlayerY as any)._value !== 0))
284
- ) {
285
- resetScrollAnimatedValues(
286
- lastScrollY,
287
- lastScrollYValue,
288
- dragScrollY,
289
- dragVideoPlayerY
290
- );
291
- }
292
-
293
- Animated.timing(
294
- translateYOffset,
295
- getAnimatedConfig(modalSnapPoints[1])
296
- ).start(() => {
297
- minimiseVideoModal();
298
-
299
- setScrollModalAnimatedValue(
300
- translateYOffset,
301
- modalSnapPoints[1],
302
- setLastSnap
303
- );
304
-
305
- resetScrollAnimatedValues(
306
- lastScrollY,
307
- lastScrollYValue,
308
- dragScrollY,
309
- dragVideoPlayerY
310
- );
311
-
312
- resetPlayerAnimationState();
313
- });
314
- } else if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
315
- Animated.timing(translateYOffset, getAnimatedConfig(0)).start(() => {
316
- maximiseVideoModal();
317
- setScrollModalAnimatedValue(translateYOffset, 0, setLastSnap);
318
-
319
- resetScrollAnimatedValues(
320
- lastScrollY,
321
- lastScrollYValue,
322
- dragScrollY,
323
- dragVideoPlayerY
324
- );
325
-
326
- resetPlayerAnimationState();
327
- });
328
- }
329
- }, [playerAnimationState]);
330
-
331
- React.useEffect(() => {
332
- const lastScrollYListenerId = lastScrollY.addListener(({ value }) => {
333
- lastScrollYValue.current = value;
334
- });
335
-
336
- const dragListenerId = dragScrollY.addListener(({ value }) => {
337
- const preparedValue =
338
- isMinimizedModal && value >= 0
339
- ? 0
340
- : Math.round(isAudioItem ? Math.abs(value) : value);
341
-
342
- if (
343
- preparedValue > 0 &&
344
- scrollPosition.current === 0 &&
345
- playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
346
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
347
- ) {
348
- isMinimizedModal && setStartComponentsAnimation(true);
349
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
350
- }
351
- });
352
-
353
- return () => {
354
- lastScrollY.removeListener(lastScrollYListenerId);
355
- dragScrollY.removeListener(dragListenerId);
356
- };
357
- }, [playerAnimationState, isAudioItem, isMinimizedModal]);
358
-
359
- const scrollEnabled = isMaximizedModal && isNotMinimizeMaximazeAnimation;
360
-
361
- return (
362
- <View style={generalStyles.container}>
363
- <TapGestureHandler
364
- maxDurationMs={100000}
365
- ref={tapHandlerRef}
366
- maxDeltaY={lastSnap - modalSnapPoints[0]}
367
- numberOfTaps={1}
368
- >
369
- <View pointerEvents="box-none">
370
- <PanGestureHandler
371
- enabled={isEnablePanGesture}
372
- ref={panHandlerRef}
373
- simultaneousHandlers={[scrollRef, tapHandlerRef]}
374
- shouldCancelWhenOutside={isMaximizedModal}
375
- onGestureEvent={onGestureEvent}
376
- onHandlerStateChange={onHandlerStateChange}
377
- activeOffsetY={[-5, 5]}
378
- >
379
- <Animated.View>
380
- <NativeViewGestureHandler
381
- ref={scrollRef}
382
- waitFor={tapHandlerRef}
383
- simultaneousHandlers={panHandlerRef}
384
- >
385
- <Animated.ScrollView
386
- scrollEnabled={scrollEnabled}
387
- bounces={false}
388
- onScrollBeginDrag={onRegisterLastScroll}
389
- onScroll={onScroll}
390
- onMomentumScrollBegin={onMomentumScrollBegin}
391
- onMomentumScrollEnd={onMomentumScrollEnd}
392
- scrollEventThrottle={1}
393
- showsVerticalScrollIndicator={false}
394
- >
395
- {children}
396
- </Animated.ScrollView>
397
- </NativeViewGestureHandler>
398
- </Animated.View>
399
- </PanGestureHandler>
400
- </View>
401
- </TapGestureHandler>
402
- </View>
403
- );
404
- };
405
-
406
- export const AnimatedScrollModal = ({ children }: Props) => {
407
- const {
408
- videoModalState: { visible },
409
- } = useNavigation();
410
-
411
- const Component =
412
- !isTV() && visible ? AnimatedScrollModalComponent : React.Fragment;
413
-
414
- return <Component>{children}</Component>;
415
- };