@applicaster/zapp-react-native-ui-components 12.0.0-alpha.8433353116 → 12.0.0-alpha.8454200631
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/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/Layout/TV/index.tsx +12 -9
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -109
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/utils/index.ts +16 -5
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +16 -9
- package/Components/PlayerImageBackground/index.tsx +34 -8
- package/Components/River/ComponentsMap/ComponentsMap.tsx +92 -22
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/__tests__/componentsMap.test.js +6 -0
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
- package/Components/Screen/index.tsx +36 -25
- package/Components/Transitioner/Scene.tsx +24 -19
- package/Components/Transitioner/Transitioner.tsx +9 -2
- 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 +3 -0
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +20 -5
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
- package/Components/VideoModal/ModalAnimation/index.ts +15 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- package/Components/VideoModal/PlayerWrapper.tsx +78 -48
- package/Components/VideoModal/VideoModal.tsx +25 -42
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +151 -119
- package/Components/VideoModal/utils.ts +3 -3
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/Viewport/ViewportTracker/index.tsx +1 -0
- package/Components/Viewport/utils.js +1 -1
- package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
- package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
- package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
- package/Contexts/ScreenContext/index.tsx +94 -25
- package/Contexts/ScreenDataContext/index.ts +3 -0
- package/events/index.ts +1 -0
- package/package.json +5 -5
- package/Components/VideoModal/hooks/usePosition.ts +0 -50
- /package/Contexts/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
useSafeAreaFrame,
|
|
6
|
+
useSafeAreaInsets,
|
|
7
|
+
} from "react-native-safe-area-context";
|
|
8
|
+
import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
9
|
+
|
|
10
|
+
import { useConfiguration } from "../utils";
|
|
11
|
+
|
|
12
|
+
export enum PlayerAnimationStateEnum {
|
|
13
|
+
minimize = "minimize",
|
|
14
|
+
maximaze = "maximaze",
|
|
15
|
+
drag_player = "drag_player",
|
|
16
|
+
drag_scroll = "drag_scroll",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
|
|
20
|
+
|
|
21
|
+
export type ModalAnimationContextT = {
|
|
22
|
+
isActiveGesture: boolean;
|
|
23
|
+
playerAnimationState: PlayerAnimationStateT;
|
|
24
|
+
setPlayerAnimationState: (value: PlayerAnimationStateT) => void;
|
|
25
|
+
startComponentsAnimation: boolean;
|
|
26
|
+
setStartComponentsAnimation: (value: boolean) => void;
|
|
27
|
+
resetPlayerAnimationState: () => void;
|
|
28
|
+
minimisedHeight: number;
|
|
29
|
+
animatedValues: {
|
|
30
|
+
lastScrollY: Animated.Value;
|
|
31
|
+
dragScrollY: Animated.Value;
|
|
32
|
+
dragVideoPlayerY: Animated.Value;
|
|
33
|
+
translateYOffset: Animated.Value;
|
|
34
|
+
};
|
|
35
|
+
lastScrollYValue: React.MutableRefObject<number>;
|
|
36
|
+
scrollPosition: React.MutableRefObject<number>;
|
|
37
|
+
modalSnapPoints: number[];
|
|
38
|
+
lastSnap: number;
|
|
39
|
+
setLastSnap: (value: number) => void;
|
|
40
|
+
tabletLandscapePlayerTopPosition: number;
|
|
41
|
+
setTabletLandscapePlayerTopPosition: (value: number) => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
45
|
+
isActiveGesture: false,
|
|
46
|
+
playerAnimationState: null,
|
|
47
|
+
setPlayerAnimationState: () => null,
|
|
48
|
+
startComponentsAnimation: false,
|
|
49
|
+
setStartComponentsAnimation: () => null,
|
|
50
|
+
resetPlayerAnimationState: () => null,
|
|
51
|
+
minimisedHeight: 60,
|
|
52
|
+
animatedValues: {
|
|
53
|
+
lastScrollY: new Animated.Value(0),
|
|
54
|
+
dragScrollY: new Animated.Value(0),
|
|
55
|
+
dragVideoPlayerY: new Animated.Value(0),
|
|
56
|
+
translateYOffset: new Animated.Value(0),
|
|
57
|
+
},
|
|
58
|
+
lastScrollYValue: null,
|
|
59
|
+
scrollPosition: null,
|
|
60
|
+
modalSnapPoints: [0, 0],
|
|
61
|
+
lastSnap: 0,
|
|
62
|
+
setLastSnap: () => null,
|
|
63
|
+
tabletLandscapePlayerTopPosition: 0,
|
|
64
|
+
setTabletLandscapePlayerTopPosition: () => null,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export function useModalAnimationContext() {
|
|
68
|
+
return useContext<ModalAnimationContextT>(ReactContext);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
72
|
+
const [playerAnimationState, setPlayerAnimationState] =
|
|
73
|
+
React.useState<PlayerAnimationStateT>(null);
|
|
74
|
+
|
|
75
|
+
const [
|
|
76
|
+
tabletLandscapePlayerTopPosition,
|
|
77
|
+
setTabletLandscapePlayerTopPosition,
|
|
78
|
+
] = React.useState<number>(0);
|
|
79
|
+
|
|
80
|
+
const [startComponentsAnimation, setStartComponentsAnimation] =
|
|
81
|
+
React.useState<boolean>(false);
|
|
82
|
+
|
|
83
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
84
|
+
|
|
85
|
+
const resetPlayerAnimationState = React.useCallback(() => {
|
|
86
|
+
setPlayerAnimationState(null);
|
|
87
|
+
setStartComponentsAnimation(false);
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
// Animated values
|
|
91
|
+
const lastScrollY = React.useRef(new Animated.Value(0)).current;
|
|
92
|
+
const dragScrollY = React.useRef(new Animated.Value(0)).current;
|
|
93
|
+
const translateYOffset = React.useRef(new Animated.Value(0)).current;
|
|
94
|
+
const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
|
|
95
|
+
|
|
96
|
+
const { height } = useSafeAreaFrame();
|
|
97
|
+
const { bottom: bottomSafeArea } = useSafeAreaInsets();
|
|
98
|
+
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
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
|
+
|
|
107
|
+
const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
|
|
108
|
+
// Last snap state which will helps us to make smooth responder to scrollview animation
|
|
109
|
+
const [lastSnap, setLastSnap] = React.useState<number>(modalSnapPoints[0]);
|
|
110
|
+
// Extracted animated values which we will use for calculations
|
|
111
|
+
const lastScrollYValue = React.useRef<number>(0);
|
|
112
|
+
const scrollPosition = React.useRef<number>(0);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<ReactContext.Provider
|
|
116
|
+
value={{
|
|
117
|
+
startComponentsAnimation,
|
|
118
|
+
setStartComponentsAnimation,
|
|
119
|
+
isActiveGesture: playerAnimationState !== null,
|
|
120
|
+
playerAnimationState,
|
|
121
|
+
setPlayerAnimationState,
|
|
122
|
+
resetPlayerAnimationState,
|
|
123
|
+
minimisedHeight,
|
|
124
|
+
animatedValues: {
|
|
125
|
+
lastScrollY,
|
|
126
|
+
dragScrollY,
|
|
127
|
+
dragVideoPlayerY,
|
|
128
|
+
translateYOffset,
|
|
129
|
+
},
|
|
130
|
+
lastScrollYValue,
|
|
131
|
+
scrollPosition,
|
|
132
|
+
modalSnapPoints,
|
|
133
|
+
lastSnap,
|
|
134
|
+
setLastSnap,
|
|
135
|
+
tabletLandscapePlayerTopPosition,
|
|
136
|
+
setTabletLandscapePlayerTopPosition,
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
{children}
|
|
140
|
+
</ReactContext.Provider>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const withModalAnimationProvider = (Component) => {
|
|
145
|
+
const WithProvider = (props) => {
|
|
146
|
+
return (
|
|
147
|
+
<Provider>
|
|
148
|
+
<Component {...props} />
|
|
149
|
+
</Provider>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return WithProvider;
|
|
154
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { AnimatedPlayerModalWrapper } from "./AnimatedPlayerModalWrapper";
|
|
2
|
+
|
|
3
|
+
export { AnimatedScrollModal } from "./AnimatedScrollModal";
|
|
4
|
+
|
|
5
|
+
export { AnimatedVideoPlayerComponent } from "./AnimatedVideoPlayerComponent";
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
withModalAnimationProvider,
|
|
9
|
+
useModalAnimationContext,
|
|
10
|
+
PlayerAnimationStateEnum,
|
|
11
|
+
} from "./ModalAnimationContext";
|
|
12
|
+
|
|
13
|
+
export { AnimationComponent } from "./AnimationComponent";
|
|
14
|
+
|
|
15
|
+
export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/* eslint-disable padding-line-between-statements */
|
|
2
|
+
|
|
3
|
+
import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
4
|
+
|
|
5
|
+
export enum ComponentAnimationType {
|
|
6
|
+
bottomBar = "bottomBar",
|
|
7
|
+
player = "player",
|
|
8
|
+
componentFade = "componentFade",
|
|
9
|
+
componentAppears = "componentAppears",
|
|
10
|
+
moveUpComponent = "moveUpComponent",
|
|
11
|
+
moveComponentHorizontal = "moveComponentHorizontal",
|
|
12
|
+
audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
|
|
16
|
+
|
|
17
|
+
export const defaultAspectRatioWidth = (height: number): number =>
|
|
18
|
+
(height / 9) * 16;
|
|
19
|
+
|
|
20
|
+
export const getAnimationStyle = (component, animatedValue) => {
|
|
21
|
+
switch (component) {
|
|
22
|
+
case ComponentAnimationType.bottomBar: {
|
|
23
|
+
return { zIndex: 99, transform: [{ translateY: animatedValue }] };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
case ComponentAnimationType.player: {
|
|
27
|
+
return { width: animatedValue.x, height: animatedValue.y };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
case ComponentAnimationType.componentFade:
|
|
31
|
+
case ComponentAnimationType.componentAppears: {
|
|
32
|
+
return { opacity: animatedValue };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
case ComponentAnimationType.moveUpComponent: {
|
|
36
|
+
return { transform: [{ translateY: animatedValue }] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
40
|
+
case ComponentAnimationType.moveComponentHorizontal: {
|
|
41
|
+
return { transform: [{ translateX: animatedValue }] };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
default:
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
|
|
50
|
+
switch (component) {
|
|
51
|
+
case ComponentAnimationType.bottomBar: {
|
|
52
|
+
return bottomTabBarHeight;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case ComponentAnimationType.player: {
|
|
56
|
+
return { x: 0, y: 0 };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case ComponentAnimationType.componentFade: {
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
64
|
+
case ComponentAnimationType.moveComponentHorizontal:
|
|
65
|
+
case ComponentAnimationType.componentAppears:
|
|
66
|
+
case ComponentAnimationType.moveUpComponent: {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const calculateAnimationValue = (animationType, dragPosition, data) => {
|
|
73
|
+
const {
|
|
74
|
+
isAudioItem,
|
|
75
|
+
bottomTabBarHeight,
|
|
76
|
+
minimisedHeight,
|
|
77
|
+
minimisedWidth,
|
|
78
|
+
defaultValue,
|
|
79
|
+
moveUpValue,
|
|
80
|
+
moveComponentHorizontalValue,
|
|
81
|
+
isTablet,
|
|
82
|
+
isTabletLandscape,
|
|
83
|
+
isRTL,
|
|
84
|
+
fromMiniPlayer,
|
|
85
|
+
inlineAudioPlayer,
|
|
86
|
+
} = data;
|
|
87
|
+
|
|
88
|
+
switch (animationType) {
|
|
89
|
+
case ComponentAnimationType.bottomBar: {
|
|
90
|
+
if (fromMiniPlayer) {
|
|
91
|
+
return dragPosition < bottomTabBarHeight
|
|
92
|
+
? dragPosition
|
|
93
|
+
: bottomTabBarHeight;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return dragPosition < bottomTabBarHeight
|
|
97
|
+
? bottomTabBarHeight - dragPosition
|
|
98
|
+
: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
case ComponentAnimationType.player: {
|
|
102
|
+
const value =
|
|
103
|
+
isAudioItem && !inlineAudioPlayer
|
|
104
|
+
? isTabletLandscape
|
|
105
|
+
? fromMiniPlayer
|
|
106
|
+
? { forWidth: 4, forHeight: 4.5 }
|
|
107
|
+
: { forWidth: 3, forHeight: 3 }
|
|
108
|
+
: { forWidth: 2, forHeight: 2 }
|
|
109
|
+
: isTabletLandscape
|
|
110
|
+
? { forWidth: 8, forHeight: 6.5 }
|
|
111
|
+
: { forWidth: 3.5, forHeight: 2 };
|
|
112
|
+
|
|
113
|
+
const minWidth =
|
|
114
|
+
isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
|
|
115
|
+
|
|
116
|
+
if (fromMiniPlayer) {
|
|
117
|
+
const calculationWidth =
|
|
118
|
+
dragPosition * value.forWidth < minWidth
|
|
119
|
+
? minWidth
|
|
120
|
+
: dragPosition * value.forWidth;
|
|
121
|
+
const calculationHeight =
|
|
122
|
+
dragPosition * value.forHeight < minimisedHeight
|
|
123
|
+
? minimisedHeight
|
|
124
|
+
: dragPosition * value.forHeight;
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
x:
|
|
128
|
+
calculationWidth < defaultValue.x
|
|
129
|
+
? calculationWidth
|
|
130
|
+
: defaultValue.x,
|
|
131
|
+
y:
|
|
132
|
+
calculationHeight < defaultValue.y
|
|
133
|
+
? calculationHeight
|
|
134
|
+
: defaultValue.y,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
|
|
139
|
+
|
|
140
|
+
const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
x: calculationWidth > minWidth ? calculationWidth : minWidth,
|
|
144
|
+
y:
|
|
145
|
+
calculationHeight > minimisedHeight
|
|
146
|
+
? calculationHeight
|
|
147
|
+
: minimisedHeight,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
case ComponentAnimationType.componentFade: {
|
|
152
|
+
if (fromMiniPlayer) {
|
|
153
|
+
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
154
|
+
|
|
155
|
+
return calculation < 1 ? calculation : 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
159
|
+
|
|
160
|
+
return calculation > 0 ? calculation : 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case ComponentAnimationType.componentAppears: {
|
|
164
|
+
if (fromMiniPlayer) {
|
|
165
|
+
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
166
|
+
|
|
167
|
+
return calculation > 0 ? calculation : 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
171
|
+
|
|
172
|
+
return calculation < 1 ? calculation : 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
case ComponentAnimationType.moveUpComponent: {
|
|
176
|
+
if (fromMiniPlayer) {
|
|
177
|
+
const calculation =
|
|
178
|
+
moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
|
|
179
|
+
|
|
180
|
+
return calculation < 0 ? calculation : 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
|
|
184
|
+
|
|
185
|
+
return calculation > moveUpValue ? calculation : moveUpValue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
case ComponentAnimationType.moveComponentHorizontal: {
|
|
189
|
+
if (fromMiniPlayer) {
|
|
190
|
+
const calculation = isRTL
|
|
191
|
+
? moveComponentHorizontalValue - dragPosition * 2
|
|
192
|
+
: moveComponentHorizontalValue + dragPosition * 2;
|
|
193
|
+
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
194
|
+
|
|
195
|
+
return condition ? calculation : 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
|
|
199
|
+
const condition = isRTL
|
|
200
|
+
? calculation < moveComponentHorizontalValue
|
|
201
|
+
: calculation > moveComponentHorizontalValue;
|
|
202
|
+
|
|
203
|
+
return condition ? calculation : moveComponentHorizontalValue;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
case ComponentAnimationType.audioPlayerPaddingHorizontal: {
|
|
207
|
+
const padding = isRTL
|
|
208
|
+
? AUDIO_PLAYER_HORIZONTAL_PADDING
|
|
209
|
+
: -AUDIO_PLAYER_HORIZONTAL_PADDING;
|
|
210
|
+
|
|
211
|
+
if (fromMiniPlayer) {
|
|
212
|
+
const calculation = isRTL
|
|
213
|
+
? padding - dragPosition / 5
|
|
214
|
+
: padding + dragPosition / 5;
|
|
215
|
+
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
216
|
+
|
|
217
|
+
return condition ? calculation : 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
|
|
221
|
+
const condition = isRTL ? calculation < padding : calculation > padding;
|
|
222
|
+
|
|
223
|
+
return condition ? calculation : padding;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export const gestureListenerHelper = (data) => {
|
|
229
|
+
const {
|
|
230
|
+
listenerValue,
|
|
231
|
+
preparedValue,
|
|
232
|
+
animationType,
|
|
233
|
+
animatedValue,
|
|
234
|
+
calculationData,
|
|
235
|
+
modalSnapPoint,
|
|
236
|
+
startAnimationDistance,
|
|
237
|
+
startComponentsAnimation,
|
|
238
|
+
setStartComponentsAnimation,
|
|
239
|
+
getAnimationValue,
|
|
240
|
+
} = data;
|
|
241
|
+
|
|
242
|
+
if (calculationData.fromMiniPlayer) {
|
|
243
|
+
if (listenerValue <= 0) {
|
|
244
|
+
if (
|
|
245
|
+
preparedValue >= 0 &&
|
|
246
|
+
preparedValue <= modalSnapPoint - startAnimationDistance
|
|
247
|
+
) {
|
|
248
|
+
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
249
|
+
|
|
250
|
+
animatedValue.setValue(
|
|
251
|
+
calculateAnimationValue(animationType, preparedValue, calculationData)
|
|
252
|
+
);
|
|
253
|
+
} else {
|
|
254
|
+
animatedValue.setValue(calculationData.defaultValue);
|
|
255
|
+
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
const value = getAnimationValue(
|
|
259
|
+
animationType,
|
|
260
|
+
PlayerAnimationStateEnum.minimize
|
|
261
|
+
).toValue;
|
|
262
|
+
|
|
263
|
+
animatedValue.setValue(value);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
if (preparedValue >= startAnimationDistance) {
|
|
267
|
+
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
268
|
+
const value = Math.round(preparedValue - startAnimationDistance);
|
|
269
|
+
|
|
270
|
+
animatedValue.setValue(
|
|
271
|
+
calculateAnimationValue(animationType, value, calculationData)
|
|
272
|
+
);
|
|
273
|
+
} else {
|
|
274
|
+
animatedValue.setValue(calculationData.defaultValue);
|
|
275
|
+
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export const setScrollModalAnimatedValue = (
|
|
281
|
+
animatedValue,
|
|
282
|
+
value,
|
|
283
|
+
setLastSnap
|
|
284
|
+
) => {
|
|
285
|
+
setLastSnap(value);
|
|
286
|
+
animatedValue.setValue(value);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const resetScrollAnimatedValues = (
|
|
290
|
+
lastScrollY,
|
|
291
|
+
lastScrollYValue,
|
|
292
|
+
dragScrollY,
|
|
293
|
+
dragVideoPlayerY
|
|
294
|
+
) => {
|
|
295
|
+
lastScrollY.setValue(0);
|
|
296
|
+
lastScrollYValue.current = 0;
|
|
297
|
+
dragScrollY.setValue(0);
|
|
298
|
+
dragVideoPlayerY.setValue(0);
|
|
299
|
+
};
|
|
@@ -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
|
|
|
@@ -14,10 +14,18 @@ import { PlayerDetails } from "./PlayerDetails";
|
|
|
14
14
|
import { playerDimesionsHack } from "./utils";
|
|
15
15
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
16
16
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
17
|
+
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
AnimatedScrollModal,
|
|
21
|
+
AnimatedVideoPlayerComponent,
|
|
22
|
+
AnimationComponent,
|
|
23
|
+
ComponentAnimationType,
|
|
24
|
+
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
17
25
|
|
|
18
26
|
type DimensionsT = {
|
|
19
27
|
width: number | string;
|
|
20
|
-
height: number | string;
|
|
28
|
+
height: number | string | undefined;
|
|
21
29
|
aspectRatio?: number;
|
|
22
30
|
};
|
|
23
31
|
|
|
@@ -44,6 +52,7 @@ type Props = {
|
|
|
44
52
|
const defaultStyles = StyleSheet.create({
|
|
45
53
|
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
46
54
|
playerDetails: { flex: 1, paddingTop: 20 },
|
|
55
|
+
flex: { flex: 1 },
|
|
47
56
|
});
|
|
48
57
|
|
|
49
58
|
const orientationStyles = StyleSheet.create({
|
|
@@ -82,18 +91,9 @@ const safeAreaStyles = (
|
|
|
82
91
|
};
|
|
83
92
|
};
|
|
84
93
|
|
|
85
|
-
const getEdges = (
|
|
86
|
-
isTablet: boolean,
|
|
87
|
-
docked: boolean,
|
|
88
|
-
isInlineModal: boolean
|
|
89
|
-
) => {
|
|
94
|
+
const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
90
95
|
if (isTablet) {
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// mobile
|
|
95
|
-
if (isInlineModal && docked) {
|
|
96
|
-
return ["bottom"];
|
|
96
|
+
return ["top"];
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (!isInlineModal && Platform.OS === "android") {
|
|
@@ -151,9 +151,9 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
151
151
|
() => ({
|
|
152
152
|
width:
|
|
153
153
|
isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
|
|
154
|
-
height:
|
|
154
|
+
height: undefined,
|
|
155
155
|
}),
|
|
156
|
-
[isInlineModal, tabletWidth,
|
|
156
|
+
[isInlineModal, tabletWidth, docked]
|
|
157
157
|
);
|
|
158
158
|
|
|
159
159
|
const playerDimensions: DimensionsT = React.useMemo(
|
|
@@ -181,41 +181,71 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
181
181
|
[containerDimensions, playerDimesionsHack]
|
|
182
182
|
);
|
|
183
183
|
|
|
184
|
+
const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
|
|
185
|
+
|
|
184
186
|
return (
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
style={
|
|
199
|
-
defaultStyles.playerContainer,
|
|
200
|
-
containerDimensions,
|
|
201
|
-
containerStyle,
|
|
202
|
-
playerDimesionsHack,
|
|
203
|
-
]}
|
|
187
|
+
<ScreenContextProvider pathname={pathname}>
|
|
188
|
+
<PathnameContext.Provider value={pathname}>
|
|
189
|
+
<WrapperView
|
|
190
|
+
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
191
|
+
style={[
|
|
192
|
+
safeAreaStyles(configuration, isTablet),
|
|
193
|
+
style,
|
|
194
|
+
playerDimesionsHack,
|
|
195
|
+
]}
|
|
196
|
+
>
|
|
197
|
+
<AnimationComponent
|
|
198
|
+
animationType={ComponentAnimationType.moveUpComponent}
|
|
199
|
+
additionalData={{ saveArea: true }}
|
|
200
|
+
style={directionStyles(isTabletLandscape)}
|
|
204
201
|
>
|
|
205
|
-
{
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
202
|
+
<ScreenContextProvider pathname={pathname}>
|
|
203
|
+
<PathnameContext.Provider value={pathname}>
|
|
204
|
+
<View
|
|
205
|
+
testID={`${entry?.id}-player-container`}
|
|
206
|
+
style={[
|
|
207
|
+
defaultStyles.playerContainer,
|
|
208
|
+
containerDimensions,
|
|
209
|
+
containerStyle,
|
|
210
|
+
playerDimesionsHack,
|
|
211
|
+
]}
|
|
212
|
+
>
|
|
213
|
+
<AnimationComponent
|
|
214
|
+
animationType={ComponentAnimationType.moveUpComponent}
|
|
215
|
+
style={isTabletLandscape ? defaultStyles.flex : undefined}
|
|
216
|
+
additionalData={{
|
|
217
|
+
useLayoutMeasure: isTabletLandscape,
|
|
218
|
+
disableAnimatedComponent: !isTabletLandscape,
|
|
219
|
+
resetAnimationValue: isTabletLandscape && docked,
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<AnimatedVideoPlayerComponent>
|
|
223
|
+
{children(childrenStyles)}
|
|
224
|
+
</AnimatedVideoPlayerComponent>
|
|
225
|
+
</AnimationComponent>
|
|
226
|
+
</View>
|
|
227
|
+
<AnimatedScrollModal>
|
|
228
|
+
{isInlineModal ? (
|
|
229
|
+
<AnimationComponent
|
|
230
|
+
animationType={ComponentAnimationType.componentFade}
|
|
231
|
+
style={defaultStyles.flex}
|
|
232
|
+
>
|
|
233
|
+
<PlayerDetails
|
|
234
|
+
configuration={configuration}
|
|
235
|
+
style={defaultStyles.playerDetails}
|
|
236
|
+
entry={entry}
|
|
237
|
+
isTabletLandscape={isTabletLandscape}
|
|
238
|
+
/>
|
|
239
|
+
</AnimationComponent>
|
|
240
|
+
) : (
|
|
241
|
+
<View style={defaultStyles.playerDetails} />
|
|
242
|
+
)}
|
|
243
|
+
</AnimatedScrollModal>
|
|
244
|
+
</PathnameContext.Provider>
|
|
245
|
+
</ScreenContextProvider>
|
|
246
|
+
</AnimationComponent>
|
|
247
|
+
</WrapperView>
|
|
248
|
+
</PathnameContext.Provider>
|
|
249
|
+
</ScreenContextProvider>
|
|
220
250
|
);
|
|
221
251
|
};
|