@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5227180498 → 12.0.0-alpha.5347482137
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/BaseFocusable/index.tsx +3 -3
- package/Components/Cell/Cell.tsx +5 -5
- package/Components/Cell/CellWithFocusable.tsx +23 -9
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +11 -2
- package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +19 -75
- package/Components/Layout/TV/index.tsx +12 -11
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -112
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/Navigator/StackNavigator.tsx +54 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
- package/Components/River/RefreshControl.tsx +2 -2
- package/Components/River/TV/River.tsx +0 -23
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/TV/hooks/index.ts +3 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
- package/Components/Screen/TV/index.web.tsx +186 -0
- package/Components/Screen/__tests__/Screen.test.tsx +3 -0
- package/Components/Screen/index.tsx +29 -1
- package/Components/ScreenResolver/index.tsx +3 -1
- package/Components/Transitioner/Scene.tsx +24 -19
- package/Components/Transitioner/Transitioner.tsx +21 -28
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/VideoLive/LiveImageManager.ts +28 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +48 -38
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +40 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +98 -81
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +6 -4
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- package/Components/VideoModal/PlayerWrapper.tsx +67 -60
- package/Components/VideoModal/VideoModal.tsx +4 -4
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +32 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
- package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
- package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
- package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
- package/Contexts/FocusableGroupContext/index.ts +7 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
- /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
- /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
|
@@ -100,58 +100,68 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
100
100
|
{ useNativeDriver: true }
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
const onHandlerStateChange = (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
const onHandlerStateChange = React.useCallback(
|
|
104
|
+
({ nativeEvent }) => {
|
|
105
|
+
if (
|
|
106
|
+
nativeEvent.oldState === State.ACTIVE &&
|
|
107
|
+
scrollPosition.current === 0
|
|
108
|
+
) {
|
|
109
|
+
// eslint-disable-next-line prefer-const
|
|
110
|
+
const { velocityY, translationY } = nativeEvent;
|
|
111
|
+
const dragToss = 0.05;
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
const preparedTranslationY =
|
|
114
|
+
Math.abs(translationY) - lastScrollYValue.current;
|
|
111
115
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
if (videoModalState.mode === "MAXIMIZED") {
|
|
117
|
+
const endOffsetY =
|
|
118
|
+
lastSnap + preparedTranslationY + dragToss * velocityY + 150;
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
let destSnapPoint = modalSnapPoints[0];
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
for (const snapPoint of modalSnapPoints) {
|
|
123
|
+
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
|
|
126
|
+
destSnapPoint = snapPoint;
|
|
127
|
+
}
|
|
123
128
|
}
|
|
124
|
-
}
|
|
125
129
|
|
|
126
|
-
|
|
130
|
+
setLastSnap(destSnapPoint);
|
|
127
131
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
if (destSnapPoint === modalSnapPoints[0]) {
|
|
133
|
+
translateYOffset.extractOffset();
|
|
134
|
+
translateYOffset.setValue(preparedTranslationY);
|
|
135
|
+
translateYOffset.flattenOffset();
|
|
136
|
+
dragScrollY.setValue(0);
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
139
|
+
} else {
|
|
140
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
141
|
+
}
|
|
135
142
|
} else {
|
|
136
|
-
|
|
143
|
+
if (translationY < 0) {
|
|
144
|
+
// from mini to full
|
|
145
|
+
setLastSnap(modalSnapPoints[0]);
|
|
146
|
+
|
|
147
|
+
translateYOffset.setValue(
|
|
148
|
+
modalSnapPoints[1] - preparedTranslationY
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
dragScrollY.setValue(0);
|
|
152
|
+
|
|
153
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
154
|
+
} else {
|
|
155
|
+
resetPlayerAnimationState();
|
|
156
|
+
}
|
|
137
157
|
}
|
|
138
158
|
} else {
|
|
139
|
-
|
|
140
|
-
// from mini to full
|
|
141
|
-
setLastSnap(modalSnapPoints[0]);
|
|
142
|
-
translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
|
|
143
|
-
dragScrollY.setValue(0);
|
|
144
|
-
|
|
145
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
146
|
-
} else {
|
|
159
|
+
playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
|
|
147
160
|
resetPlayerAnimationState();
|
|
148
|
-
}
|
|
149
161
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
};
|
|
162
|
+
},
|
|
163
|
+
[lastSnap, modalSnapPoints, playerAnimationState, videoModalState.mode]
|
|
164
|
+
);
|
|
155
165
|
|
|
156
166
|
const onScroll = React.useCallback(({ nativeEvent }) => {
|
|
157
167
|
scrollPosition.current = nativeEvent.contentOffset.y;
|
|
@@ -50,50 +50,57 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
50
50
|
{ useNativeDriver: true }
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
const onHandlerStateChange = (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const onHandlerStateChange = React.useCallback(
|
|
54
|
+
({ nativeEvent }) => {
|
|
55
|
+
if (nativeEvent.oldState === State.ACTIVE) {
|
|
56
|
+
// eslint-disable-next-line prefer-const
|
|
57
|
+
const { velocityY, translationY } = nativeEvent;
|
|
58
|
+
const preparedTranslationY = Math.abs(translationY);
|
|
59
|
+
const dragToss = 0.05;
|
|
60
|
+
|
|
61
|
+
if (videoModalState.mode === "MAXIMIZED") {
|
|
62
|
+
if (translationY > 0) {
|
|
63
|
+
const endOffsetY =
|
|
64
|
+
lastSnap + preparedTranslationY + dragToss * velocityY + 200;
|
|
65
|
+
|
|
66
|
+
let destSnapPoint = modalSnapPoints[0];
|
|
67
|
+
|
|
68
|
+
for (const snapPoint of modalSnapPoints) {
|
|
69
|
+
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
70
|
+
|
|
71
|
+
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
|
|
72
|
+
destSnapPoint = snapPoint;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
76
|
+
setLastSnap(destSnapPoint);
|
|
69
77
|
|
|
70
|
-
if (
|
|
71
|
-
|
|
78
|
+
if (destSnapPoint === modalSnapPoints[0]) {
|
|
79
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
80
|
+
} else {
|
|
81
|
+
lastScrollY.setValue(0);
|
|
82
|
+
lastScrollYValue.current = 0;
|
|
83
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
72
84
|
}
|
|
73
85
|
}
|
|
86
|
+
} else if (videoModalState.mode === "MINIMIZED") {
|
|
87
|
+
if (translationY < 0) {
|
|
88
|
+
// from mini to full
|
|
89
|
+
setLastSnap(modalSnapPoints[0]);
|
|
74
90
|
|
|
75
|
-
|
|
91
|
+
translateYOffset.setValue(
|
|
92
|
+
modalSnapPoints[1] - preparedTranslationY
|
|
93
|
+
);
|
|
76
94
|
|
|
77
|
-
if (destSnapPoint === modalSnapPoints[0]) {
|
|
78
95
|
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
79
96
|
} else {
|
|
80
|
-
|
|
81
|
-
lastScrollYValue.current = 0;
|
|
82
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
97
|
+
resetPlayerAnimationState();
|
|
83
98
|
}
|
|
84
99
|
}
|
|
85
|
-
} else if (videoModalState.mode === "MINIMIZED") {
|
|
86
|
-
if (translationY < 0) {
|
|
87
|
-
// from mini to full
|
|
88
|
-
setLastSnap(modalSnapPoints[0]);
|
|
89
|
-
translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
|
|
90
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
91
|
-
} else {
|
|
92
|
-
resetPlayerAnimationState();
|
|
93
|
-
}
|
|
94
100
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
101
|
+
},
|
|
102
|
+
[lastSnap, modalSnapPoints, videoModalState.mode]
|
|
103
|
+
);
|
|
97
104
|
|
|
98
105
|
React.useEffect(() => {
|
|
99
106
|
const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useState } from "react";
|
|
2
|
-
import { Animated, View
|
|
2
|
+
import { Animated, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
useSafeAreaInsets,
|
|
6
|
-
useSafeAreaFrame,
|
|
7
|
-
} from "react-native-safe-area-context";
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
8
5
|
|
|
9
6
|
import {
|
|
10
7
|
useModalAnimationContext,
|
|
@@ -18,6 +15,7 @@ import {
|
|
|
18
15
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
19
16
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
20
17
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
|
+
import { useAppState } from "@applicaster/zapp-react-native-utils/reactHooks/app";
|
|
21
19
|
|
|
22
20
|
import {
|
|
23
21
|
gestureListenerHelper,
|
|
@@ -35,10 +33,6 @@ type Props = {
|
|
|
35
33
|
additionalData?: { [key: string]: any };
|
|
36
34
|
};
|
|
37
35
|
|
|
38
|
-
const styles = StyleSheet.create({
|
|
39
|
-
flex: { flex: 1 },
|
|
40
|
-
});
|
|
41
|
-
|
|
42
36
|
export const AnimationView = ({
|
|
43
37
|
animationType,
|
|
44
38
|
style,
|
|
@@ -56,21 +50,21 @@ export const AnimationView = ({
|
|
|
56
50
|
tabletLandscapePlayerTopPosition,
|
|
57
51
|
setTabletLandscapePlayerTopPosition,
|
|
58
52
|
modalSnapPoints,
|
|
53
|
+
startComponentsAnimationDistance,
|
|
59
54
|
} = useModalAnimationContext();
|
|
60
55
|
|
|
61
56
|
const isRTL = useIsRTL();
|
|
57
|
+
const isAppActive = useAppState(true);
|
|
62
58
|
|
|
63
59
|
const {
|
|
64
|
-
|
|
60
|
+
width: screenWidth,
|
|
65
61
|
deviceInfo: { isTablet, isTabletLandscape },
|
|
66
|
-
} = useDimensions("
|
|
62
|
+
} = useDimensions("window", { deviceInfo: true });
|
|
67
63
|
|
|
68
|
-
const startAnimationDistance = Math.round((screenHeight * 60) / 100);
|
|
69
64
|
const { videoModalState } = useNavigation();
|
|
70
65
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
71
66
|
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
72
67
|
const insets = useSafeAreaInsets();
|
|
73
|
-
const { width: screenWidth } = useSafeAreaFrame();
|
|
74
68
|
const animationComponentRef = useRef(null);
|
|
75
69
|
|
|
76
70
|
// retrieving top position of the player for tablet landscape mode
|
|
@@ -88,13 +82,6 @@ export const AnimationView = ({
|
|
|
88
82
|
getAnimationDefaultValue(animationType, bottomTabBarHeight)
|
|
89
83
|
);
|
|
90
84
|
|
|
91
|
-
const animationValueType: string =
|
|
92
|
-
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
93
|
-
|
|
94
|
-
const animatedValue = useRef(
|
|
95
|
-
new Animated[animationValueType](defaultValue)
|
|
96
|
-
).current;
|
|
97
|
-
|
|
98
85
|
const isAudioItem = React.useMemo(
|
|
99
86
|
() =>
|
|
100
87
|
videoModalState.item?.content?.type?.includes?.("audio") ||
|
|
@@ -118,63 +105,8 @@ export const AnimationView = ({
|
|
|
118
105
|
: -additionalData.moveValue
|
|
119
106
|
: 0;
|
|
120
107
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
isAudioItem,
|
|
124
|
-
bottomTabBarHeight,
|
|
125
|
-
minimisedHeight,
|
|
126
|
-
minimisedWidth,
|
|
127
|
-
defaultValue,
|
|
128
|
-
moveUpValue,
|
|
129
|
-
moveComponentHorizontalValue,
|
|
130
|
-
isTablet,
|
|
131
|
-
isTabletLandscape,
|
|
132
|
-
isRTL,
|
|
133
|
-
fromMiniPlayer: videoModalState.mode === "MINIMIZED",
|
|
134
|
-
inlineAudioPlayer,
|
|
135
|
-
}),
|
|
136
|
-
[
|
|
137
|
-
bottomTabBarHeight,
|
|
138
|
-
minimisedHeight,
|
|
139
|
-
minimisedWidth,
|
|
140
|
-
defaultValue,
|
|
141
|
-
moveUpValue,
|
|
142
|
-
moveComponentHorizontalValue,
|
|
143
|
-
videoModalState.mode,
|
|
144
|
-
]
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
React.useEffect(() => {
|
|
148
|
-
if (additionalData.resetAnimationValue) {
|
|
149
|
-
animatedValue.setValue(0);
|
|
150
|
-
}
|
|
151
|
-
}, [additionalData.resetAnimationValue]);
|
|
152
|
-
|
|
153
|
-
React.useEffect(() => {
|
|
154
|
-
if (animationType === ComponentAnimationType.player) {
|
|
155
|
-
let width, height;
|
|
156
|
-
|
|
157
|
-
if (additionalData.aspectRatio) {
|
|
158
|
-
width = isTabletLandscape ? additionalData.width : screenWidth;
|
|
159
|
-
|
|
160
|
-
height =
|
|
161
|
-
(isTabletLandscape ? additionalData.width : screenWidth) /
|
|
162
|
-
additionalData.aspectRatio;
|
|
163
|
-
} else {
|
|
164
|
-
width =
|
|
165
|
-
typeof additionalData.width === "number" && additionalData.width;
|
|
166
|
-
|
|
167
|
-
height =
|
|
168
|
-
typeof additionalData.height === "number" && additionalData.height;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (defaultValue.x === 0 && width && height) {
|
|
172
|
-
const value = { x: width, y: height };
|
|
173
|
-
setDefaultValue(value);
|
|
174
|
-
animatedValue.setValue(value);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}, [additionalData, screenWidth]);
|
|
108
|
+
const animationValueType: string =
|
|
109
|
+
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
178
110
|
|
|
179
111
|
const getAnimationValue = React.useCallback(
|
|
180
112
|
(animationType, state) => {
|
|
@@ -292,6 +224,90 @@ export const AnimationView = ({
|
|
|
292
224
|
]
|
|
293
225
|
);
|
|
294
226
|
|
|
227
|
+
const getInitialValue = React.useCallback(() => {
|
|
228
|
+
const mode =
|
|
229
|
+
videoModalState.mode === "PIP"
|
|
230
|
+
? videoModalState.previousMode
|
|
231
|
+
: videoModalState.mode;
|
|
232
|
+
|
|
233
|
+
switch (mode) {
|
|
234
|
+
case "MINIMIZED":
|
|
235
|
+
return getAnimationValue(
|
|
236
|
+
animationType,
|
|
237
|
+
PlayerAnimationStateEnum.minimize
|
|
238
|
+
).toValue;
|
|
239
|
+
|
|
240
|
+
case "MAXIMIZED":
|
|
241
|
+
default:
|
|
242
|
+
return getAnimationValue(
|
|
243
|
+
animationType,
|
|
244
|
+
PlayerAnimationStateEnum.maximaze
|
|
245
|
+
).toValue;
|
|
246
|
+
}
|
|
247
|
+
}, [defaultValue, videoModalState]);
|
|
248
|
+
|
|
249
|
+
const animatedValue = useRef(
|
|
250
|
+
new Animated[animationValueType](getInitialValue())
|
|
251
|
+
).current;
|
|
252
|
+
|
|
253
|
+
const calculationData = React.useMemo(
|
|
254
|
+
() => ({
|
|
255
|
+
isAudioItem,
|
|
256
|
+
bottomTabBarHeight,
|
|
257
|
+
minimisedHeight,
|
|
258
|
+
minimisedWidth,
|
|
259
|
+
defaultValue,
|
|
260
|
+
moveUpValue,
|
|
261
|
+
moveComponentHorizontalValue,
|
|
262
|
+
isTablet,
|
|
263
|
+
isTabletLandscape,
|
|
264
|
+
isRTL,
|
|
265
|
+
fromMiniPlayer: videoModalState.mode === "MINIMIZED",
|
|
266
|
+
inlineAudioPlayer,
|
|
267
|
+
}),
|
|
268
|
+
[
|
|
269
|
+
bottomTabBarHeight,
|
|
270
|
+
minimisedHeight,
|
|
271
|
+
minimisedWidth,
|
|
272
|
+
defaultValue,
|
|
273
|
+
moveUpValue,
|
|
274
|
+
moveComponentHorizontalValue,
|
|
275
|
+
videoModalState.mode,
|
|
276
|
+
]
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
React.useEffect(() => {
|
|
280
|
+
if (additionalData.resetAnimationValue) {
|
|
281
|
+
animatedValue.setValue(defaultValue);
|
|
282
|
+
}
|
|
283
|
+
}, [additionalData.resetAnimationValue, defaultValue]);
|
|
284
|
+
|
|
285
|
+
React.useEffect(() => {
|
|
286
|
+
if (animationType === ComponentAnimationType.player) {
|
|
287
|
+
let width, height;
|
|
288
|
+
|
|
289
|
+
if (additionalData.aspectRatio) {
|
|
290
|
+
width = isTabletLandscape ? additionalData.width : screenWidth;
|
|
291
|
+
|
|
292
|
+
height =
|
|
293
|
+
(isTabletLandscape ? additionalData.width : screenWidth) /
|
|
294
|
+
additionalData.aspectRatio;
|
|
295
|
+
} else {
|
|
296
|
+
width =
|
|
297
|
+
typeof additionalData.width === "number" && additionalData.width;
|
|
298
|
+
|
|
299
|
+
height =
|
|
300
|
+
typeof additionalData.height === "number" && additionalData.height;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (defaultValue.x === 0 && width && height) {
|
|
304
|
+
const value = { x: width, y: height };
|
|
305
|
+
setDefaultValue(value);
|
|
306
|
+
animatedValue.setValue(value);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}, [additionalData, screenWidth]);
|
|
310
|
+
|
|
295
311
|
React.useEffect(() => {
|
|
296
312
|
if (
|
|
297
313
|
playerAnimationState === PlayerAnimationStateEnum.minimize &&
|
|
@@ -325,7 +341,7 @@ export const AnimationView = ({
|
|
|
325
341
|
animatedValue,
|
|
326
342
|
calculationData,
|
|
327
343
|
modalSnapPoint: modalSnapPoints[1],
|
|
328
|
-
|
|
344
|
+
startComponentsAnimationDistance,
|
|
329
345
|
startComponentsAnimation,
|
|
330
346
|
setStartComponentsAnimation,
|
|
331
347
|
getAnimationValue,
|
|
@@ -350,7 +366,7 @@ export const AnimationView = ({
|
|
|
350
366
|
animatedValue,
|
|
351
367
|
calculationData,
|
|
352
368
|
modalSnapPoint: modalSnapPoints[1],
|
|
353
|
-
|
|
369
|
+
startComponentsAnimationDistance,
|
|
354
370
|
startComponentsAnimation,
|
|
355
371
|
setStartComponentsAnimation,
|
|
356
372
|
getAnimationValue,
|
|
@@ -372,9 +388,9 @@ export const AnimationView = ({
|
|
|
372
388
|
ref={animationComponentRef}
|
|
373
389
|
style={[
|
|
374
390
|
...preparedStyles,
|
|
375
|
-
additionalData.saveArea ? styles.flex : null,
|
|
376
391
|
(videoModalState.mode === "MAXIMIZED" ||
|
|
377
|
-
videoModalState.mode === "MINIMIZED"
|
|
392
|
+
videoModalState.mode === "MINIMIZED" ||
|
|
393
|
+
(videoModalState.mode === "PIP" && isAppActive)) &&
|
|
378
394
|
getAnimationStyle(animationType, animatedValue),
|
|
379
395
|
]}
|
|
380
396
|
>
|
|
@@ -412,6 +428,7 @@ export const AnimationComponent = (props: Props) => {
|
|
|
412
428
|
delete additionalData.extraAnimation[animationType];
|
|
413
429
|
|
|
414
430
|
return (
|
|
431
|
+
// @ts-ignore
|
|
415
432
|
<Component {...(isReactFragment ? null : props)}>
|
|
416
433
|
<AnimationComponent
|
|
417
434
|
{...animationProps}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "react-native-
|
|
8
|
-
import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
useGetBottomTabBarHeight,
|
|
7
|
+
useDimensions,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
9
9
|
|
|
10
10
|
import { useConfiguration } from "../utils";
|
|
11
11
|
|
|
@@ -39,6 +39,7 @@ export type ModalAnimationContextT = {
|
|
|
39
39
|
setLastSnap: (value: number) => void;
|
|
40
40
|
tabletLandscapePlayerTopPosition: number;
|
|
41
41
|
setTabletLandscapePlayerTopPosition: (value: number) => void;
|
|
42
|
+
startComponentsAnimationDistance: number;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
@@ -62,6 +63,7 @@ const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
|
62
63
|
setLastSnap: () => null,
|
|
63
64
|
tabletLandscapePlayerTopPosition: 0,
|
|
64
65
|
setTabletLandscapePlayerTopPosition: () => null,
|
|
66
|
+
startComponentsAnimationDistance: 0,
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
export function useModalAnimationContext() {
|
|
@@ -93,10 +95,15 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
93
95
|
const translateYOffset = React.useRef(new Animated.Value(0)).current;
|
|
94
96
|
const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
|
|
95
97
|
|
|
96
|
-
const { height } =
|
|
98
|
+
const { height } = useDimensions("window", { fullDimensions: true });
|
|
97
99
|
const { bottom: bottomSafeArea } = useSafeAreaInsets();
|
|
98
100
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
99
101
|
|
|
102
|
+
const startComponentsAnimationDistance = React.useMemo(
|
|
103
|
+
() => Math.round((height * 60) / 100),
|
|
104
|
+
[height]
|
|
105
|
+
);
|
|
106
|
+
|
|
100
107
|
/*
|
|
101
108
|
If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
|
|
102
109
|
Because of this we need to minus bottom SafeArea offset.
|
|
@@ -134,6 +141,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
134
141
|
setLastSnap,
|
|
135
142
|
tabletLandscapePlayerTopPosition,
|
|
136
143
|
setTabletLandscapePlayerTopPosition,
|
|
144
|
+
startComponentsAnimationDistance,
|
|
137
145
|
}}
|
|
138
146
|
>
|
|
139
147
|
{children}
|
|
@@ -233,7 +233,7 @@ export const gestureListenerHelper = (data) => {
|
|
|
233
233
|
animatedValue,
|
|
234
234
|
calculationData,
|
|
235
235
|
modalSnapPoint,
|
|
236
|
-
|
|
236
|
+
startComponentsAnimationDistance,
|
|
237
237
|
startComponentsAnimation,
|
|
238
238
|
setStartComponentsAnimation,
|
|
239
239
|
getAnimationValue,
|
|
@@ -243,7 +243,7 @@ export const gestureListenerHelper = (data) => {
|
|
|
243
243
|
if (listenerValue <= 0) {
|
|
244
244
|
if (
|
|
245
245
|
preparedValue >= 0 &&
|
|
246
|
-
preparedValue <= modalSnapPoint -
|
|
246
|
+
preparedValue <= modalSnapPoint - startComponentsAnimationDistance
|
|
247
247
|
) {
|
|
248
248
|
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
249
249
|
|
|
@@ -263,9 +263,11 @@ export const gestureListenerHelper = (data) => {
|
|
|
263
263
|
animatedValue.setValue(value);
|
|
264
264
|
}
|
|
265
265
|
} else {
|
|
266
|
-
if (preparedValue >=
|
|
266
|
+
if (preparedValue >= startComponentsAnimationDistance) {
|
|
267
267
|
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
268
|
-
const value = Math.round(
|
|
268
|
+
const value = Math.round(
|
|
269
|
+
preparedValue - startComponentsAnimationDistance
|
|
270
|
+
);
|
|
269
271
|
|
|
270
272
|
animatedValue.setValue(
|
|
271
273
|
calculateAnimationValue(animationType, value, calculationData)
|
|
@@ -42,12 +42,12 @@ export const PlayerDetails = ({
|
|
|
42
42
|
: {};
|
|
43
43
|
|
|
44
44
|
// Animation setup
|
|
45
|
-
const translateY = useRef(new Animated.Value(
|
|
45
|
+
const translateY = useRef(new Animated.Value(50)).current;
|
|
46
46
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
47
47
|
|
|
48
48
|
const runAnimation = () => {
|
|
49
49
|
Animated.timing(translateY, {
|
|
50
|
-
toValue:
|
|
50
|
+
toValue: -30,
|
|
51
51
|
duration: 500,
|
|
52
52
|
easing: Easing.inOut(Easing.ease),
|
|
53
53
|
useNativeDriver: true,
|
|
@@ -63,7 +63,7 @@ export const PlayerDetails = ({
|
|
|
63
63
|
|
|
64
64
|
useEffect(() => {
|
|
65
65
|
if (isAudioPlayer) {
|
|
66
|
-
setTimeout(() => runAnimation(),
|
|
66
|
+
setTimeout(() => runAnimation(), 1500);
|
|
67
67
|
}
|
|
68
68
|
}, [isAudioPlayer]);
|
|
69
69
|
|