@applicaster/zapp-react-native-ui-components 15.0.0-rc.26 → 15.0.0-rc.27
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/PlayerContainer/PlayerContainer.tsx +1 -16
- package/Components/PlayerImageBackground/index.tsx +3 -22
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +3 -153
- package/Components/VideoModal/ModalAnimation/index.ts +2 -13
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
- package/Components/VideoModal/PlayerWrapper.tsx +10 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/playerWrapperUtils.ts +21 -4
- 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/AnimationComponent.tsx +0 -500
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
|
@@ -56,11 +56,6 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
|
56
56
|
import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
|
|
57
57
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
58
58
|
|
|
59
|
-
import {
|
|
60
|
-
PlayerAnimationStateEnum,
|
|
61
|
-
useModalAnimationContext,
|
|
62
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
63
|
-
|
|
64
59
|
import {
|
|
65
60
|
PlayerNativeCommandTypes,
|
|
66
61
|
PlayerNativeSendCommand,
|
|
@@ -248,9 +243,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
248
243
|
const screenData = useTargetScreenData(item);
|
|
249
244
|
const { setVisible: showNavBar } = useSetNavbarState();
|
|
250
245
|
|
|
251
|
-
const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
|
|
252
|
-
useModalAnimationContext();
|
|
253
|
-
|
|
254
246
|
const playerEvent = (event, ...args) => {
|
|
255
247
|
playerManager.invokeHandler(event, ...args);
|
|
256
248
|
};
|
|
@@ -482,8 +474,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
482
474
|
if (isModal && mode === VideoModalMode.MAXIMIZED) {
|
|
483
475
|
if (disableMiniPlayer) {
|
|
484
476
|
navigator.closeVideoModal();
|
|
485
|
-
} else {
|
|
486
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
487
477
|
}
|
|
488
478
|
}
|
|
489
479
|
|
|
@@ -680,11 +670,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
680
670
|
autoplay={true}
|
|
681
671
|
controls={false}
|
|
682
672
|
disableCastAction={disableCastAction}
|
|
683
|
-
docked={
|
|
684
|
-
navigator.isVideoModalDocked() &&
|
|
685
|
-
!startComponentsAnimation &&
|
|
686
|
-
!isActiveGesture
|
|
687
|
-
}
|
|
673
|
+
docked={navigator.isVideoModalDocked()}
|
|
688
674
|
entry={item}
|
|
689
675
|
fullscreen={mode === VideoModalMode.FULLSCREEN}
|
|
690
676
|
inline={inline}
|
|
@@ -702,7 +688,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
702
688
|
setNextVideoPreloadThresholdPercentage={
|
|
703
689
|
setNextVideoPreloadThresholdPercentage
|
|
704
690
|
}
|
|
705
|
-
startComponentsAnimation={startComponentsAnimation}
|
|
706
691
|
>
|
|
707
692
|
{renderApplePlayer(applePlayerProps)}
|
|
708
693
|
</Player>
|
|
@@ -2,12 +2,6 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
2
|
import { ImageBackground, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
5
|
-
import {
|
|
6
|
-
AnimationComponent,
|
|
7
|
-
ComponentAnimationType,
|
|
8
|
-
useModalAnimationContext,
|
|
9
|
-
PlayerAnimationStateEnum,
|
|
10
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
11
5
|
|
|
12
6
|
type Props = PropsWithChildren<{
|
|
13
7
|
entry: ZappEntry;
|
|
@@ -25,30 +19,17 @@ const PlayerImageBackgroundComponent = ({
|
|
|
25
19
|
style,
|
|
26
20
|
imageStyle,
|
|
27
21
|
imageKey,
|
|
28
|
-
defaultImageDimensions,
|
|
29
22
|
}: Props) => {
|
|
30
23
|
const source = React.useMemo(
|
|
31
24
|
() => ({ uri: imageSrcFromMediaItem(entry, [imageKey]) }),
|
|
32
25
|
[imageKey, entry]
|
|
33
26
|
);
|
|
34
27
|
|
|
35
|
-
const { playerAnimationState } = useModalAnimationContext();
|
|
36
|
-
|
|
37
28
|
if (!source) return <>{children}</>;
|
|
38
29
|
|
|
39
30
|
return (
|
|
40
|
-
<View
|
|
41
|
-
style={
|
|
42
|
-
playerAnimationState === PlayerAnimationStateEnum.maximize
|
|
43
|
-
? defaultImageDimensions
|
|
44
|
-
: style
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
<AnimationComponent
|
|
48
|
-
style={style}
|
|
49
|
-
animationType={ComponentAnimationType.player}
|
|
50
|
-
additionalData={defaultImageDimensions}
|
|
51
|
-
>
|
|
31
|
+
<View style={style}>
|
|
32
|
+
<View style={style}>
|
|
52
33
|
<ImageBackground
|
|
53
34
|
resizeMode="cover"
|
|
54
35
|
style={imageSize}
|
|
@@ -57,7 +38,7 @@ const PlayerImageBackgroundComponent = ({
|
|
|
57
38
|
>
|
|
58
39
|
{children}
|
|
59
40
|
</ImageBackground>
|
|
60
|
-
</
|
|
41
|
+
</View>
|
|
61
42
|
</View>
|
|
62
43
|
);
|
|
63
44
|
};
|
|
@@ -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}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
export { AnimatedScrollModal } from "./AnimatedScrollModal";
|
|
4
|
-
|
|
5
|
-
export { AnimatedVideoPlayerComponent } from "./AnimatedVideoPlayerComponent";
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
withModalAnimationProvider,
|
|
9
|
-
PlayerAnimationStateEnum,
|
|
10
|
-
} from "./ModalAnimationContext";
|
|
1
|
+
export { withModalAnimationProvider } from "./ModalAnimationContext";
|
|
11
2
|
|
|
12
3
|
export { useModalAnimationContext } from "./useModalAnimationContext";
|
|
13
4
|
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
|
|
5
|
+
export { defaultAspectRatioWidth } from "./utils";
|
|
17
6
|
|
|
18
7
|
export { DURATION_TO_MINIMIZE, DURATION_TO_MAXIMIZE } from "./const";
|
|
@@ -1,332 +1,6 @@
|
|
|
1
|
-
/* eslint-disable padding-line-between-statements */
|
|
2
|
-
|
|
3
|
-
import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
4
|
-
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
5
|
-
|
|
6
|
-
export enum ComponentAnimationType {
|
|
7
|
-
bottomBar = "bottomBar",
|
|
8
|
-
player = "player",
|
|
9
|
-
componentFade = "componentFade",
|
|
10
|
-
componentAppears = "componentAppears",
|
|
11
|
-
moveUpComponent = "moveUpComponent",
|
|
12
|
-
moveComponentHorizontal = "moveComponentHorizontal",
|
|
13
|
-
audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
|
|
2
|
+
|
|
17
3
|
export const PROGRESS_BAR_HEIGHT = 3;
|
|
18
4
|
|
|
19
5
|
export const defaultAspectRatioWidth = (height: number): number =>
|
|
20
6
|
(height / 9) * 16;
|
|
21
|
-
|
|
22
|
-
export const getAnimationStyle = (component, animatedValue) => {
|
|
23
|
-
switch (component) {
|
|
24
|
-
case ComponentAnimationType.bottomBar: {
|
|
25
|
-
return { zIndex: 99, transform: [{ translateY: animatedValue }] };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
case ComponentAnimationType.player: {
|
|
29
|
-
return { width: animatedValue.x, height: animatedValue.y };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
case ComponentAnimationType.componentFade:
|
|
33
|
-
case ComponentAnimationType.componentAppears: {
|
|
34
|
-
return { opacity: animatedValue };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
38
|
-
return { transform: [{ translateY: animatedValue }] };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
42
|
-
case ComponentAnimationType.moveComponentHorizontal: {
|
|
43
|
-
return { transform: [{ translateX: animatedValue }] };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
default:
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
|
|
52
|
-
switch (component) {
|
|
53
|
-
case ComponentAnimationType.bottomBar: {
|
|
54
|
-
return bottomTabBarHeight;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
case ComponentAnimationType.player: {
|
|
58
|
-
return { x: 0, y: 0 };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
case ComponentAnimationType.componentFade: {
|
|
62
|
-
return 1;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
66
|
-
case ComponentAnimationType.moveComponentHorizontal:
|
|
67
|
-
case ComponentAnimationType.componentAppears:
|
|
68
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const calculateAnimationValue = (animationType, dragPosition, data) => {
|
|
75
|
-
const {
|
|
76
|
-
isAudioItem,
|
|
77
|
-
bottomTabBarHeight,
|
|
78
|
-
minimisedHeight,
|
|
79
|
-
minimisedWidth,
|
|
80
|
-
defaultValue,
|
|
81
|
-
moveUpValue,
|
|
82
|
-
moveComponentHorizontalValue,
|
|
83
|
-
isTablet,
|
|
84
|
-
isTabletLandscape,
|
|
85
|
-
isRTL,
|
|
86
|
-
fromMiniPlayer,
|
|
87
|
-
inlineAudioPlayer,
|
|
88
|
-
} = data;
|
|
89
|
-
|
|
90
|
-
switch (animationType) {
|
|
91
|
-
case ComponentAnimationType.bottomBar: {
|
|
92
|
-
if (fromMiniPlayer) {
|
|
93
|
-
return dragPosition < bottomTabBarHeight
|
|
94
|
-
? dragPosition
|
|
95
|
-
: bottomTabBarHeight;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return dragPosition < bottomTabBarHeight
|
|
99
|
-
? bottomTabBarHeight - dragPosition
|
|
100
|
-
: 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
case ComponentAnimationType.player: {
|
|
104
|
-
const value =
|
|
105
|
-
isAudioItem && !inlineAudioPlayer
|
|
106
|
-
? isTabletLandscape
|
|
107
|
-
? fromMiniPlayer
|
|
108
|
-
? { forWidth: 4, forHeight: 4.5 }
|
|
109
|
-
: { forWidth: 3, forHeight: 3 }
|
|
110
|
-
: { forWidth: 2, forHeight: 2 }
|
|
111
|
-
: isTabletLandscape
|
|
112
|
-
? { forWidth: 8, forHeight: 6.5 }
|
|
113
|
-
: { forWidth: 3.5, forHeight: 2 };
|
|
114
|
-
|
|
115
|
-
const minWidth =
|
|
116
|
-
isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
|
|
117
|
-
|
|
118
|
-
if (fromMiniPlayer) {
|
|
119
|
-
const calculationWidth =
|
|
120
|
-
dragPosition * value.forWidth < minWidth
|
|
121
|
-
? minWidth
|
|
122
|
-
: dragPosition * value.forWidth;
|
|
123
|
-
const calculationHeight =
|
|
124
|
-
dragPosition * value.forHeight < minimisedHeight
|
|
125
|
-
? minimisedHeight
|
|
126
|
-
: dragPosition * value.forHeight;
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
x:
|
|
130
|
-
calculationWidth < defaultValue.x
|
|
131
|
-
? calculationWidth
|
|
132
|
-
: defaultValue.x,
|
|
133
|
-
y:
|
|
134
|
-
calculationHeight < defaultValue.y
|
|
135
|
-
? calculationHeight
|
|
136
|
-
: defaultValue.y,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
|
|
141
|
-
|
|
142
|
-
const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
x: calculationWidth > minWidth ? calculationWidth : minWidth,
|
|
146
|
-
y:
|
|
147
|
-
calculationHeight > minimisedHeight
|
|
148
|
-
? calculationHeight
|
|
149
|
-
: minimisedHeight,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
case ComponentAnimationType.componentFade: {
|
|
154
|
-
if (fromMiniPlayer) {
|
|
155
|
-
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
156
|
-
|
|
157
|
-
return calculation < 1 ? calculation : 1;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
161
|
-
|
|
162
|
-
return calculation > 0 ? calculation : 0;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
case ComponentAnimationType.componentAppears: {
|
|
166
|
-
if (fromMiniPlayer) {
|
|
167
|
-
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
168
|
-
|
|
169
|
-
return calculation > 0 ? calculation : 0;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
173
|
-
|
|
174
|
-
return calculation < 1 ? calculation : 1;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
178
|
-
if (fromMiniPlayer) {
|
|
179
|
-
const calculation =
|
|
180
|
-
moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
|
|
181
|
-
|
|
182
|
-
return calculation < 0 ? calculation : 0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
|
|
186
|
-
|
|
187
|
-
return calculation > moveUpValue ? calculation : moveUpValue;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
case ComponentAnimationType.moveComponentHorizontal: {
|
|
191
|
-
if (fromMiniPlayer) {
|
|
192
|
-
const calculation = isRTL
|
|
193
|
-
? moveComponentHorizontalValue - dragPosition * 2
|
|
194
|
-
: moveComponentHorizontalValue + dragPosition * 2;
|
|
195
|
-
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
196
|
-
|
|
197
|
-
return condition ? calculation : 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
|
|
201
|
-
const condition = isRTL
|
|
202
|
-
? calculation < moveComponentHorizontalValue
|
|
203
|
-
: calculation > moveComponentHorizontalValue;
|
|
204
|
-
|
|
205
|
-
return condition ? calculation : moveComponentHorizontalValue;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal: {
|
|
209
|
-
const padding = isRTL
|
|
210
|
-
? AUDIO_PLAYER_HORIZONTAL_PADDING
|
|
211
|
-
: -AUDIO_PLAYER_HORIZONTAL_PADDING;
|
|
212
|
-
|
|
213
|
-
if (fromMiniPlayer) {
|
|
214
|
-
const calculation = isRTL
|
|
215
|
-
? padding - dragPosition / 5
|
|
216
|
-
: padding + dragPosition / 5;
|
|
217
|
-
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
218
|
-
|
|
219
|
-
return condition ? calculation : 0;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
|
|
223
|
-
const condition = isRTL ? calculation < padding : calculation > padding;
|
|
224
|
-
|
|
225
|
-
return condition ? calculation : padding;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const gestureListenerHelper = (data) => {
|
|
231
|
-
const {
|
|
232
|
-
listenerValue,
|
|
233
|
-
preparedValue,
|
|
234
|
-
animationType,
|
|
235
|
-
animatedValue,
|
|
236
|
-
calculationData,
|
|
237
|
-
modalSnapPoint,
|
|
238
|
-
startComponentsAnimationDistance,
|
|
239
|
-
startComponentsAnimation,
|
|
240
|
-
setStartComponentsAnimation,
|
|
241
|
-
getAnimationValue,
|
|
242
|
-
} = data;
|
|
243
|
-
|
|
244
|
-
if (calculationData.fromMiniPlayer) {
|
|
245
|
-
if (listenerValue <= 0) {
|
|
246
|
-
if (
|
|
247
|
-
preparedValue >= 0 &&
|
|
248
|
-
preparedValue <= modalSnapPoint - startComponentsAnimationDistance
|
|
249
|
-
) {
|
|
250
|
-
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
251
|
-
|
|
252
|
-
animatedValue.setValue(
|
|
253
|
-
calculateAnimationValue(animationType, preparedValue, calculationData)
|
|
254
|
-
);
|
|
255
|
-
} else {
|
|
256
|
-
animatedValue.setValue(calculationData.defaultValue);
|
|
257
|
-
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
const value = getAnimationValue(
|
|
261
|
-
animationType,
|
|
262
|
-
PlayerAnimationStateEnum.minimize
|
|
263
|
-
).toValue;
|
|
264
|
-
|
|
265
|
-
animatedValue.setValue(value);
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
if (preparedValue >= startComponentsAnimationDistance) {
|
|
269
|
-
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
270
|
-
const value = Math.round(
|
|
271
|
-
preparedValue - startComponentsAnimationDistance
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
animatedValue.setValue(
|
|
275
|
-
calculateAnimationValue(animationType, value, calculationData)
|
|
276
|
-
);
|
|
277
|
-
} else {
|
|
278
|
-
animatedValue.setValue(calculationData.defaultValue);
|
|
279
|
-
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export const setScrollModalAnimatedValue = (
|
|
285
|
-
animatedValue,
|
|
286
|
-
value,
|
|
287
|
-
setLastSnap
|
|
288
|
-
) => {
|
|
289
|
-
setLastSnap(value);
|
|
290
|
-
animatedValue.setValue(value);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const resetScrollAnimatedValues = (
|
|
294
|
-
lastScrollY,
|
|
295
|
-
lastScrollYValue,
|
|
296
|
-
dragScrollY,
|
|
297
|
-
dragVideoPlayerY
|
|
298
|
-
) => {
|
|
299
|
-
lastScrollY.setValue(0);
|
|
300
|
-
lastScrollYValue.current = 0;
|
|
301
|
-
dragScrollY.setValue(0);
|
|
302
|
-
dragVideoPlayerY.setValue(0);
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export const getMoveUpValue = ({
|
|
306
|
-
additionalData,
|
|
307
|
-
insets,
|
|
308
|
-
isAudioItem,
|
|
309
|
-
progressBarHeight,
|
|
310
|
-
isTablet,
|
|
311
|
-
isTabletLandscape,
|
|
312
|
-
tabletLandscapePlayerTopPosition,
|
|
313
|
-
}) => {
|
|
314
|
-
if (additionalData.saveArea) {
|
|
315
|
-
return -insets.top + (isAudioItem ? 0 : progressBarHeight);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (isAudioItem) {
|
|
319
|
-
// for any layouts in audioPlayer
|
|
320
|
-
return -1 * toNumberWithDefaultZero(additionalData?.marginTop);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (isTablet) {
|
|
324
|
-
if (isTabletLandscape) {
|
|
325
|
-
return -tabletLandscapePlayerTopPosition + progressBarHeight;
|
|
326
|
-
} else {
|
|
327
|
-
return -130;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return -50 + progressBarHeight;
|
|
332
|
-
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleSheet, View, ViewStyle } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Edge,
|
|
5
|
+
SafeAreaView,
|
|
6
|
+
useSafeAreaInsets,
|
|
7
|
+
} from "react-native-safe-area-context";
|
|
4
8
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
9
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
10
|
import { playerDimensionsHack } from "./utils";
|
|
@@ -63,8 +67,12 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
63
67
|
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
64
68
|
);
|
|
65
69
|
|
|
70
|
+
const insets = useSafeAreaInsets();
|
|
71
|
+
|
|
66
72
|
const aspectRatio = React.useMemo(
|
|
67
|
-
() => calculateAspectRatio(isInlineModal, pip),
|
|
73
|
+
() => calculateAspectRatio(isInlineModal, pip, insets),
|
|
74
|
+
// ignoring insets - only initial needed
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
76
|
[isInlineModal, pip]
|
|
69
77
|
);
|
|
70
78
|
|
|
@@ -46,6 +46,7 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
|
46
46
|
|
|
47
47
|
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
48
48
|
isTV: jest.fn(() => false),
|
|
49
|
+
isAndroidPlatform: jest.fn(() => false),
|
|
49
50
|
isApplePlatform: jest.fn(() => true),
|
|
50
51
|
platformSelect: jest.fn((props) => props.android),
|
|
51
52
|
}));
|