@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5740530237 → 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/Cell/FocusableWrapper.tsx +44 -0
- package/Components/Cell/TvOSCellComponent.tsx +80 -14
- 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/Screen/TV/hooks/useInitialFocus.ts +14 -4
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +22 -5
- package/Components/ScreenRevealManager/utils/index.ts +23 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
- 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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReplaySubject } from "rxjs";
|
|
2
|
+
import { pairwise, filter, first } from "rxjs/operators";
|
|
3
|
+
|
|
4
|
+
// we are interested in last 2 events, because we wait transition from <false> to <true>
|
|
5
|
+
const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
|
|
6
|
+
|
|
7
|
+
export const emitScreenRevealManagerIsReadyToShow = () => {
|
|
8
|
+
screenRevealManagerSubject$.next(true);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const emitScreenRevealManagerIsNotReadyToShow = () => {
|
|
12
|
+
screenRevealManagerSubject$.next(false);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const waitUntilScreenRevealManagerIsReady = () => {
|
|
16
|
+
return screenRevealManagerSubject$.pipe(
|
|
17
|
+
pairwise(), // emit consecutive pairs: [prev, curr]
|
|
18
|
+
filter(
|
|
19
|
+
([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady
|
|
20
|
+
), // detect transition from not_ready to ready
|
|
21
|
+
first()
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Animated } from "react-native";
|
|
2
|
+
import { Animated, StyleSheet } from "react-native";
|
|
3
3
|
import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
4
|
-
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
4
|
import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
|
|
5
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
6
|
|
|
7
7
|
import { ScreenRevealManager } from "./ScreenRevealManager";
|
|
8
|
+
import {
|
|
9
|
+
emitScreenRevealManagerIsReadyToShow,
|
|
10
|
+
emitScreenRevealManagerIsNotReadyToShow,
|
|
11
|
+
} from "./utils";
|
|
8
12
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
lg_tv: undefined,
|
|
15
|
-
default: undefined,
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
container: {
|
|
15
|
+
...StyleSheet.absoluteFillObject,
|
|
16
|
+
position: "absolute",
|
|
17
|
+
},
|
|
16
18
|
});
|
|
17
19
|
|
|
18
|
-
export const TIMEOUT =
|
|
20
|
+
export const TIMEOUT = 300; // 300 ms
|
|
19
21
|
|
|
20
22
|
const HIDDEN = 0; // opacity = 0
|
|
21
23
|
|
|
@@ -29,29 +31,48 @@ export const withScreenRevealManager = (Component) => {
|
|
|
29
31
|
return function WithScreenRevealManager(props: Props) {
|
|
30
32
|
const { componentsToRender } = props;
|
|
31
33
|
|
|
32
|
-
const [
|
|
34
|
+
const [isContentReadyToBeShown, setIsContentReadyToBeShown] =
|
|
35
|
+
React.useState(false);
|
|
33
36
|
|
|
34
|
-
const
|
|
35
|
-
|
|
37
|
+
const [isShowOverlay, setIsShowOverlay] = React.useState(true);
|
|
38
|
+
|
|
39
|
+
const theme = useTheme<BaseThemePropertiesTV>();
|
|
40
|
+
|
|
41
|
+
const handleSetIsContentReadyToBeShown = React.useCallback(() => {
|
|
42
|
+
setIsContentReadyToBeShown(true);
|
|
36
43
|
}, []);
|
|
37
44
|
|
|
38
45
|
const managerRef = useRefWithInitialValue<ScreenRevealManager>(
|
|
39
|
-
() =>
|
|
46
|
+
() =>
|
|
47
|
+
new ScreenRevealManager(
|
|
48
|
+
componentsToRender,
|
|
49
|
+
handleSetIsContentReadyToBeShown
|
|
50
|
+
)
|
|
40
51
|
);
|
|
41
52
|
|
|
42
53
|
const opacityRef = useRefWithInitialValue<Animated.Value>(
|
|
43
|
-
() => new Animated.Value(
|
|
54
|
+
() => new Animated.Value(SHOWN)
|
|
44
55
|
);
|
|
45
56
|
|
|
46
57
|
React.useEffect(() => {
|
|
47
|
-
if (
|
|
58
|
+
if (!isContentReadyToBeShown) {
|
|
59
|
+
emitScreenRevealManagerIsNotReadyToShow();
|
|
60
|
+
} else {
|
|
61
|
+
emitScreenRevealManagerIsReadyToShow();
|
|
62
|
+
}
|
|
63
|
+
}, [isContentReadyToBeShown]);
|
|
64
|
+
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (isContentReadyToBeShown) {
|
|
48
67
|
Animated.timing(opacityRef.current, {
|
|
49
|
-
toValue:
|
|
68
|
+
toValue: HIDDEN,
|
|
50
69
|
duration: TIMEOUT,
|
|
51
70
|
useNativeDriver: true,
|
|
52
|
-
}).start()
|
|
71
|
+
}).start(() => {
|
|
72
|
+
setIsShowOverlay(false);
|
|
73
|
+
});
|
|
53
74
|
}
|
|
54
|
-
}, [
|
|
75
|
+
}, [isContentReadyToBeShown]);
|
|
55
76
|
|
|
56
77
|
if (isFirstComponentScreenPicker(componentsToRender)) {
|
|
57
78
|
// for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
|
|
@@ -59,10 +80,7 @@ export const withScreenRevealManager = (Component) => {
|
|
|
59
80
|
}
|
|
60
81
|
|
|
61
82
|
return (
|
|
62
|
-
|
|
63
|
-
style={{ opacity: opacityRef.current, flex }}
|
|
64
|
-
testID="animated-component"
|
|
65
|
-
>
|
|
83
|
+
<>
|
|
66
84
|
<Component
|
|
67
85
|
{...props}
|
|
68
86
|
initialNumberToLoad={
|
|
@@ -73,7 +91,19 @@ export const withScreenRevealManager = (Component) => {
|
|
|
73
91
|
}
|
|
74
92
|
onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
|
|
75
93
|
/>
|
|
76
|
-
|
|
94
|
+
{isShowOverlay ? (
|
|
95
|
+
<Animated.View
|
|
96
|
+
style={[
|
|
97
|
+
styles.container,
|
|
98
|
+
{
|
|
99
|
+
opacity: opacityRef.current,
|
|
100
|
+
backgroundColor: theme.app_background_color,
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
testID="animated-component"
|
|
104
|
+
/>
|
|
105
|
+
) : null}
|
|
106
|
+
</>
|
|
77
107
|
);
|
|
78
108
|
};
|
|
79
109
|
};
|
|
@@ -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
|
};
|