@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5412418016 → 15.0.0-alpha.5830601313
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/HandlePlayable/HandlePlayable.tsx +14 -65
- package/Components/HandlePlayable/const.ts +3 -0
- package/Components/HandlePlayable/utils.ts +74 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +1 -16
- package/Components/PlayerImageBackground/index.tsx +1 -11
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
- package/Components/TopMarginApplicator/TopMarginApplicator.tsx +0 -6
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +4 -487
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +3 -153
- package/Components/VideoModal/ModalAnimation/index.ts +1 -10
- package/Components/VideoModal/ModalAnimation/utils.ts +0 -315
- package/Components/VideoModal/PlayerWrapper.tsx +31 -59
- package/Components/VideoModal/hooks/useModalSize.ts +5 -4
- package/Components/VideoModal/playerWrapperUtils.ts +92 -0
- package/package.json +5 -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/__tests__/getMoveUpValue.test.ts +0 -108
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
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";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
31
3
|
|
|
32
4
|
type Props = {
|
|
33
5
|
animationType: string;
|
|
@@ -36,465 +8,10 @@ type Props = {
|
|
|
36
8
|
additionalData?: { [key: string]: any };
|
|
37
9
|
};
|
|
38
10
|
|
|
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
11
|
export const AnimationComponent = (props: Props) => {
|
|
444
|
-
const {
|
|
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
|
-
}
|
|
12
|
+
const { style } = props;
|
|
493
13
|
|
|
494
|
-
|
|
495
|
-
// @ts-ignore
|
|
496
|
-
return <Component>{props.children}</Component>;
|
|
497
|
-
}
|
|
14
|
+
const Component = style ? View : React.Fragment;
|
|
498
15
|
|
|
499
16
|
return <Component {...props}>{props.children}</Component>;
|
|
500
17
|
};
|
|
@@ -1,78 +1,19 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from "react";
|
|
2
2
|
import { Animated, Dimensions } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
useSafeAreaInsets,
|
|
6
|
-
useSafeAreaFrame,
|
|
7
|
-
} from "react-native-safe-area-context";
|
|
8
|
-
import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useGetBottomTabBarHeight";
|
|
9
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
10
|
-
import { isLive } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
11
5
|
|
|
12
|
-
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
13
6
|
import { useConfiguration } from "../utils";
|
|
14
7
|
import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
|
|
15
8
|
|
|
16
|
-
export enum PlayerAnimationStateEnum {
|
|
17
|
-
minimize = "minimize",
|
|
18
|
-
maximize = "maximize",
|
|
19
|
-
drag_player = "drag_player",
|
|
20
|
-
drag_scroll = "drag_scroll",
|
|
21
|
-
appear_as_docked = "appear_as_docked",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
|
|
25
|
-
|
|
26
9
|
export type ModalAnimationContextT = {
|
|
27
10
|
yTranslate: React.MutableRefObject<Animated.Value | null>;
|
|
28
|
-
isActiveGesture: boolean;
|
|
29
|
-
playerAnimationState: PlayerAnimationStateT;
|
|
30
|
-
setPlayerAnimationState: (value: PlayerAnimationStateT) => void;
|
|
31
|
-
startComponentsAnimation: boolean;
|
|
32
|
-
setStartComponentsAnimation: (value: boolean) => void;
|
|
33
|
-
resetPlayerAnimationState: () => void;
|
|
34
11
|
minimisedHeight: number;
|
|
35
|
-
animatedValues: {
|
|
36
|
-
lastScrollY: Animated.Value;
|
|
37
|
-
dragScrollY: Animated.Value;
|
|
38
|
-
dragVideoPlayerY: Animated.Value;
|
|
39
|
-
translateYOffset: Animated.Value;
|
|
40
|
-
};
|
|
41
|
-
lastScrollYValue: React.MutableRefObject<number>;
|
|
42
|
-
scrollPosition: React.MutableRefObject<number>;
|
|
43
|
-
modalSnapPoints: number[];
|
|
44
|
-
lastSnap: number;
|
|
45
|
-
setLastSnap: (value: number) => void;
|
|
46
|
-
tabletLandscapePlayerTopPosition: number;
|
|
47
|
-
setTabletLandscapePlayerTopPosition: (value: number) => void;
|
|
48
|
-
startComponentsAnimationDistance: number;
|
|
49
|
-
progressBarHeight: number;
|
|
50
12
|
};
|
|
51
13
|
|
|
52
14
|
export const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
53
15
|
yTranslate: React.createRef<Animated.Value | null>(),
|
|
54
|
-
isActiveGesture: false,
|
|
55
|
-
playerAnimationState: null,
|
|
56
|
-
setPlayerAnimationState: () => null,
|
|
57
|
-
startComponentsAnimation: false,
|
|
58
|
-
setStartComponentsAnimation: () => null,
|
|
59
|
-
resetPlayerAnimationState: () => null,
|
|
60
16
|
minimisedHeight: 60,
|
|
61
|
-
animatedValues: {
|
|
62
|
-
lastScrollY: new Animated.Value(0),
|
|
63
|
-
dragScrollY: new Animated.Value(0),
|
|
64
|
-
dragVideoPlayerY: new Animated.Value(0),
|
|
65
|
-
translateYOffset: new Animated.Value(0),
|
|
66
|
-
},
|
|
67
|
-
lastScrollYValue: null,
|
|
68
|
-
scrollPosition: null,
|
|
69
|
-
modalSnapPoints: [0, 0],
|
|
70
|
-
lastSnap: 0,
|
|
71
|
-
setLastSnap: () => null,
|
|
72
|
-
tabletLandscapePlayerTopPosition: 0,
|
|
73
|
-
setTabletLandscapePlayerTopPosition: () => null,
|
|
74
|
-
startComponentsAnimationDistance: 0,
|
|
75
|
-
progressBarHeight: 0,
|
|
76
17
|
});
|
|
77
18
|
|
|
78
19
|
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
@@ -80,49 +21,18 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
80
21
|
new Animated.Value(Dimensions.get("window").height)
|
|
81
22
|
);
|
|
82
23
|
|
|
83
|
-
const [playerAnimationState, setPlayerAnimationState] =
|
|
84
|
-
React.useState<PlayerAnimationStateT>(null);
|
|
85
|
-
|
|
86
|
-
const [
|
|
87
|
-
tabletLandscapePlayerTopPosition,
|
|
88
|
-
setTabletLandscapePlayerTopPosition,
|
|
89
|
-
] = React.useState<number>(0);
|
|
90
|
-
|
|
91
|
-
const [startComponentsAnimation, setStartComponentsAnimation] =
|
|
92
|
-
React.useState<boolean>(false);
|
|
93
|
-
|
|
94
24
|
const {
|
|
95
|
-
videoModalState: {
|
|
25
|
+
videoModalState: { visible },
|
|
96
26
|
} = useNavigation();
|
|
97
27
|
|
|
98
|
-
const isLiveItem = isLive(item);
|
|
99
28
|
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
100
29
|
|
|
101
|
-
const resetPlayerAnimationState = React.useCallback(() => {
|
|
102
|
-
setPlayerAnimationState(null);
|
|
103
|
-
setStartComponentsAnimation(false);
|
|
104
|
-
}, []);
|
|
105
|
-
|
|
106
|
-
// Animated values
|
|
107
|
-
const lastScrollY = React.useRef(new Animated.Value(0)).current;
|
|
108
|
-
const dragScrollY = React.useRef(new Animated.Value(0)).current;
|
|
109
|
-
const translateYOffset = React.useRef(new Animated.Value(0)).current;
|
|
110
|
-
const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
|
|
111
|
-
|
|
112
|
-
const { height: safeAreaFrameHeight } = useSafeAreaFrame();
|
|
113
|
-
const [height, setHeight] = React.useState<number>(safeAreaFrameHeight);
|
|
114
|
-
const progressBarHeight = isLiveItem ? 0 : PROGRESS_BAR_HEIGHT;
|
|
115
|
-
const { bottom: bottomSafeArea } = useSafeAreaInsets();
|
|
116
|
-
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
117
|
-
const startComponentsAnimationDistance = Math.round((height * 60) / 100);
|
|
118
30
|
const isTabletLandscape = useIsTabletLandscape();
|
|
119
31
|
const windowDimensions = Dimensions.get("window");
|
|
120
32
|
|
|
121
33
|
useEffect(() => {
|
|
122
34
|
// Reset player animation state when video modal is closed
|
|
123
35
|
if (!visible) {
|
|
124
|
-
resetPlayerAnimationState();
|
|
125
|
-
|
|
126
36
|
if (!isTabletLandscape) {
|
|
127
37
|
// restore to portrait ( in portrait mode height is bigger)
|
|
128
38
|
if (windowDimensions.height > windowDimensions.width) {
|
|
@@ -134,79 +44,19 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
134
44
|
}
|
|
135
45
|
}, [
|
|
136
46
|
visible,
|
|
137
|
-
resetPlayerAnimationState,
|
|
138
47
|
windowDimensions.height,
|
|
139
48
|
isTabletLandscape,
|
|
49
|
+
windowDimensions.width,
|
|
140
50
|
]);
|
|
141
51
|
|
|
142
|
-
React.useEffect(() => {
|
|
143
|
-
if (visible && mode === "MAXIMIZED" && height !== safeAreaFrameHeight) {
|
|
144
|
-
setHeight(safeAreaFrameHeight);
|
|
145
|
-
}
|
|
146
|
-
}, [height, safeAreaFrameHeight, mode, visible]);
|
|
147
|
-
|
|
148
|
-
/*
|
|
149
|
-
If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
|
|
150
|
-
Because of this we need to minus bottom SafeArea offset.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
const minValue =
|
|
154
|
-
height -
|
|
155
|
-
(minimisedHeight + bottomTabBarHeight + progressBarHeight + bottomSafeArea);
|
|
156
|
-
|
|
157
|
-
const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
|
|
158
|
-
// Last snap state which will helps us to make smooth responder to scrollview animation
|
|
159
|
-
const [lastSnap, setLastSnap] = React.useState<number>(modalSnapPoints[0]);
|
|
160
|
-
// Extracted animated values which we will use for calculations
|
|
161
|
-
const lastScrollYValue = React.useRef<number>(0);
|
|
162
|
-
const scrollPosition = React.useRef<number>(0);
|
|
163
|
-
|
|
164
52
|
return (
|
|
165
53
|
<ReactContext.Provider
|
|
166
54
|
value={useMemo(
|
|
167
55
|
() => ({
|
|
168
56
|
yTranslate,
|
|
169
|
-
startComponentsAnimation,
|
|
170
|
-
setStartComponentsAnimation,
|
|
171
|
-
isActiveGesture: playerAnimationState !== null,
|
|
172
|
-
playerAnimationState,
|
|
173
|
-
setPlayerAnimationState,
|
|
174
|
-
resetPlayerAnimationState,
|
|
175
57
|
minimisedHeight,
|
|
176
|
-
animatedValues: {
|
|
177
|
-
lastScrollY,
|
|
178
|
-
dragScrollY,
|
|
179
|
-
dragVideoPlayerY,
|
|
180
|
-
translateYOffset,
|
|
181
|
-
},
|
|
182
|
-
lastScrollYValue,
|
|
183
|
-
scrollPosition,
|
|
184
|
-
modalSnapPoints,
|
|
185
|
-
lastSnap,
|
|
186
|
-
setLastSnap,
|
|
187
|
-
tabletLandscapePlayerTopPosition,
|
|
188
|
-
setTabletLandscapePlayerTopPosition,
|
|
189
|
-
startComponentsAnimationDistance,
|
|
190
|
-
progressBarHeight,
|
|
191
58
|
}),
|
|
192
|
-
|
|
193
|
-
[
|
|
194
|
-
startComponentsAnimation,
|
|
195
|
-
playerAnimationState,
|
|
196
|
-
minimisedHeight,
|
|
197
|
-
lastScrollY,
|
|
198
|
-
dragScrollY,
|
|
199
|
-
dragVideoPlayerY,
|
|
200
|
-
translateYOffset,
|
|
201
|
-
lastSnap,
|
|
202
|
-
modalSnapPoints,
|
|
203
|
-
lastScrollYValue,
|
|
204
|
-
scrollPosition,
|
|
205
|
-
tabletLandscapePlayerTopPosition,
|
|
206
|
-
startComponentsAnimationDistance,
|
|
207
|
-
progressBarHeight,
|
|
208
|
-
isLiveItem,
|
|
209
|
-
]
|
|
59
|
+
[minimisedHeight]
|
|
210
60
|
)}
|
|
211
61
|
>
|
|
212
62
|
{children}
|