@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5208030571 → 12.0.0-alpha.5230293331
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 +30 -13
- package/Components/Cell/CellWithFocusable.tsx +6 -4
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +10 -2
- package/Components/FreezeWithCallback/Freeze.tsx +31 -0
- package/Components/FreezeWithCallback/LICENSE +21 -0
- package/Components/FreezeWithCallback/Suspender.tsx +17 -0
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
- package/Components/FreezeWithCallback/index.tsx +3 -0
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +20 -75
- package/Components/Layout/TV/index.tsx +29 -181
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -116
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +17 -1
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
- package/Components/MasterCell/dataAdapter.ts +21 -7
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/index.tsx +5 -3
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/Navigator/StackNavigator.tsx +57 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +14 -3
- package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +0 -22
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/TV/hooks/index.ts +1 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/index.web.tsx +85 -58
- package/Components/Screen/__tests__/Screen.test.tsx +3 -49
- package/Components/Screen/index.tsx +55 -76
- package/Components/Screen/navigationHandler.ts +6 -3
- package/Components/Screen/orientationHandler.ts +18 -7
- package/Components/Screen/utils.ts +16 -0
- package/Components/ScreenResolver/index.tsx +6 -11
- package/Components/Transitioner/Scene.tsx +39 -26
- package/Components/Transitioner/Transitioner.tsx +56 -48
- package/Components/Transitioner/__tests__/Scene.test.js +7 -0
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -0
- package/Components/VideoLive/LiveImageManager.ts +28 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +81 -46
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +47 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +129 -86
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +44 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
- package/Components/VideoModal/PlayerDetails.tsx +19 -5
- package/Components/VideoModal/PlayerWrapper.tsx +104 -67
- package/Components/VideoModal/VideoModal.tsx +27 -21
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +7 -0
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +134 -22
- package/Components/VideoModal/hooks/useModalSize.ts +10 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
- package/Contexts/ConfirmDialogState/index.ts +1 -1
- 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/ScreenContext/index.tsx +2 -2
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/const.ts +6 -0
- package/events/index.ts +1 -0
- package/index.js +3 -0
- 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
|
@@ -58,6 +58,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
58
58
|
modalSnapPoints,
|
|
59
59
|
lastSnap,
|
|
60
60
|
setLastSnap,
|
|
61
|
+
setStartComponentsAnimation,
|
|
61
62
|
} = useModalAnimationContext();
|
|
62
63
|
|
|
63
64
|
const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
|
|
@@ -100,58 +101,68 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
100
101
|
{ useNativeDriver: true }
|
|
101
102
|
);
|
|
102
103
|
|
|
103
|
-
const onHandlerStateChange = (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
const onHandlerStateChange = React.useCallback(
|
|
105
|
+
({ nativeEvent }) => {
|
|
106
|
+
if (
|
|
107
|
+
nativeEvent.oldState === State.ACTIVE &&
|
|
108
|
+
scrollPosition.current === 0
|
|
109
|
+
) {
|
|
110
|
+
// eslint-disable-next-line prefer-const
|
|
111
|
+
const { velocityY, translationY } = nativeEvent;
|
|
112
|
+
const dragToss = 0.05;
|
|
108
113
|
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
const preparedTranslationY =
|
|
115
|
+
Math.abs(translationY) - lastScrollYValue.current;
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
if (videoModalState.mode === "MAXIMIZED") {
|
|
118
|
+
const endOffsetY =
|
|
119
|
+
lastSnap + preparedTranslationY + dragToss * velocityY + 150;
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
let destSnapPoint = modalSnapPoints[0];
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
for (const snapPoint of modalSnapPoints) {
|
|
124
|
+
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
|
|
127
|
+
destSnapPoint = snapPoint;
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
|
-
}
|
|
125
130
|
|
|
126
|
-
|
|
131
|
+
setLastSnap(destSnapPoint);
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
if (destSnapPoint === modalSnapPoints[0]) {
|
|
134
|
+
translateYOffset.extractOffset();
|
|
135
|
+
translateYOffset.setValue(preparedTranslationY);
|
|
136
|
+
translateYOffset.flattenOffset();
|
|
137
|
+
dragScrollY.setValue(0);
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
140
|
+
} else {
|
|
141
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
142
|
+
}
|
|
135
143
|
} else {
|
|
136
|
-
|
|
144
|
+
if (translationY < 0) {
|
|
145
|
+
// from mini to full
|
|
146
|
+
setLastSnap(modalSnapPoints[0]);
|
|
147
|
+
|
|
148
|
+
translateYOffset.setValue(
|
|
149
|
+
modalSnapPoints[1] - preparedTranslationY
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
dragScrollY.setValue(0);
|
|
153
|
+
|
|
154
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
155
|
+
} else {
|
|
156
|
+
resetPlayerAnimationState();
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
} 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 {
|
|
160
|
+
playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
|
|
147
161
|
resetPlayerAnimationState();
|
|
148
|
-
}
|
|
149
162
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
};
|
|
163
|
+
},
|
|
164
|
+
[lastSnap, modalSnapPoints, playerAnimationState, videoModalState.mode]
|
|
165
|
+
);
|
|
155
166
|
|
|
156
167
|
const onScroll = React.useCallback(({ nativeEvent }) => {
|
|
157
168
|
scrollPosition.current = nativeEvent.contentOffset.y;
|
|
@@ -189,13 +200,31 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
189
200
|
videoModalState.mode === "MINIMIZED" &&
|
|
190
201
|
videoModalState.previousMode === "MAXIMIZED"
|
|
191
202
|
) {
|
|
192
|
-
|
|
203
|
+
// set animation to the minimize values if moving from the player to another screen
|
|
204
|
+
if (playerAnimationState === null) {
|
|
205
|
+
setScrollModalAnimatedValue(
|
|
206
|
+
translateYOffset,
|
|
207
|
+
modalSnapPoints[1],
|
|
208
|
+
setLastSnap
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
resetScrollAnimatedValues(
|
|
212
|
+
lastScrollY,
|
|
213
|
+
lastScrollYValue,
|
|
214
|
+
dragScrollY,
|
|
215
|
+
dragVideoPlayerY
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
resetPlayerAnimationState();
|
|
219
|
+
}
|
|
193
220
|
}
|
|
194
221
|
|
|
195
222
|
if (
|
|
196
223
|
(videoModalState.mode === "MAXIMIZED" &&
|
|
197
|
-
videoModalState.previousMode === "
|
|
198
|
-
|
|
224
|
+
videoModalState.previousMode === "MINIMIZED" &&
|
|
225
|
+
previousItemId === videoModalState.item?.id) ||
|
|
226
|
+
(previousItemId !== videoModalState.item?.id &&
|
|
227
|
+
videoModalState.mode !== "FULLSCREEN")
|
|
199
228
|
) {
|
|
200
229
|
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
201
230
|
setTimeout(() => resetPlayerAnimationState());
|
|
@@ -271,10 +300,11 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
271
300
|
if (
|
|
272
301
|
preparedValue > 0 &&
|
|
273
302
|
scrollPosition.current === 0 &&
|
|
274
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_player
|
|
303
|
+
playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
|
|
304
|
+
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
275
305
|
) {
|
|
276
|
-
|
|
277
|
-
|
|
306
|
+
isMinimizedModal && setStartComponentsAnimation(true);
|
|
307
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
|
|
278
308
|
}
|
|
279
309
|
});
|
|
280
310
|
|
|
@@ -282,7 +312,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
282
312
|
lastScrollY.removeListener(lastScrollYListenerId);
|
|
283
313
|
dragScrollY.removeListener(dragListenerId);
|
|
284
314
|
};
|
|
285
|
-
}, [playerAnimationState, isAudioItem, modalSnapPoints]);
|
|
315
|
+
}, [playerAnimationState, isAudioItem, modalSnapPoints, isMinimizedModal]);
|
|
286
316
|
|
|
287
317
|
const Wrapper = React.useMemo(
|
|
288
318
|
() => (Platform.OS === "android" ? GestureHandlerRootView : View),
|
|
@@ -336,7 +366,12 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
336
366
|
};
|
|
337
367
|
|
|
338
368
|
export const AnimatedScrollModal = ({ children }: Props) => {
|
|
339
|
-
const
|
|
369
|
+
const {
|
|
370
|
+
videoModalState: { visible },
|
|
371
|
+
} = useNavigation();
|
|
372
|
+
|
|
373
|
+
const Component =
|
|
374
|
+
!isTV() && visible ? AnimatedScrollModalComponent : React.Fragment;
|
|
340
375
|
|
|
341
376
|
return <Component>{children}</Component>;
|
|
342
377
|
};
|
|
@@ -34,6 +34,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
34
34
|
lastSnap,
|
|
35
35
|
setLastSnap,
|
|
36
36
|
resetPlayerAnimationState,
|
|
37
|
+
setStartComponentsAnimation,
|
|
37
38
|
} = useModalAnimationContext();
|
|
38
39
|
|
|
39
40
|
const { videoModalState } = useNavigation();
|
|
@@ -50,50 +51,57 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
50
51
|
{ useNativeDriver: true }
|
|
51
52
|
);
|
|
52
53
|
|
|
53
|
-
const onHandlerStateChange = (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const onHandlerStateChange = React.useCallback(
|
|
55
|
+
({ nativeEvent }) => {
|
|
56
|
+
if (nativeEvent.oldState === State.ACTIVE) {
|
|
57
|
+
// eslint-disable-next-line prefer-const
|
|
58
|
+
const { velocityY, translationY } = nativeEvent;
|
|
59
|
+
const preparedTranslationY = Math.abs(translationY);
|
|
60
|
+
const dragToss = 0.05;
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (videoModalState.mode === "MAXIMIZED") {
|
|
63
|
+
if (translationY > 0) {
|
|
64
|
+
const endOffsetY =
|
|
65
|
+
lastSnap + preparedTranslationY + dragToss * velocityY + 200;
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
let destSnapPoint = modalSnapPoints[0];
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
for (const snapPoint of modalSnapPoints) {
|
|
70
|
+
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
|
|
73
|
+
destSnapPoint = snapPoint;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
setLastSnap(destSnapPoint);
|
|
78
|
+
|
|
79
|
+
if (destSnapPoint === modalSnapPoints[0]) {
|
|
80
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
81
|
+
} else {
|
|
82
|
+
lastScrollY.setValue(0);
|
|
83
|
+
lastScrollYValue.current = 0;
|
|
84
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
72
85
|
}
|
|
73
86
|
}
|
|
87
|
+
} else if (videoModalState.mode === "MINIMIZED") {
|
|
88
|
+
if (translationY < 0) {
|
|
89
|
+
// from mini to full
|
|
90
|
+
setLastSnap(modalSnapPoints[0]);
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
translateYOffset.setValue(
|
|
93
|
+
modalSnapPoints[1] - preparedTranslationY
|
|
94
|
+
);
|
|
76
95
|
|
|
77
|
-
if (destSnapPoint === modalSnapPoints[0]) {
|
|
78
96
|
setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
|
|
79
97
|
} else {
|
|
80
|
-
|
|
81
|
-
lastScrollYValue.current = 0;
|
|
82
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
98
|
+
resetPlayerAnimationState();
|
|
83
99
|
}
|
|
84
100
|
}
|
|
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
101
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
102
|
+
},
|
|
103
|
+
[lastSnap, modalSnapPoints, videoModalState.mode]
|
|
104
|
+
);
|
|
97
105
|
|
|
98
106
|
React.useEffect(() => {
|
|
99
107
|
const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
|
|
@@ -114,8 +122,10 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
114
122
|
preparedValue > 0 &&
|
|
115
123
|
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
116
124
|
) {
|
|
117
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_player
|
|
125
|
+
if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
|
|
126
|
+
isMinimizedModal && setStartComponentsAnimation(true);
|
|
118
127
|
setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
|
|
128
|
+
}
|
|
119
129
|
|
|
120
130
|
translateYOffset.setValue(
|
|
121
131
|
isMaximazedModal
|
|
@@ -145,7 +155,11 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
|
145
155
|
};
|
|
146
156
|
|
|
147
157
|
export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
|
|
148
|
-
const
|
|
158
|
+
const {
|
|
159
|
+
videoModalState: { visible },
|
|
160
|
+
} = useNavigation();
|
|
161
|
+
|
|
162
|
+
const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
|
|
149
163
|
|
|
150
164
|
return <Component>{children}</Component>;
|
|
151
165
|
};
|
|
@@ -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,25 @@ export const AnimationView = ({
|
|
|
56
50
|
tabletLandscapePlayerTopPosition,
|
|
57
51
|
setTabletLandscapePlayerTopPosition,
|
|
58
52
|
modalSnapPoints,
|
|
53
|
+
startComponentsAnimationDistance,
|
|
54
|
+
progressBarHeight,
|
|
59
55
|
} = useModalAnimationContext();
|
|
60
56
|
|
|
61
57
|
const isRTL = useIsRTL();
|
|
58
|
+
const isAppActive = useAppState(true);
|
|
62
59
|
|
|
63
60
|
const {
|
|
64
|
-
|
|
61
|
+
width: screenWidth,
|
|
65
62
|
deviceInfo: { isTablet, isTabletLandscape },
|
|
66
|
-
} = useDimensions("
|
|
63
|
+
} = useDimensions("window", {
|
|
64
|
+
deviceInfo: true,
|
|
65
|
+
updateForInactiveScreens: true,
|
|
66
|
+
});
|
|
67
67
|
|
|
68
|
-
const startAnimationDistance = Math.round((screenHeight * 60) / 100);
|
|
69
68
|
const { videoModalState } = useNavigation();
|
|
70
|
-
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
71
|
-
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
72
69
|
const insets = useSafeAreaInsets();
|
|
73
|
-
const
|
|
70
|
+
const bottomTabBarHeight = useGetBottomTabBarHeight() + (insets.bottom || 0);
|
|
71
|
+
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
74
72
|
const animationComponentRef = useRef(null);
|
|
75
73
|
|
|
76
74
|
// retrieving top position of the player for tablet landscape mode
|
|
@@ -88,13 +86,6 @@ export const AnimationView = ({
|
|
|
88
86
|
getAnimationDefaultValue(animationType, bottomTabBarHeight)
|
|
89
87
|
);
|
|
90
88
|
|
|
91
|
-
const animationValueType: string =
|
|
92
|
-
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
93
|
-
|
|
94
|
-
const animatedValue = useRef(
|
|
95
|
-
new Animated[animationValueType](defaultValue)
|
|
96
|
-
).current;
|
|
97
|
-
|
|
98
89
|
const isAudioItem = React.useMemo(
|
|
99
90
|
() =>
|
|
100
91
|
videoModalState.item?.content?.type?.includes?.("audio") ||
|
|
@@ -105,12 +96,12 @@ export const AnimationView = ({
|
|
|
105
96
|
const inlineAudioPlayer = additionalData.inlineAudioPlayer;
|
|
106
97
|
|
|
107
98
|
const moveUpValue = additionalData.saveArea
|
|
108
|
-
? -insets.top
|
|
99
|
+
? -insets.top + (isAudioItem ? 0 : progressBarHeight)
|
|
109
100
|
: isTablet
|
|
110
101
|
? isTabletLandscape && (!isAudioItem || (isAudioItem && inlineAudioPlayer))
|
|
111
|
-
? -tabletLandscapePlayerTopPosition
|
|
102
|
+
? -tabletLandscapePlayerTopPosition + progressBarHeight
|
|
112
103
|
: -130
|
|
113
|
-
: -50;
|
|
104
|
+
: -50 + progressBarHeight;
|
|
114
105
|
|
|
115
106
|
const moveComponentHorizontalValue = additionalData.moveValue
|
|
116
107
|
? isRTL
|
|
@@ -118,63 +109,8 @@ export const AnimationView = ({
|
|
|
118
109
|
: -additionalData.moveValue
|
|
119
110
|
: 0;
|
|
120
111
|
|
|
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]);
|
|
112
|
+
const animationValueType: string =
|
|
113
|
+
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
178
114
|
|
|
179
115
|
const getAnimationValue = React.useCallback(
|
|
180
116
|
(animationType, state) => {
|
|
@@ -292,6 +228,112 @@ export const AnimationView = ({
|
|
|
292
228
|
]
|
|
293
229
|
);
|
|
294
230
|
|
|
231
|
+
const getInitialValue = React.useCallback(() => {
|
|
232
|
+
const mode =
|
|
233
|
+
videoModalState.mode === "PIP"
|
|
234
|
+
? videoModalState.previousMode
|
|
235
|
+
: videoModalState.mode;
|
|
236
|
+
|
|
237
|
+
switch (mode) {
|
|
238
|
+
case "MINIMIZED":
|
|
239
|
+
return getAnimationValue(
|
|
240
|
+
animationType,
|
|
241
|
+
PlayerAnimationStateEnum.minimize
|
|
242
|
+
).toValue;
|
|
243
|
+
|
|
244
|
+
case "MAXIMIZED":
|
|
245
|
+
default:
|
|
246
|
+
return getAnimationValue(
|
|
247
|
+
animationType,
|
|
248
|
+
PlayerAnimationStateEnum.maximaze
|
|
249
|
+
).toValue;
|
|
250
|
+
}
|
|
251
|
+
}, [defaultValue, videoModalState]);
|
|
252
|
+
|
|
253
|
+
const animatedValue = useRef(
|
|
254
|
+
new Animated[animationValueType](getInitialValue())
|
|
255
|
+
).current;
|
|
256
|
+
|
|
257
|
+
const calculationData = React.useMemo(
|
|
258
|
+
() => ({
|
|
259
|
+
isAudioItem,
|
|
260
|
+
bottomTabBarHeight,
|
|
261
|
+
minimisedHeight,
|
|
262
|
+
minimisedWidth,
|
|
263
|
+
defaultValue,
|
|
264
|
+
moveUpValue,
|
|
265
|
+
moveComponentHorizontalValue,
|
|
266
|
+
isTablet,
|
|
267
|
+
isTabletLandscape,
|
|
268
|
+
isRTL,
|
|
269
|
+
fromMiniPlayer: videoModalState.mode === "MINIMIZED",
|
|
270
|
+
inlineAudioPlayer,
|
|
271
|
+
}),
|
|
272
|
+
[
|
|
273
|
+
bottomTabBarHeight,
|
|
274
|
+
minimisedHeight,
|
|
275
|
+
minimisedWidth,
|
|
276
|
+
defaultValue,
|
|
277
|
+
moveUpValue,
|
|
278
|
+
moveComponentHorizontalValue,
|
|
279
|
+
videoModalState.mode,
|
|
280
|
+
]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
React.useEffect(() => {
|
|
284
|
+
if (additionalData.resetAnimationValue) {
|
|
285
|
+
animatedValue.setValue(defaultValue);
|
|
286
|
+
}
|
|
287
|
+
}, [additionalData.resetAnimationValue, defaultValue]);
|
|
288
|
+
|
|
289
|
+
React.useEffect(() => {
|
|
290
|
+
if (animationType === ComponentAnimationType.player) {
|
|
291
|
+
let width, height;
|
|
292
|
+
|
|
293
|
+
if (additionalData.aspectRatio) {
|
|
294
|
+
width = isTabletLandscape ? additionalData.width : screenWidth;
|
|
295
|
+
|
|
296
|
+
height =
|
|
297
|
+
(isTabletLandscape ? additionalData.width : screenWidth) /
|
|
298
|
+
additionalData.aspectRatio;
|
|
299
|
+
} else {
|
|
300
|
+
width =
|
|
301
|
+
typeof additionalData.width === "number" && additionalData.width;
|
|
302
|
+
|
|
303
|
+
height =
|
|
304
|
+
typeof additionalData.height === "number" && additionalData.height;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (
|
|
308
|
+
videoModalState.mode === "MAXIMIZED" &&
|
|
309
|
+
defaultValue.x !== screenWidth &&
|
|
310
|
+
width &&
|
|
311
|
+
height
|
|
312
|
+
) {
|
|
313
|
+
const value = { x: width, y: height };
|
|
314
|
+
setDefaultValue(value);
|
|
315
|
+
animatedValue.setValue(value);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}, [screenWidth]);
|
|
319
|
+
|
|
320
|
+
React.useEffect(() => {
|
|
321
|
+
if (
|
|
322
|
+
videoModalState.mode === "MINIMIZED" &&
|
|
323
|
+
videoModalState.previousMode === "MAXIMIZED"
|
|
324
|
+
) {
|
|
325
|
+
// set animation to the minimize values if moving from the player to another screen
|
|
326
|
+
if (playerAnimationState === null) {
|
|
327
|
+
const value = getAnimationValue(
|
|
328
|
+
animationType,
|
|
329
|
+
PlayerAnimationStateEnum.minimize
|
|
330
|
+
).toValue;
|
|
331
|
+
|
|
332
|
+
animatedValue.setValue(value);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}, [videoModalState]);
|
|
336
|
+
|
|
295
337
|
React.useEffect(() => {
|
|
296
338
|
if (
|
|
297
339
|
playerAnimationState === PlayerAnimationStateEnum.minimize &&
|
|
@@ -325,7 +367,7 @@ export const AnimationView = ({
|
|
|
325
367
|
animatedValue,
|
|
326
368
|
calculationData,
|
|
327
369
|
modalSnapPoint: modalSnapPoints[1],
|
|
328
|
-
|
|
370
|
+
startComponentsAnimationDistance,
|
|
329
371
|
startComponentsAnimation,
|
|
330
372
|
setStartComponentsAnimation,
|
|
331
373
|
getAnimationValue,
|
|
@@ -350,7 +392,7 @@ export const AnimationView = ({
|
|
|
350
392
|
animatedValue,
|
|
351
393
|
calculationData,
|
|
352
394
|
modalSnapPoint: modalSnapPoints[1],
|
|
353
|
-
|
|
395
|
+
startComponentsAnimationDistance,
|
|
354
396
|
startComponentsAnimation,
|
|
355
397
|
setStartComponentsAnimation,
|
|
356
398
|
getAnimationValue,
|
|
@@ -372,9 +414,9 @@ export const AnimationView = ({
|
|
|
372
414
|
ref={animationComponentRef}
|
|
373
415
|
style={[
|
|
374
416
|
...preparedStyles,
|
|
375
|
-
additionalData.saveArea ? styles.flex : null,
|
|
376
417
|
(videoModalState.mode === "MAXIMIZED" ||
|
|
377
|
-
videoModalState.mode === "MINIMIZED"
|
|
418
|
+
videoModalState.mode === "MINIMIZED" ||
|
|
419
|
+
(videoModalState.mode === "PIP" && isAppActive)) &&
|
|
378
420
|
getAnimationStyle(animationType, animatedValue),
|
|
379
421
|
]}
|
|
380
422
|
>
|
|
@@ -412,6 +454,7 @@ export const AnimationComponent = (props: Props) => {
|
|
|
412
454
|
delete additionalData.extraAnimation[animationType];
|
|
413
455
|
|
|
414
456
|
return (
|
|
457
|
+
// @ts-ignore
|
|
415
458
|
<Component {...(isReactFragment ? null : props)}>
|
|
416
459
|
<AnimationComponent
|
|
417
460
|
{...animationProps}
|