@applicaster/zapp-react-native-ui-components 15.0.0-alpha.3514407021 → 15.0.0-alpha.4368022015
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 +3 -22
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +3 -153
- package/Components/VideoModal/ModalAnimation/index.ts +2 -13
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
- package/Components/VideoModal/PlayerWrapper.tsx +31 -59
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/hooks/useModalSize.ts +5 -4
- package/Components/VideoModal/playerWrapperUtils.ts +104 -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/AnimationComponent.tsx +0 -500
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
|
@@ -1,332 +1,6 @@
|
|
|
1
|
-
/* eslint-disable padding-line-between-statements */
|
|
2
|
-
|
|
3
|
-
import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
4
|
-
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
5
|
-
|
|
6
|
-
export enum ComponentAnimationType {
|
|
7
|
-
bottomBar = "bottomBar",
|
|
8
|
-
player = "player",
|
|
9
|
-
componentFade = "componentFade",
|
|
10
|
-
componentAppears = "componentAppears",
|
|
11
|
-
moveUpComponent = "moveUpComponent",
|
|
12
|
-
moveComponentHorizontal = "moveComponentHorizontal",
|
|
13
|
-
audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
|
|
2
|
+
|
|
17
3
|
export const PROGRESS_BAR_HEIGHT = 3;
|
|
18
4
|
|
|
19
5
|
export const defaultAspectRatioWidth = (height: number): number =>
|
|
20
6
|
(height / 9) * 16;
|
|
21
|
-
|
|
22
|
-
export const getAnimationStyle = (component, animatedValue) => {
|
|
23
|
-
switch (component) {
|
|
24
|
-
case ComponentAnimationType.bottomBar: {
|
|
25
|
-
return { zIndex: 99, transform: [{ translateY: animatedValue }] };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
case ComponentAnimationType.player: {
|
|
29
|
-
return { width: animatedValue.x, height: animatedValue.y };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
case ComponentAnimationType.componentFade:
|
|
33
|
-
case ComponentAnimationType.componentAppears: {
|
|
34
|
-
return { opacity: animatedValue };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
38
|
-
return { transform: [{ translateY: animatedValue }] };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
42
|
-
case ComponentAnimationType.moveComponentHorizontal: {
|
|
43
|
-
return { transform: [{ translateX: animatedValue }] };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
default:
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
|
|
52
|
-
switch (component) {
|
|
53
|
-
case ComponentAnimationType.bottomBar: {
|
|
54
|
-
return bottomTabBarHeight;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
case ComponentAnimationType.player: {
|
|
58
|
-
return { x: 0, y: 0 };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
case ComponentAnimationType.componentFade: {
|
|
62
|
-
return 1;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal:
|
|
66
|
-
case ComponentAnimationType.moveComponentHorizontal:
|
|
67
|
-
case ComponentAnimationType.componentAppears:
|
|
68
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const calculateAnimationValue = (animationType, dragPosition, data) => {
|
|
75
|
-
const {
|
|
76
|
-
isAudioItem,
|
|
77
|
-
bottomTabBarHeight,
|
|
78
|
-
minimisedHeight,
|
|
79
|
-
minimisedWidth,
|
|
80
|
-
defaultValue,
|
|
81
|
-
moveUpValue,
|
|
82
|
-
moveComponentHorizontalValue,
|
|
83
|
-
isTablet,
|
|
84
|
-
isTabletLandscape,
|
|
85
|
-
isRTL,
|
|
86
|
-
fromMiniPlayer,
|
|
87
|
-
inlineAudioPlayer,
|
|
88
|
-
} = data;
|
|
89
|
-
|
|
90
|
-
switch (animationType) {
|
|
91
|
-
case ComponentAnimationType.bottomBar: {
|
|
92
|
-
if (fromMiniPlayer) {
|
|
93
|
-
return dragPosition < bottomTabBarHeight
|
|
94
|
-
? dragPosition
|
|
95
|
-
: bottomTabBarHeight;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return dragPosition < bottomTabBarHeight
|
|
99
|
-
? bottomTabBarHeight - dragPosition
|
|
100
|
-
: 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
case ComponentAnimationType.player: {
|
|
104
|
-
const value =
|
|
105
|
-
isAudioItem && !inlineAudioPlayer
|
|
106
|
-
? isTabletLandscape
|
|
107
|
-
? fromMiniPlayer
|
|
108
|
-
? { forWidth: 4, forHeight: 4.5 }
|
|
109
|
-
: { forWidth: 3, forHeight: 3 }
|
|
110
|
-
: { forWidth: 2, forHeight: 2 }
|
|
111
|
-
: isTabletLandscape
|
|
112
|
-
? { forWidth: 8, forHeight: 6.5 }
|
|
113
|
-
: { forWidth: 3.5, forHeight: 2 };
|
|
114
|
-
|
|
115
|
-
const minWidth =
|
|
116
|
-
isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
|
|
117
|
-
|
|
118
|
-
if (fromMiniPlayer) {
|
|
119
|
-
const calculationWidth =
|
|
120
|
-
dragPosition * value.forWidth < minWidth
|
|
121
|
-
? minWidth
|
|
122
|
-
: dragPosition * value.forWidth;
|
|
123
|
-
const calculationHeight =
|
|
124
|
-
dragPosition * value.forHeight < minimisedHeight
|
|
125
|
-
? minimisedHeight
|
|
126
|
-
: dragPosition * value.forHeight;
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
x:
|
|
130
|
-
calculationWidth < defaultValue.x
|
|
131
|
-
? calculationWidth
|
|
132
|
-
: defaultValue.x,
|
|
133
|
-
y:
|
|
134
|
-
calculationHeight < defaultValue.y
|
|
135
|
-
? calculationHeight
|
|
136
|
-
: defaultValue.y,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
|
|
141
|
-
|
|
142
|
-
const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
x: calculationWidth > minWidth ? calculationWidth : minWidth,
|
|
146
|
-
y:
|
|
147
|
-
calculationHeight > minimisedHeight
|
|
148
|
-
? calculationHeight
|
|
149
|
-
: minimisedHeight,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
case ComponentAnimationType.componentFade: {
|
|
154
|
-
if (fromMiniPlayer) {
|
|
155
|
-
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
156
|
-
|
|
157
|
-
return calculation < 1 ? calculation : 1;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
161
|
-
|
|
162
|
-
return calculation > 0 ? calculation : 0;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
case ComponentAnimationType.componentAppears: {
|
|
166
|
-
if (fromMiniPlayer) {
|
|
167
|
-
const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
|
|
168
|
-
|
|
169
|
-
return calculation > 0 ? calculation : 0;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const calculation = dragPosition / (isTablet ? 200 : 150);
|
|
173
|
-
|
|
174
|
-
return calculation < 1 ? calculation : 1;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
case ComponentAnimationType.moveUpComponent: {
|
|
178
|
-
if (fromMiniPlayer) {
|
|
179
|
-
const calculation =
|
|
180
|
-
moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
|
|
181
|
-
|
|
182
|
-
return calculation < 0 ? calculation : 0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
|
|
186
|
-
|
|
187
|
-
return calculation > moveUpValue ? calculation : moveUpValue;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
case ComponentAnimationType.moveComponentHorizontal: {
|
|
191
|
-
if (fromMiniPlayer) {
|
|
192
|
-
const calculation = isRTL
|
|
193
|
-
? moveComponentHorizontalValue - dragPosition * 2
|
|
194
|
-
: moveComponentHorizontalValue + dragPosition * 2;
|
|
195
|
-
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
196
|
-
|
|
197
|
-
return condition ? calculation : 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
|
|
201
|
-
const condition = isRTL
|
|
202
|
-
? calculation < moveComponentHorizontalValue
|
|
203
|
-
: calculation > moveComponentHorizontalValue;
|
|
204
|
-
|
|
205
|
-
return condition ? calculation : moveComponentHorizontalValue;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
case ComponentAnimationType.audioPlayerPaddingHorizontal: {
|
|
209
|
-
const padding = isRTL
|
|
210
|
-
? AUDIO_PLAYER_HORIZONTAL_PADDING
|
|
211
|
-
: -AUDIO_PLAYER_HORIZONTAL_PADDING;
|
|
212
|
-
|
|
213
|
-
if (fromMiniPlayer) {
|
|
214
|
-
const calculation = isRTL
|
|
215
|
-
? padding - dragPosition / 5
|
|
216
|
-
: padding + dragPosition / 5;
|
|
217
|
-
const condition = isRTL ? calculation > 0 : calculation < 0;
|
|
218
|
-
|
|
219
|
-
return condition ? calculation : 0;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
|
|
223
|
-
const condition = isRTL ? calculation < padding : calculation > padding;
|
|
224
|
-
|
|
225
|
-
return condition ? calculation : padding;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const gestureListenerHelper = (data) => {
|
|
231
|
-
const {
|
|
232
|
-
listenerValue,
|
|
233
|
-
preparedValue,
|
|
234
|
-
animationType,
|
|
235
|
-
animatedValue,
|
|
236
|
-
calculationData,
|
|
237
|
-
modalSnapPoint,
|
|
238
|
-
startComponentsAnimationDistance,
|
|
239
|
-
startComponentsAnimation,
|
|
240
|
-
setStartComponentsAnimation,
|
|
241
|
-
getAnimationValue,
|
|
242
|
-
} = data;
|
|
243
|
-
|
|
244
|
-
if (calculationData.fromMiniPlayer) {
|
|
245
|
-
if (listenerValue <= 0) {
|
|
246
|
-
if (
|
|
247
|
-
preparedValue >= 0 &&
|
|
248
|
-
preparedValue <= modalSnapPoint - startComponentsAnimationDistance
|
|
249
|
-
) {
|
|
250
|
-
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
251
|
-
|
|
252
|
-
animatedValue.setValue(
|
|
253
|
-
calculateAnimationValue(animationType, preparedValue, calculationData)
|
|
254
|
-
);
|
|
255
|
-
} else {
|
|
256
|
-
animatedValue.setValue(calculationData.defaultValue);
|
|
257
|
-
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
const value = getAnimationValue(
|
|
261
|
-
animationType,
|
|
262
|
-
PlayerAnimationStateEnum.minimize
|
|
263
|
-
).toValue;
|
|
264
|
-
|
|
265
|
-
animatedValue.setValue(value);
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
if (preparedValue >= startComponentsAnimationDistance) {
|
|
269
|
-
!startComponentsAnimation && setStartComponentsAnimation(true);
|
|
270
|
-
const value = Math.round(
|
|
271
|
-
preparedValue - startComponentsAnimationDistance
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
animatedValue.setValue(
|
|
275
|
-
calculateAnimationValue(animationType, value, calculationData)
|
|
276
|
-
);
|
|
277
|
-
} else {
|
|
278
|
-
animatedValue.setValue(calculationData.defaultValue);
|
|
279
|
-
startComponentsAnimation && setStartComponentsAnimation(false);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export const setScrollModalAnimatedValue = (
|
|
285
|
-
animatedValue,
|
|
286
|
-
value,
|
|
287
|
-
setLastSnap
|
|
288
|
-
) => {
|
|
289
|
-
setLastSnap(value);
|
|
290
|
-
animatedValue.setValue(value);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
export const resetScrollAnimatedValues = (
|
|
294
|
-
lastScrollY,
|
|
295
|
-
lastScrollYValue,
|
|
296
|
-
dragScrollY,
|
|
297
|
-
dragVideoPlayerY
|
|
298
|
-
) => {
|
|
299
|
-
lastScrollY.setValue(0);
|
|
300
|
-
lastScrollYValue.current = 0;
|
|
301
|
-
dragScrollY.setValue(0);
|
|
302
|
-
dragVideoPlayerY.setValue(0);
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export const getMoveUpValue = ({
|
|
306
|
-
additionalData,
|
|
307
|
-
insets,
|
|
308
|
-
isAudioItem,
|
|
309
|
-
progressBarHeight,
|
|
310
|
-
isTablet,
|
|
311
|
-
isTabletLandscape,
|
|
312
|
-
tabletLandscapePlayerTopPosition,
|
|
313
|
-
}) => {
|
|
314
|
-
if (additionalData.saveArea) {
|
|
315
|
-
return -insets.top + (isAudioItem ? 0 : progressBarHeight);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (isAudioItem) {
|
|
319
|
-
// for any layouts in audioPlayer
|
|
320
|
-
return -1 * toNumberWithDefaultZero(additionalData?.marginTop);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (isTablet) {
|
|
324
|
-
if (isTabletLandscape) {
|
|
325
|
-
return -tabletLandscapePlayerTopPosition + progressBarHeight;
|
|
326
|
-
} else {
|
|
327
|
-
return -130;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return -50 + progressBarHeight;
|
|
332
|
-
};
|
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { StyleSheet, View, ViewStyle } from "react-native";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from "react-native";
|
|
9
|
-
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
Edge,
|
|
5
|
+
SafeAreaView,
|
|
6
|
+
useSafeAreaInsets,
|
|
7
|
+
} from "react-native-safe-area-context";
|
|
10
8
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
11
9
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
10
|
import { playerDimensionsHack } from "./utils";
|
|
13
11
|
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type Configuration = {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
tablet_landscape_sidebar_width?: string;
|
|
26
|
-
tablet_landscape_player_container_background_color?: string;
|
|
27
|
-
};
|
|
12
|
+
import {
|
|
13
|
+
DimensionsT,
|
|
14
|
+
Configuration,
|
|
15
|
+
getEdges,
|
|
16
|
+
getBaseDimensions,
|
|
17
|
+
calculateAspectRatio,
|
|
18
|
+
getPlayerDimensions,
|
|
19
|
+
getContainerDimensions,
|
|
20
|
+
} from "./playerWrapperUtils";
|
|
28
21
|
|
|
29
22
|
type Props = {
|
|
30
23
|
entry: ZappEntry;
|
|
@@ -45,32 +38,12 @@ const defaultStyles = StyleSheet.create({
|
|
|
45
38
|
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
46
39
|
});
|
|
47
40
|
|
|
48
|
-
const getScreenAspectRatio = () => {
|
|
49
|
-
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
50
|
-
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
51
|
-
|
|
52
|
-
return longEdge / shortEdge;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
56
|
-
if (isTablet) {
|
|
57
|
-
return ["top"];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!isInlineModal && Platform.OS === "android") {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return ["top"];
|
|
65
|
-
};
|
|
66
|
-
|
|
67
41
|
const PlayerWrapperComponent = (props: Props) => {
|
|
68
42
|
const {
|
|
69
43
|
entry,
|
|
70
44
|
style,
|
|
71
45
|
containerStyle,
|
|
72
46
|
inline,
|
|
73
|
-
docked,
|
|
74
47
|
isModal,
|
|
75
48
|
isTabletPortrait,
|
|
76
49
|
configuration,
|
|
@@ -90,28 +63,27 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
90
63
|
);
|
|
91
64
|
|
|
92
65
|
const baseDimensions: DimensionsT = React.useMemo(
|
|
93
|
-
() => (
|
|
94
|
-
|
|
95
|
-
height: undefined,
|
|
96
|
-
}),
|
|
97
|
-
[isInlineModal, tabletWidth, docked]
|
|
66
|
+
() => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
|
|
67
|
+
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
98
68
|
);
|
|
99
69
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
[
|
|
70
|
+
const insets = useSafeAreaInsets();
|
|
71
|
+
|
|
72
|
+
const aspectRatio = React.useMemo(
|
|
73
|
+
() => calculateAspectRatio(isInlineModal, pip, insets),
|
|
74
|
+
// ignoring insets - only initial needed
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
[isInlineModal, pip]
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const playerDimensions = React.useMemo(
|
|
80
|
+
() => getPlayerDimensions(baseDimensions, aspectRatio),
|
|
81
|
+
[baseDimensions, aspectRatio]
|
|
107
82
|
);
|
|
108
83
|
|
|
109
84
|
const containerDimensions: DimensionsT = React.useMemo(
|
|
110
|
-
() => (
|
|
111
|
-
|
|
112
|
-
aspectRatio: playerDimensions.aspectRatio,
|
|
113
|
-
}),
|
|
114
|
-
[baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
|
|
85
|
+
() => getContainerDimensions(baseDimensions, playerDimensions.aspectRatio),
|
|
86
|
+
[baseDimensions, playerDimensions.aspectRatio]
|
|
115
87
|
);
|
|
116
88
|
|
|
117
89
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
@@ -121,7 +93,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
121
93
|
...playerDimensions,
|
|
122
94
|
...playerDimensionsHack,
|
|
123
95
|
}),
|
|
124
|
-
[
|
|
96
|
+
[playerDimensions]
|
|
125
97
|
);
|
|
126
98
|
|
|
127
99
|
return (
|
|
@@ -46,6 +46,7 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
|
46
46
|
|
|
47
47
|
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
48
48
|
isTV: jest.fn(() => false),
|
|
49
|
+
isAndroidPlatform: jest.fn(() => false),
|
|
49
50
|
isApplePlatform: jest.fn(() => true),
|
|
50
51
|
platformSelect: jest.fn((props) => props.android),
|
|
51
52
|
}));
|
|
@@ -42,7 +42,7 @@ export const useModalSize = (): Size => {
|
|
|
42
42
|
const [modalSize, setModalSize] = React.useState<Size>({
|
|
43
43
|
width: frame.width,
|
|
44
44
|
height: isOldAndroidDevice
|
|
45
|
-
? frame.height + StatusBar.currentHeight
|
|
45
|
+
? frame.height + (StatusBar.currentHeight ?? 0)
|
|
46
46
|
: frame.height,
|
|
47
47
|
});
|
|
48
48
|
|
|
@@ -57,9 +57,10 @@ export const useModalSize = (): Size => {
|
|
|
57
57
|
|
|
58
58
|
return {
|
|
59
59
|
width: newSize.width,
|
|
60
|
-
height:
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
height:
|
|
61
|
+
isOldAndroidDevice && newSize.height !== "100%"
|
|
62
|
+
? newSize.height + (StatusBar.currentHeight ?? 0)
|
|
63
|
+
: newSize.height,
|
|
63
64
|
};
|
|
64
65
|
});
|
|
65
66
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Dimensions, Platform } from "react-native";
|
|
2
|
+
import { Edge } from "react-native-safe-area-context";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isAndroidPlatform,
|
|
6
|
+
isAndroidVersionAtLeast,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
|
+
|
|
9
|
+
const MIN_SUPPORTED_ANDROID_API = 34;
|
|
10
|
+
|
|
11
|
+
export const isOldAndroidDevice =
|
|
12
|
+
isAndroidPlatform() && !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API);
|
|
13
|
+
|
|
14
|
+
export type DimensionsT = {
|
|
15
|
+
width: number | string;
|
|
16
|
+
height: number | string | undefined;
|
|
17
|
+
aspectRatio?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type Configuration = {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
tablet_landscape_sidebar_width?: string;
|
|
23
|
+
tablet_landscape_player_container_background_color?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getWindowDimensions = () => {
|
|
27
|
+
const { width, height } = Dimensions.get("window");
|
|
28
|
+
|
|
29
|
+
return { width, height };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const getMaxWindowDimension = () => {
|
|
33
|
+
const { width, height } = getWindowDimensions();
|
|
34
|
+
|
|
35
|
+
return Math.max(width, height);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getMinWindowDimension = () => {
|
|
39
|
+
const { width, height } = getWindowDimensions();
|
|
40
|
+
|
|
41
|
+
return Math.min(width, height);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const getScreenAspectRatio = (insets?: {
|
|
45
|
+
top: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
}) => {
|
|
48
|
+
const longEdge = getMaxWindowDimension();
|
|
49
|
+
const shortEdge = getMinWindowDimension();
|
|
50
|
+
|
|
51
|
+
// subtract insets to get correct aspect ratio on devices with notches
|
|
52
|
+
return longEdge / (shortEdge - ((insets?.top ?? 0) + (insets?.bottom ?? 0)));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const getEdges = (
|
|
56
|
+
isTablet: boolean,
|
|
57
|
+
isInlineModal: boolean
|
|
58
|
+
): readonly Edge[] => {
|
|
59
|
+
if (isTablet) {
|
|
60
|
+
return ["top"];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!isInlineModal && Platform.OS === "android") {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return ["top"];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const getBaseDimensions = (
|
|
71
|
+
isInlineModal: boolean,
|
|
72
|
+
isTabletLandscape: boolean,
|
|
73
|
+
tabletWidth: number | string
|
|
74
|
+
): DimensionsT => ({
|
|
75
|
+
width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
|
|
76
|
+
height: undefined,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const calculateAspectRatio = (
|
|
80
|
+
isInlineModal: boolean,
|
|
81
|
+
pip?: boolean,
|
|
82
|
+
insets?: { top: number; bottom: number }
|
|
83
|
+
): number => {
|
|
84
|
+
return !isInlineModal && !pip
|
|
85
|
+
? getScreenAspectRatio(isOldAndroidDevice ? insets : undefined)
|
|
86
|
+
: 16 / 9;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const getPlayerDimensions = (
|
|
90
|
+
baseDimensions: DimensionsT,
|
|
91
|
+
aspectRatio: number
|
|
92
|
+
): DimensionsT => ({
|
|
93
|
+
...baseDimensions,
|
|
94
|
+
width: baseDimensions.width,
|
|
95
|
+
aspectRatio,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const getContainerDimensions = (
|
|
99
|
+
baseDimensions: DimensionsT,
|
|
100
|
+
playerAspectRatio?: number
|
|
101
|
+
): DimensionsT => ({
|
|
102
|
+
...baseDimensions,
|
|
103
|
+
aspectRatio: playerAspectRatio,
|
|
104
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.4368022015",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.4368022015",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.4368022015",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.4368022015",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.4368022015",
|
|
35
35
|
"promise": "^8.3.0",
|
|
36
36
|
"url": "^0.11.0",
|
|
37
37
|
"uuid": "^3.3.2"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Animated, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
useModalAnimationContext,
|
|
6
|
-
PlayerAnimationStateEnum,
|
|
7
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
style: ViewStyle[];
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const AnimatedPlayerModalWrapper = (props: Props) => {
|
|
15
|
-
const {
|
|
16
|
-
playerAnimationState,
|
|
17
|
-
animatedValues: { lastScrollY, dragScrollY, translateYOffset },
|
|
18
|
-
modalSnapPoints,
|
|
19
|
-
setStartComponentsAnimation,
|
|
20
|
-
} = useModalAnimationContext();
|
|
21
|
-
|
|
22
|
-
const interpolateConfig: Animated.InterpolationConfigType = React.useMemo(
|
|
23
|
-
() => ({
|
|
24
|
-
inputRange: modalSnapPoints,
|
|
25
|
-
outputRange: modalSnapPoints,
|
|
26
|
-
extrapolate: "clamp",
|
|
27
|
-
}),
|
|
28
|
-
[modalSnapPoints]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
let translateY;
|
|
32
|
-
|
|
33
|
-
if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
|
|
34
|
-
translateY = translateYOffset.interpolate(interpolateConfig);
|
|
35
|
-
} else {
|
|
36
|
-
const reverseLastScrollY = Animated.multiply(
|
|
37
|
-
new Animated.Value(-1),
|
|
38
|
-
lastScrollY
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
translateY = Animated.add(
|
|
42
|
-
translateYOffset,
|
|
43
|
-
Animated.add(dragScrollY, reverseLastScrollY)
|
|
44
|
-
).interpolate(interpolateConfig);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
React.useEffect(() => {
|
|
48
|
-
(playerAnimationState === PlayerAnimationStateEnum.minimize ||
|
|
49
|
-
playerAnimationState === PlayerAnimationStateEnum.maximize) &&
|
|
50
|
-
setStartComponentsAnimation(true);
|
|
51
|
-
}, [playerAnimationState]);
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<Animated.View
|
|
55
|
-
style={[props.style, { transform: [{ translateY: translateY }] }]}
|
|
56
|
-
>
|
|
57
|
-
{props.children}
|
|
58
|
-
</Animated.View>
|
|
59
|
-
);
|
|
60
|
-
};
|