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