@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5945373352 → 15.0.0-alpha.6141436051
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/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/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +4 -487
- package/Components/VideoModal/ModalAnimation/index.ts +0 -6
- package/Components/VideoModal/ModalAnimation/utils.ts +0 -315
- package/Components/VideoModal/PlayerWrapper.tsx +23 -59
- package/Components/VideoModal/hooks/useModalSize.ts +5 -4
- package/Components/VideoModal/playerWrapperUtils.ts +87 -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
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Animated, StyleSheet } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
-
import { PanGestureHandler, State } from "react-native-gesture-handler";
|
|
6
|
-
|
|
7
|
-
import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
|
|
8
|
-
import {
|
|
9
|
-
useModalAnimationContext,
|
|
10
|
-
PlayerAnimationStateEnum,
|
|
11
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
12
|
-
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
13
|
-
|
|
14
|
-
const generalStyles = StyleSheet.create({
|
|
15
|
-
container: {
|
|
16
|
-
flex: 1,
|
|
17
|
-
width: "100%",
|
|
18
|
-
position: "absolute",
|
|
19
|
-
zIndex: 201,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
type Props = {
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
28
|
-
const {
|
|
29
|
-
playerAnimationState,
|
|
30
|
-
setPlayerAnimationState,
|
|
31
|
-
animatedValues: { translateYOffset, dragVideoPlayerY, lastScrollY },
|
|
32
|
-
lastScrollYValue,
|
|
33
|
-
modalSnapPoints,
|
|
34
|
-
lastSnap,
|
|
35
|
-
setLastSnap,
|
|
36
|
-
resetPlayerAnimationState,
|
|
37
|
-
setStartComponentsAnimation,
|
|
38
|
-
} = useModalAnimationContext();
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
videoModalState: { mode: videoModalMode },
|
|
42
|
-
} = useNavigation();
|
|
43
|
-
|
|
44
|
-
const { isLanguageOverlayVisible, isSeekBarTouch } = React.useContext(
|
|
45
|
-
PlayerContainerContext
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const isMaximazedModal = videoModalMode === "MAXIMIZED";
|
|
49
|
-
const isMinimizedModal = videoModalMode === "MINIMIZED";
|
|
50
|
-
|
|
51
|
-
const isNotMinimizeMaximazeAnimation =
|
|
52
|
-
playerAnimationState !== PlayerAnimationStateEnum.minimize &&
|
|
53
|
-
playerAnimationState !== PlayerAnimationStateEnum.maximize;
|
|
54
|
-
|
|
55
|
-
const isEnablePanGesture =
|
|
56
|
-
!isLanguageOverlayVisible &&
|
|
57
|
-
isNotMinimizeMaximazeAnimation &&
|
|
58
|
-
!isSeekBarTouch &&
|
|
59
|
-
(isMaximazedModal || isMinimizedModal);
|
|
60
|
-
|
|
61
|
-
const onGestureEvent = Animated.event(
|
|
62
|
-
[{ nativeEvent: { translationY: dragVideoPlayerY } }],
|
|
63
|
-
{ useNativeDriver: true }
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const onHandlerStateChange = React.useCallback(
|
|
67
|
-
({ nativeEvent }) => {
|
|
68
|
-
if (nativeEvent.oldState === State.ACTIVE) {
|
|
69
|
-
// eslint-disable-next-line prefer-const
|
|
70
|
-
const { velocityY, translationY } = nativeEvent;
|
|
71
|
-
const preparedTranslationY = Math.abs(translationY);
|
|
72
|
-
const dragToss = 0.05;
|
|
73
|
-
|
|
74
|
-
if (videoModalMode === "MAXIMIZED") {
|
|
75
|
-
if (translationY > 0) {
|
|
76
|
-
const endOffsetY =
|
|
77
|
-
lastSnap + preparedTranslationY + dragToss * velocityY + 200;
|
|
78
|
-
|
|
79
|
-
let destSnapPoint = modalSnapPoints[0];
|
|
80
|
-
|
|
81
|
-
for (const snapPoint of modalSnapPoints) {
|
|
82
|
-
const distFromSnap = Math.abs(snapPoint - endOffsetY);
|
|
83
|
-
|
|
84
|
-
if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
|
|
85
|
-
destSnapPoint = snapPoint;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setLastSnap(destSnapPoint);
|
|
90
|
-
|
|
91
|
-
if (destSnapPoint === modalSnapPoints[0]) {
|
|
92
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
|
|
93
|
-
} else {
|
|
94
|
-
lastScrollY.setValue(0);
|
|
95
|
-
lastScrollYValue.current = 0;
|
|
96
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
} else if (videoModalMode === "MINIMIZED") {
|
|
100
|
-
if (translationY < 0) {
|
|
101
|
-
// from mini to full
|
|
102
|
-
setLastSnap(modalSnapPoints[0]);
|
|
103
|
-
|
|
104
|
-
translateYOffset.setValue(
|
|
105
|
-
modalSnapPoints[1] - preparedTranslationY
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
|
|
109
|
-
} else {
|
|
110
|
-
resetPlayerAnimationState();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
[lastSnap, modalSnapPoints, videoModalMode]
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
|
|
120
|
-
({ value }) => {
|
|
121
|
-
if (
|
|
122
|
-
(isMinimizedModal && value >= 0) ||
|
|
123
|
-
(isMaximazedModal && value <= 0)
|
|
124
|
-
) {
|
|
125
|
-
if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
|
|
126
|
-
translateYOffset.setValue(
|
|
127
|
-
modalSnapPoints[isMinimizedModal ? 1 : 0]
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
const preparedValue = Math.round(Math.abs(value));
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
preparedValue > 0 &&
|
|
135
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
136
|
-
) {
|
|
137
|
-
if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
|
|
138
|
-
isMinimizedModal && setStartComponentsAnimation(true);
|
|
139
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
translateYOffset.setValue(
|
|
143
|
-
isMaximazedModal
|
|
144
|
-
? preparedValue
|
|
145
|
-
: modalSnapPoints[1] - preparedValue
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
return () => {
|
|
153
|
-
dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
|
|
154
|
-
};
|
|
155
|
-
}, [playerAnimationState, isMinimizedModal, isMaximazedModal]);
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<PanGestureHandler
|
|
159
|
-
enabled={isEnablePanGesture}
|
|
160
|
-
onGestureEvent={onGestureEvent}
|
|
161
|
-
onHandlerStateChange={onHandlerStateChange}
|
|
162
|
-
>
|
|
163
|
-
<Animated.View style={generalStyles.container}>{children}</Animated.View>
|
|
164
|
-
</PanGestureHandler>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
|
|
169
|
-
const {
|
|
170
|
-
videoModalState: { visible },
|
|
171
|
-
} = useNavigation();
|
|
172
|
-
|
|
173
|
-
const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
|
|
174
|
-
|
|
175
|
-
return <Component>{children}</Component>;
|
|
176
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Animated, StyleSheet } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
useModalAnimationContext,
|
|
8
|
-
PlayerAnimationStateEnum,
|
|
9
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
10
|
-
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
11
|
-
|
|
12
|
-
const generalStyles = StyleSheet.create({
|
|
13
|
-
container: {
|
|
14
|
-
flex: 1,
|
|
15
|
-
width: "100%",
|
|
16
|
-
position: "absolute",
|
|
17
|
-
zIndex: 201,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type Props = {
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const AnimatedVideoPlayer = ({ children }: Props) => {
|
|
26
|
-
const {
|
|
27
|
-
playerAnimationState,
|
|
28
|
-
setPlayerAnimationState,
|
|
29
|
-
animatedValues: { translateYOffset, dragVideoPlayerY },
|
|
30
|
-
modalSnapPoints,
|
|
31
|
-
setStartComponentsAnimation,
|
|
32
|
-
} = useModalAnimationContext();
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
videoModalState: { mode: videoModalMode },
|
|
36
|
-
} = useNavigation();
|
|
37
|
-
|
|
38
|
-
const isMaximazedModal = videoModalMode === "MAXIMIZED";
|
|
39
|
-
const isMinimizedModal = videoModalMode === "MINIMIZED";
|
|
40
|
-
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
|
|
43
|
-
({ value }) => {
|
|
44
|
-
if (
|
|
45
|
-
(isMinimizedModal && value >= 0) ||
|
|
46
|
-
(isMaximazedModal && value <= 0)
|
|
47
|
-
) {
|
|
48
|
-
if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
|
|
49
|
-
translateYOffset.setValue(
|
|
50
|
-
modalSnapPoints[isMinimizedModal ? 1 : 0]
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
const preparedValue = Math.round(Math.abs(value));
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
preparedValue > 0 &&
|
|
58
|
-
playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
|
|
59
|
-
) {
|
|
60
|
-
if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
|
|
61
|
-
isMinimizedModal && setStartComponentsAnimation(true);
|
|
62
|
-
setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
translateYOffset.setValue(
|
|
66
|
-
isMaximazedModal
|
|
67
|
-
? preparedValue
|
|
68
|
-
: modalSnapPoints[1] - preparedValue
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return () => {
|
|
76
|
-
dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
|
|
77
|
-
};
|
|
78
|
-
}, [playerAnimationState, isMinimizedModal, isMaximazedModal]);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Animated.View style={generalStyles.container}>{children}</Animated.View>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
|
|
86
|
-
const {
|
|
87
|
-
videoModalState: { visible },
|
|
88
|
-
} = useNavigation();
|
|
89
|
-
|
|
90
|
-
const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
|
|
91
|
-
|
|
92
|
-
return <Component>{children}</Component>;
|
|
93
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { getMoveUpValue } from "../utils";
|
|
2
|
-
|
|
3
|
-
describe("getMoveUpValue", () => {
|
|
4
|
-
it("returns correct value when additionalData.saveArea is true and isAudioItem is false", () => {
|
|
5
|
-
const result = getMoveUpValue({
|
|
6
|
-
additionalData: { saveArea: true },
|
|
7
|
-
insets: { top: 20 },
|
|
8
|
-
isAudioItem: false,
|
|
9
|
-
progressBarHeight: 10,
|
|
10
|
-
isTablet: false,
|
|
11
|
-
isTabletLandscape: false,
|
|
12
|
-
inlineAudioPlayer: false,
|
|
13
|
-
tabletLandscapePlayerTopPosition: 100,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
expect(result).toBe(-20 + 10);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns correct value when additionalData.saveArea is true and isAudioItem is true", () => {
|
|
20
|
-
const result = getMoveUpValue({
|
|
21
|
-
additionalData: { saveArea: true },
|
|
22
|
-
insets: { top: 15 },
|
|
23
|
-
isAudioItem: true,
|
|
24
|
-
progressBarHeight: 5,
|
|
25
|
-
isTablet: false,
|
|
26
|
-
isTabletLandscape: false,
|
|
27
|
-
inlineAudioPlayer: false,
|
|
28
|
-
tabletLandscapePlayerTopPosition: 100,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
expect(result).toBe(-15 + 0);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns correct value for audio item (tablet or not)", () => {
|
|
35
|
-
const result = getMoveUpValue({
|
|
36
|
-
additionalData: { marginTop: 30 },
|
|
37
|
-
insets: { top: 0 },
|
|
38
|
-
isAudioItem: true,
|
|
39
|
-
progressBarHeight: 0,
|
|
40
|
-
isTablet: false,
|
|
41
|
-
isTabletLandscape: false,
|
|
42
|
-
inlineAudioPlayer: false,
|
|
43
|
-
tabletLandscapePlayerTopPosition: 0,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(result).toBe(-30);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("returns correct value for tablet landscape with inline audio player", () => {
|
|
50
|
-
const result = getMoveUpValue({
|
|
51
|
-
additionalData: {},
|
|
52
|
-
insets: { top: 0 },
|
|
53
|
-
isAudioItem: true,
|
|
54
|
-
progressBarHeight: 8,
|
|
55
|
-
isTablet: true,
|
|
56
|
-
isTabletLandscape: true,
|
|
57
|
-
inlineAudioPlayer: true,
|
|
58
|
-
tabletLandscapePlayerTopPosition: 50,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(result).toBe(-0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("returns correct value for tablet landscape without audio item", () => {
|
|
65
|
-
const result = getMoveUpValue({
|
|
66
|
-
additionalData: {},
|
|
67
|
-
insets: { top: 0 },
|
|
68
|
-
isAudioItem: false,
|
|
69
|
-
progressBarHeight: 12,
|
|
70
|
-
isTablet: true,
|
|
71
|
-
isTabletLandscape: true,
|
|
72
|
-
inlineAudioPlayer: false,
|
|
73
|
-
tabletLandscapePlayerTopPosition: 60,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(result).toBe(-60 + 12);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("returns -130 for tablet portrait (not landscape)", () => {
|
|
80
|
-
const result = getMoveUpValue({
|
|
81
|
-
additionalData: {},
|
|
82
|
-
insets: { top: 0 },
|
|
83
|
-
isAudioItem: false,
|
|
84
|
-
progressBarHeight: 0,
|
|
85
|
-
isTablet: true,
|
|
86
|
-
isTabletLandscape: false,
|
|
87
|
-
inlineAudioPlayer: false,
|
|
88
|
-
tabletLandscapePlayerTopPosition: 0,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
expect(result).toBe(-130);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("returns -50 + progressBarHeight for mobile audio player in docked mode", () => {
|
|
95
|
-
const result = getMoveUpValue({
|
|
96
|
-
additionalData: {},
|
|
97
|
-
insets: { top: 0 },
|
|
98
|
-
isAudioItem: false,
|
|
99
|
-
progressBarHeight: 7,
|
|
100
|
-
isTablet: false,
|
|
101
|
-
isTabletLandscape: false,
|
|
102
|
-
inlineAudioPlayer: false,
|
|
103
|
-
tabletLandscapePlayerTopPosition: 0,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
expect(result).toBe(-50 + 7);
|
|
107
|
-
});
|
|
108
|
-
});
|