@applicaster/zapp-react-native-ui-components 12.0.0-alpha.7921075302 → 12.0.0-alpha.8024419438
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 +1 -1
- package/Components/Cell/Cell.tsx +5 -5
- package/Components/Cell/CellWithFocusable.tsx +17 -5
- package/Components/FocusableGroup/index.tsx +1 -0
- 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/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +87 -112
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- 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 +48 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +9 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
- package/Components/River/RefreshControl.tsx +55 -1
- 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 +179 -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 +18 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +48 -38
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +40 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +94 -71
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +15 -4
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- package/Components/VideoModal/PlayerWrapper.tsx +67 -60
- package/Components/VideoModal/VideoModal.tsx +17 -17
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/utils.ts +5 -2
- package/Contexts/ScreenContext/index.tsx +2 -2
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/events/index.ts +1 -0
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
|
@@ -4,10 +4,7 @@ import * as R from "ramda";
|
|
|
4
4
|
|
|
5
5
|
import { AnimationManager } from "./AnimationManager";
|
|
6
6
|
import { Scene } from "./Scene";
|
|
7
|
-
|
|
8
|
-
getScreenOrientation,
|
|
9
|
-
isOrientationCompatible,
|
|
10
|
-
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
7
|
+
|
|
11
8
|
import {
|
|
12
9
|
getSceneByRoute,
|
|
13
10
|
shouldSkipAnimationForPreviousWebViewScene,
|
|
@@ -277,33 +274,25 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
277
274
|
// so only a single scene should be rendered,
|
|
278
275
|
// instead of dangerous nulls or duplicates.
|
|
279
276
|
renderSingleScene({ scenes, to }) {
|
|
280
|
-
const { contentStyle
|
|
281
|
-
const screenData =
|
|
282
|
-
|
|
283
|
-
const orientation = getScreenOrientation({
|
|
284
|
-
screenData,
|
|
285
|
-
layoutData,
|
|
286
|
-
});
|
|
277
|
+
const { contentStyle } = this.props;
|
|
278
|
+
const screenData = this.props.children.props.screenData;
|
|
279
|
+
const pathname = scenes[to.index].key;
|
|
287
280
|
|
|
288
|
-
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
289
|
-
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
290
281
|
return (
|
|
291
282
|
<View style={styles.container}>
|
|
292
|
-
{scenes[to.index] &&
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
</Scene>
|
|
306
|
-
)}
|
|
283
|
+
{scenes[to.index] && (
|
|
284
|
+
<Scene
|
|
285
|
+
{...{ style: to.style }}
|
|
286
|
+
pathname={pathname}
|
|
287
|
+
isActive={pathname === this.props.navigator.currentRoute}
|
|
288
|
+
contentStyle={contentStyle}
|
|
289
|
+
key={scenes[to.index].key}
|
|
290
|
+
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
291
|
+
screenData={screenData}
|
|
292
|
+
>
|
|
293
|
+
{scenes[to.index].children}
|
|
294
|
+
</Scene>
|
|
295
|
+
)}
|
|
307
296
|
</View>
|
|
308
297
|
);
|
|
309
298
|
}
|
|
@@ -319,12 +308,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
319
308
|
<Scene
|
|
320
309
|
key={scenes[from.index].key}
|
|
321
310
|
pathname={scenes[from.index].key}
|
|
311
|
+
isActive={scenes[from.index].key === this.props.navigator.currentRoute}
|
|
322
312
|
style={from.style}
|
|
323
313
|
pointerEvents="none"
|
|
324
314
|
overlayStyle={from.overlayStyle}
|
|
325
315
|
animating={this.state.animating}
|
|
326
316
|
contentStyle={contentStyle}
|
|
327
317
|
screenUniqueId={scenes[from.index].screenUniqueId}
|
|
318
|
+
screenData={scenes[from.index].children.props.screenData}
|
|
328
319
|
>
|
|
329
320
|
{scenes[from.index].children}
|
|
330
321
|
</Scene>
|
|
@@ -333,12 +324,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
333
324
|
const toScene = scenes[to.index] && (
|
|
334
325
|
<Scene
|
|
335
326
|
pathname={scenes[to.index].key}
|
|
327
|
+
isActive={scenes[to.index].key === this.props.navigator.currentRoute}
|
|
336
328
|
key={scenes[to.index].key}
|
|
337
329
|
style={to.style}
|
|
338
330
|
overlayStyle={to.overlayStyle}
|
|
339
331
|
animating={this.state.animating}
|
|
340
332
|
contentStyle={contentStyle}
|
|
341
333
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
334
|
+
screenData={this.props.children.props.screenData}
|
|
342
335
|
>
|
|
343
336
|
{scenes[to.index].children}
|
|
344
337
|
</Scene>
|
|
@@ -21,7 +21,9 @@ exports[`<Scene /> renders correctly 1`] = `
|
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
>
|
|
24
|
-
<ContextProvider
|
|
24
|
+
<ContextProvider>
|
|
25
|
+
<ContextProvider />
|
|
26
|
+
</ContextProvider>
|
|
25
27
|
</ForwardRef(AnimatedComponentWrapper)>
|
|
26
28
|
`;
|
|
27
29
|
|
|
@@ -43,7 +45,9 @@ exports[`<Scene /> renders the overlay while animating 1`] = `
|
|
|
43
45
|
]
|
|
44
46
|
}
|
|
45
47
|
>
|
|
46
|
-
<ContextProvider
|
|
48
|
+
<ContextProvider>
|
|
49
|
+
<ContextProvider />
|
|
50
|
+
</ContextProvider>
|
|
47
51
|
<ForwardRef(AnimatedComponentWrapper)
|
|
48
52
|
style={
|
|
49
53
|
Object {
|
|
@@ -10,7 +10,11 @@ import { Component } from "react";
|
|
|
10
10
|
|
|
11
11
|
const { log_debug, log_info, log_error } = loggerLiveImageManager;
|
|
12
12
|
|
|
13
|
-
export type LiveImageManagerEvent =
|
|
13
|
+
export type LiveImageManagerEvent =
|
|
14
|
+
| "onEnd"
|
|
15
|
+
| "onStart"
|
|
16
|
+
| "onError"
|
|
17
|
+
| "onDestroy";
|
|
14
18
|
|
|
15
19
|
export type LiveImageManagerListenerData = {
|
|
16
20
|
id: string;
|
|
@@ -102,6 +106,16 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
this.items = this.items.filter((i) => i !== item);
|
|
109
|
+
|
|
110
|
+
this.invokeListenersUpdate({
|
|
111
|
+
callbackName: "onDestroy",
|
|
112
|
+
event: {
|
|
113
|
+
item,
|
|
114
|
+
playerId: this.currentlyPlaying?.playerId,
|
|
115
|
+
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
116
|
+
entry: item.getPlayer().getEntry(),
|
|
117
|
+
},
|
|
118
|
+
});
|
|
105
119
|
};
|
|
106
120
|
|
|
107
121
|
public onViewportEnter = (item: LiveImage) => {
|
|
@@ -351,6 +365,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
351
365
|
item,
|
|
352
366
|
playerId: this.currentlyPlaying?.playerId,
|
|
353
367
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
368
|
+
entry: item.getPlayer().getEntry(),
|
|
354
369
|
},
|
|
355
370
|
});
|
|
356
371
|
};
|
|
@@ -385,6 +400,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
385
400
|
item,
|
|
386
401
|
playerId: this.currentlyPlaying?.playerId,
|
|
387
402
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
403
|
+
entry: item.getPlayer().getEntry(),
|
|
388
404
|
},
|
|
389
405
|
});
|
|
390
406
|
};
|
|
@@ -419,6 +435,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
419
435
|
error,
|
|
420
436
|
playerId: currentItem?.playerId,
|
|
421
437
|
primaryPlayerId: currentItem?.playerId,
|
|
438
|
+
entry: item.getPlayer().getEntry(),
|
|
422
439
|
},
|
|
423
440
|
});
|
|
424
441
|
};
|
|
@@ -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
2
|
import { Animated, View, StyleSheet } 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,
|
|
@@ -59,18 +57,19 @@ export const AnimationView = ({
|
|
|
59
57
|
} = useModalAnimationContext();
|
|
60
58
|
|
|
61
59
|
const isRTL = useIsRTL();
|
|
60
|
+
const isAppActive = useAppState(true);
|
|
62
61
|
|
|
63
62
|
const {
|
|
64
63
|
height: screenHeight,
|
|
64
|
+
width: screenWidth,
|
|
65
65
|
deviceInfo: { isTablet, isTabletLandscape },
|
|
66
|
-
} = useDimensions("
|
|
66
|
+
} = useDimensions("window", { deviceInfo: true });
|
|
67
67
|
|
|
68
68
|
const startAnimationDistance = Math.round((screenHeight * 60) / 100);
|
|
69
69
|
const { videoModalState } = useNavigation();
|
|
70
70
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
71
71
|
const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
|
|
72
72
|
const insets = useSafeAreaInsets();
|
|
73
|
-
const { width: screenWidth } = useSafeAreaFrame();
|
|
74
73
|
const animationComponentRef = useRef(null);
|
|
75
74
|
|
|
76
75
|
// retrieving top position of the player for tablet landscape mode
|
|
@@ -88,13 +87,6 @@ export const AnimationView = ({
|
|
|
88
87
|
getAnimationDefaultValue(animationType, bottomTabBarHeight)
|
|
89
88
|
);
|
|
90
89
|
|
|
91
|
-
const animationValueType: string =
|
|
92
|
-
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
93
|
-
|
|
94
|
-
const animatedValue = useRef(
|
|
95
|
-
new Animated[animationValueType](defaultValue)
|
|
96
|
-
).current;
|
|
97
|
-
|
|
98
90
|
const isAudioItem = React.useMemo(
|
|
99
91
|
() =>
|
|
100
92
|
videoModalState.item?.content?.type?.includes?.("audio") ||
|
|
@@ -118,63 +110,8 @@ export const AnimationView = ({
|
|
|
118
110
|
: -additionalData.moveValue
|
|
119
111
|
: 0;
|
|
120
112
|
|
|
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]);
|
|
113
|
+
const animationValueType: string =
|
|
114
|
+
animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
|
|
178
115
|
|
|
179
116
|
const getAnimationValue = React.useCallback(
|
|
180
117
|
(animationType, state) => {
|
|
@@ -292,6 +229,90 @@ export const AnimationView = ({
|
|
|
292
229
|
]
|
|
293
230
|
);
|
|
294
231
|
|
|
232
|
+
const getInitialValue = React.useCallback(() => {
|
|
233
|
+
const mode =
|
|
234
|
+
videoModalState.mode === "PIP"
|
|
235
|
+
? videoModalState.previousMode
|
|
236
|
+
: videoModalState.mode;
|
|
237
|
+
|
|
238
|
+
switch (mode) {
|
|
239
|
+
case "MINIMIZED":
|
|
240
|
+
return getAnimationValue(
|
|
241
|
+
animationType,
|
|
242
|
+
PlayerAnimationStateEnum.minimize
|
|
243
|
+
).toValue;
|
|
244
|
+
|
|
245
|
+
case "MAXIMIZED":
|
|
246
|
+
default:
|
|
247
|
+
return getAnimationValue(
|
|
248
|
+
animationType,
|
|
249
|
+
PlayerAnimationStateEnum.maximaze
|
|
250
|
+
).toValue;
|
|
251
|
+
}
|
|
252
|
+
}, [defaultValue, videoModalState]);
|
|
253
|
+
|
|
254
|
+
const animatedValue = useRef(
|
|
255
|
+
new Animated[animationValueType](getInitialValue())
|
|
256
|
+
).current;
|
|
257
|
+
|
|
258
|
+
const calculationData = React.useMemo(
|
|
259
|
+
() => ({
|
|
260
|
+
isAudioItem,
|
|
261
|
+
bottomTabBarHeight,
|
|
262
|
+
minimisedHeight,
|
|
263
|
+
minimisedWidth,
|
|
264
|
+
defaultValue,
|
|
265
|
+
moveUpValue,
|
|
266
|
+
moveComponentHorizontalValue,
|
|
267
|
+
isTablet,
|
|
268
|
+
isTabletLandscape,
|
|
269
|
+
isRTL,
|
|
270
|
+
fromMiniPlayer: videoModalState.mode === "MINIMIZED",
|
|
271
|
+
inlineAudioPlayer,
|
|
272
|
+
}),
|
|
273
|
+
[
|
|
274
|
+
bottomTabBarHeight,
|
|
275
|
+
minimisedHeight,
|
|
276
|
+
minimisedWidth,
|
|
277
|
+
defaultValue,
|
|
278
|
+
moveUpValue,
|
|
279
|
+
moveComponentHorizontalValue,
|
|
280
|
+
videoModalState.mode,
|
|
281
|
+
]
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
React.useEffect(() => {
|
|
285
|
+
if (additionalData.resetAnimationValue) {
|
|
286
|
+
animatedValue.setValue(defaultValue);
|
|
287
|
+
}
|
|
288
|
+
}, [additionalData.resetAnimationValue, defaultValue]);
|
|
289
|
+
|
|
290
|
+
React.useEffect(() => {
|
|
291
|
+
if (animationType === ComponentAnimationType.player) {
|
|
292
|
+
let width, height;
|
|
293
|
+
|
|
294
|
+
if (additionalData.aspectRatio) {
|
|
295
|
+
width = isTabletLandscape ? additionalData.width : screenWidth;
|
|
296
|
+
|
|
297
|
+
height =
|
|
298
|
+
(isTabletLandscape ? additionalData.width : screenWidth) /
|
|
299
|
+
additionalData.aspectRatio;
|
|
300
|
+
} else {
|
|
301
|
+
width =
|
|
302
|
+
typeof additionalData.width === "number" && additionalData.width;
|
|
303
|
+
|
|
304
|
+
height =
|
|
305
|
+
typeof additionalData.height === "number" && additionalData.height;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (defaultValue.x === 0 && width && height) {
|
|
309
|
+
const value = { x: width, y: height };
|
|
310
|
+
setDefaultValue(value);
|
|
311
|
+
animatedValue.setValue(value);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}, [additionalData, screenWidth]);
|
|
315
|
+
|
|
295
316
|
React.useEffect(() => {
|
|
296
317
|
if (
|
|
297
318
|
playerAnimationState === PlayerAnimationStateEnum.minimize &&
|
|
@@ -374,7 +395,8 @@ export const AnimationView = ({
|
|
|
374
395
|
...preparedStyles,
|
|
375
396
|
additionalData.saveArea ? styles.flex : null,
|
|
376
397
|
(videoModalState.mode === "MAXIMIZED" ||
|
|
377
|
-
videoModalState.mode === "MINIMIZED"
|
|
398
|
+
videoModalState.mode === "MINIMIZED" ||
|
|
399
|
+
(videoModalState.mode === "PIP" && isAppActive)) &&
|
|
378
400
|
getAnimationStyle(animationType, animatedValue),
|
|
379
401
|
]}
|
|
380
402
|
>
|
|
@@ -412,6 +434,7 @@ export const AnimationComponent = (props: Props) => {
|
|
|
412
434
|
delete additionalData.extraAnimation[animationType];
|
|
413
435
|
|
|
414
436
|
return (
|
|
437
|
+
// @ts-ignore
|
|
415
438
|
<Component {...(isReactFragment ? null : props)}>
|
|
416
439
|
<AnimationComponent
|
|
417
440
|
{...animationProps}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { Animated } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
|
+
import {
|
|
6
|
+
useGetBottomTabBarHeight,
|
|
7
|
+
useDimensions,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
9
|
|
|
7
10
|
import { useConfiguration } from "../utils";
|
|
8
11
|
|
|
@@ -90,9 +93,17 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
90
93
|
const translateYOffset = React.useRef(new Animated.Value(0)).current;
|
|
91
94
|
const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
|
|
92
95
|
|
|
93
|
-
const { height } =
|
|
96
|
+
const { height } = useDimensions("window", { fullDimensions: true });
|
|
97
|
+
const { bottom: bottomSafeArea } = useSafeAreaInsets();
|
|
94
98
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
95
|
-
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
|
|
102
|
+
Because of this we need to minus bottom SafeArea offset.
|
|
103
|
+
*/
|
|
104
|
+
const minValue =
|
|
105
|
+
height - minimisedHeight - (bottomTabBarHeight || bottomSafeArea);
|
|
106
|
+
|
|
96
107
|
const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
|
|
97
108
|
// Last snap state which will helps us to make smooth responder to scrollview animation
|
|
98
109
|
const [lastSnap, setLastSnap] = React.useState<number>(modalSnapPoints[0]);
|
|
@@ -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
|
|