@applicaster/zapp-react-native-ui-components 15.0.0-rc.4 → 15.0.0-rc.41
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/Cell/Cell.tsx +8 -3
- package/Components/Cell/FocusableWrapper.tsx +44 -0
- package/Components/Cell/TvOSCellComponent.tsx +92 -17
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -65
- package/Components/HandlePlayable/const.ts +3 -0
- package/Components/HandlePlayable/utils.ts +74 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +36 -2
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +1 -16
- package/Components/PlayerImageBackground/index.tsx +3 -22
- package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +22 -5
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/ScreenRevealManager/utils/index.ts +23 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
- package/Components/Tabs/TV/Tabs.tsx +20 -3
- package/Components/Transitioner/Scene.tsx +15 -2
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +114 -171
- package/Components/VideoModal/ModalAnimation/index.ts +2 -13
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
- package/Components/VideoModal/PlayerWrapper.tsx +14 -88
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/hooks/useModalSize.ts +10 -5
- package/Components/VideoModal/playerWrapperStyle.ts +70 -0
- package/Components/VideoModal/playerWrapperUtils.ts +91 -0
- package/Components/VideoModal/utils.ts +7 -0
- package/index.d.ts +7 -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,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Dimensions,
|
|
4
|
-
Platform,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
View,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from "react-native";
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
9
3
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
10
4
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
11
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
6
|
import { playerDimensionsHack } from "./utils";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
16
|
-
|
|
17
|
-
type DimensionsT = {
|
|
18
|
-
width: number | string;
|
|
19
|
-
height: number | string | undefined;
|
|
20
|
-
aspectRatio?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type Configuration = {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
tablet_landscape_sidebar_width?: string;
|
|
26
|
-
tablet_landscape_player_container_background_color?: string;
|
|
27
|
-
};
|
|
7
|
+
import { DimensionsT, Configuration, getEdges } from "./playerWrapperUtils";
|
|
8
|
+
import { defaultStyles, useStyle } from "./playerWrapperStyle";
|
|
28
9
|
|
|
29
10
|
type Props = {
|
|
30
11
|
entry: ZappEntry;
|
|
@@ -41,36 +22,12 @@ type Props = {
|
|
|
41
22
|
playerContent: (styles: ViewStyle) => React.ReactNode;
|
|
42
23
|
};
|
|
43
24
|
|
|
44
|
-
const defaultStyles = StyleSheet.create({
|
|
45
|
-
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
46
|
-
});
|
|
47
|
-
|
|
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
25
|
const PlayerWrapperComponent = (props: Props) => {
|
|
68
26
|
const {
|
|
69
27
|
entry,
|
|
70
28
|
style,
|
|
71
29
|
containerStyle,
|
|
72
30
|
inline,
|
|
73
|
-
docked,
|
|
74
31
|
isModal,
|
|
75
32
|
isTabletPortrait,
|
|
76
33
|
configuration,
|
|
@@ -78,52 +35,21 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
78
35
|
playerContent,
|
|
79
36
|
} = props;
|
|
80
37
|
|
|
38
|
+
const styles = useStyle({
|
|
39
|
+
style,
|
|
40
|
+
inline,
|
|
41
|
+
isModal,
|
|
42
|
+
isTabletPortrait,
|
|
43
|
+
configuration,
|
|
44
|
+
pip,
|
|
45
|
+
});
|
|
46
|
+
|
|
81
47
|
const isTablet = useIsTablet();
|
|
82
48
|
|
|
83
49
|
const isInlineModal = inline && isModal;
|
|
84
50
|
|
|
85
|
-
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
86
|
-
|
|
87
|
-
const tabletWidth = getTabletWidth(
|
|
88
|
-
configuration.tablet_landscape_sidebar_width,
|
|
89
|
-
style
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const baseDimensions: DimensionsT = React.useMemo(
|
|
93
|
-
() => ({
|
|
94
|
-
width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
|
|
95
|
-
height: undefined,
|
|
96
|
-
}),
|
|
97
|
-
[isInlineModal, tabletWidth, docked]
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const playerDimensions: DimensionsT = React.useMemo(
|
|
101
|
-
() => ({
|
|
102
|
-
...baseDimensions,
|
|
103
|
-
width: baseDimensions.width,
|
|
104
|
-
aspectRatio: !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9,
|
|
105
|
-
}),
|
|
106
|
-
[baseDimensions, isInlineModal, pip]
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const containerDimensions: DimensionsT = React.useMemo(
|
|
110
|
-
() => ({
|
|
111
|
-
...baseDimensions,
|
|
112
|
-
aspectRatio: playerDimensions.aspectRatio,
|
|
113
|
-
}),
|
|
114
|
-
[baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
|
|
115
|
-
);
|
|
116
|
-
|
|
117
51
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
118
52
|
|
|
119
|
-
const childrenStyles = React.useMemo(
|
|
120
|
-
() => ({
|
|
121
|
-
...playerDimensions,
|
|
122
|
-
...playerDimensionsHack,
|
|
123
|
-
}),
|
|
124
|
-
[containerDimensions, playerDimensionsHack]
|
|
125
|
-
);
|
|
126
|
-
|
|
127
53
|
return (
|
|
128
54
|
<WrapperView
|
|
129
55
|
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
@@ -134,11 +60,11 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
134
60
|
style={[
|
|
135
61
|
defaultStyles.playerContainer,
|
|
136
62
|
playerDimensionsHack,
|
|
137
|
-
containerDimensions,
|
|
63
|
+
styles.containerDimensions,
|
|
138
64
|
containerStyle,
|
|
139
65
|
]}
|
|
140
66
|
>
|
|
141
|
-
{playerContent(childrenStyles)}
|
|
67
|
+
{playerContent(styles.childrenStyles)}
|
|
142
68
|
</View>
|
|
143
69
|
</WrapperView>
|
|
144
70
|
);
|
|
@@ -139,11 +139,7 @@ const VideoModalComponent = () => {
|
|
|
139
139
|
|
|
140
140
|
{itemIdHooksFinished === item?.id ? (
|
|
141
141
|
<View pointerEvents="box-none" style={styles.container}>
|
|
142
|
-
<HandlePlayable
|
|
143
|
-
item={item}
|
|
144
|
-
isModal={mode !== "PIP"}
|
|
145
|
-
mode={mode}
|
|
146
|
-
/>
|
|
142
|
+
<HandlePlayable item={item} isModal mode={mode} />
|
|
147
143
|
</View>
|
|
148
144
|
) : (
|
|
149
145
|
<View style={styles.loaderContainer}>
|
|
@@ -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
|
}));
|
|
@@ -33,8 +33,12 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
|
|
|
33
33
|
height: "100%",
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
37
|
+
|
|
36
38
|
const isOldAndroidDevice =
|
|
37
|
-
isAndroidPlatform() &&
|
|
39
|
+
isAndroidPlatform() &&
|
|
40
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION) &&
|
|
41
|
+
!isAndroidTablet();
|
|
38
42
|
|
|
39
43
|
export const useModalSize = (): Size => {
|
|
40
44
|
const frame = useSafeAreaFrame();
|
|
@@ -42,7 +46,7 @@ export const useModalSize = (): Size => {
|
|
|
42
46
|
const [modalSize, setModalSize] = React.useState<Size>({
|
|
43
47
|
width: frame.width,
|
|
44
48
|
height: isOldAndroidDevice
|
|
45
|
-
? frame.height + StatusBar.currentHeight
|
|
49
|
+
? frame.height + (StatusBar.currentHeight ?? 0)
|
|
46
50
|
: frame.height,
|
|
47
51
|
});
|
|
48
52
|
|
|
@@ -57,9 +61,10 @@ export const useModalSize = (): Size => {
|
|
|
57
61
|
|
|
58
62
|
return {
|
|
59
63
|
width: newSize.width,
|
|
60
|
-
height:
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
height:
|
|
65
|
+
isOldAndroidDevice && newSize.height !== "100%"
|
|
66
|
+
? newSize.height + (StatusBar.currentHeight ?? 0)
|
|
67
|
+
: newSize.height,
|
|
63
68
|
};
|
|
64
69
|
});
|
|
65
70
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
+
import { playerDimensionsHack } from "./utils";
|
|
6
|
+
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
7
|
+
import {
|
|
8
|
+
getBaseDimensions,
|
|
9
|
+
calculateAspectRatio,
|
|
10
|
+
getPlayerDimensions,
|
|
11
|
+
getContainerDimensions,
|
|
12
|
+
} from "./playerWrapperUtils";
|
|
13
|
+
|
|
14
|
+
export const defaultStyles = StyleSheet.create({
|
|
15
|
+
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const useStyle = ({
|
|
19
|
+
style,
|
|
20
|
+
inline,
|
|
21
|
+
isModal,
|
|
22
|
+
isTabletPortrait,
|
|
23
|
+
configuration,
|
|
24
|
+
pip,
|
|
25
|
+
}) => {
|
|
26
|
+
const isTablet = useIsTablet();
|
|
27
|
+
|
|
28
|
+
const isInlineModal = inline && isModal;
|
|
29
|
+
|
|
30
|
+
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
31
|
+
|
|
32
|
+
const tabletWidth = getTabletWidth(
|
|
33
|
+
configuration.tablet_landscape_sidebar_width,
|
|
34
|
+
style
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const baseDimensions: ViewStyle = React.useMemo(
|
|
38
|
+
() => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
|
|
39
|
+
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const aspectRatio = React.useMemo(
|
|
43
|
+
() => calculateAspectRatio(isInlineModal, pip),
|
|
44
|
+
// ignoring insets - only initial needed
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
[isInlineModal, pip]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return React.useMemo(() => {
|
|
50
|
+
const playerDimensions: ViewStyle = getPlayerDimensions(
|
|
51
|
+
baseDimensions,
|
|
52
|
+
aspectRatio
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const containerDimensions: ViewStyle = getContainerDimensions(
|
|
56
|
+
baseDimensions,
|
|
57
|
+
aspectRatio
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const childrenStyles = {
|
|
61
|
+
...playerDimensions,
|
|
62
|
+
...playerDimensionsHack,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return StyleSheet.create({
|
|
66
|
+
containerDimensions,
|
|
67
|
+
childrenStyles,
|
|
68
|
+
});
|
|
69
|
+
}, [baseDimensions, aspectRatio]);
|
|
70
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
|
|
2
|
+
import { Edge } from "react-native-safe-area-context";
|
|
3
|
+
|
|
4
|
+
export type DimensionsT = {
|
|
5
|
+
width: number | string;
|
|
6
|
+
height: number | string | undefined;
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type Configuration = {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
tablet_landscape_sidebar_width?: string;
|
|
13
|
+
tablet_landscape_player_container_background_color?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// This is safe, remembering screen dimensions once as they do not change during runtime
|
|
17
|
+
// TODO: consider sharing screen orientation as a shared function for the app
|
|
18
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
19
|
+
|
|
20
|
+
export const getWindowDimensions = () => {
|
|
21
|
+
const { width, height } = Dimensions.get("window");
|
|
22
|
+
|
|
23
|
+
return { width, height };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getMaxWindowDimension = () => {
|
|
27
|
+
const { width, height } = getWindowDimensions();
|
|
28
|
+
|
|
29
|
+
return Math.max(width, height);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const getMinWindowDimension = () => {
|
|
33
|
+
const { width, height } = getWindowDimensions();
|
|
34
|
+
|
|
35
|
+
return Math.min(width, height);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getScreenAspectRatio = () => {
|
|
39
|
+
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
40
|
+
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
41
|
+
|
|
42
|
+
return longEdge / shortEdge;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const getEdges = (
|
|
46
|
+
isTablet: boolean,
|
|
47
|
+
isInlineModal: boolean
|
|
48
|
+
): readonly Edge[] => {
|
|
49
|
+
if (isTablet) {
|
|
50
|
+
return ["top"];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!isInlineModal && Platform.OS === "android") {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return ["top"];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getBaseDimensions = (
|
|
61
|
+
isInlineModal: boolean,
|
|
62
|
+
isTabletLandscape: boolean,
|
|
63
|
+
tabletWidth: DimensionValue
|
|
64
|
+
): ViewStyle => ({
|
|
65
|
+
width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
|
|
66
|
+
height: undefined,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const calculateAspectRatio = (
|
|
70
|
+
isInlineModal: boolean,
|
|
71
|
+
pip?: boolean
|
|
72
|
+
): number => {
|
|
73
|
+
return !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const getPlayerDimensions = (
|
|
77
|
+
baseDimensions: ViewStyle,
|
|
78
|
+
aspectRatio: number
|
|
79
|
+
): ViewStyle => ({
|
|
80
|
+
...(baseDimensions as any),
|
|
81
|
+
width: baseDimensions.width,
|
|
82
|
+
aspectRatio,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const getContainerDimensions = (
|
|
86
|
+
baseDimensions: ViewStyle,
|
|
87
|
+
aspectRatio?: string | number
|
|
88
|
+
): ViewStyle => ({
|
|
89
|
+
...baseDimensions,
|
|
90
|
+
aspectRatio,
|
|
91
|
+
});
|