@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5882013252 → 12.0.0-alpha.5895113034
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 +18 -10
- package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/Cell/Cell.tsx +2 -2
- package/Components/Cell/CellWithFocusable.tsx +21 -14
- package/Components/Cell/TvOSCellComponent.tsx +2 -2
- package/Components/ErrorScreen/index.tsx +1 -1
- package/Components/FocusableCell/index.tsx +7 -7
- package/Components/FocusableList/FocusableChild.ts +24 -14
- package/Components/FocusableList/FocusableItem.tsx +1 -1
- package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
- package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
- package/Components/FocusableList/index.tsx +26 -25
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +1 -1
- package/Components/HookRenderer/index.tsx +1 -6
- package/Components/Image/Image.android.tsx +3 -22
- package/Components/Image/Image.tsx +18 -2
- package/Components/Image/utils/index.ts +39 -0
- package/Components/Layout/TV/__tests__/index.test.tsx +1 -34
- package/Components/Layout/TV/index.tsx +28 -41
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -110
- package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
- 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 +6 -10
- 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/ModalComponent/BottomSheetModalContent.tsx +121 -0
- package/Components/ModalComponent/Button/Item.tsx +82 -0
- package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
- package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
- package/Components/ModalComponent/Button/assets.ts +4 -0
- package/Components/ModalComponent/Button/index.tsx +111 -0
- package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
- package/Components/ModalComponent/Header/Title.tsx +70 -0
- package/Components/ModalComponent/Header/assets.ts +4 -0
- package/Components/ModalComponent/Header/index.tsx +71 -0
- package/Components/ModalComponent/Header/utils.ts +79 -0
- package/Components/ModalComponent/index.tsx +38 -0
- package/Components/ModalComponent/utils.ts +126 -0
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
- package/Components/PlayerContainer/PlayerContainer.tsx +61 -30
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
- package/Components/PlayerImageBackground/index.tsx +34 -8
- package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/River.tsx +8 -5
- package/Components/River/TV/River.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
- package/Components/River/__tests__/componentsMap.test.js +7 -0
- package/Components/River/useScreenConfiguration.ts +5 -6
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
- package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
- package/Components/RouteManager/index.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +48 -36
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
- package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
- package/Components/Screen/index.tsx +103 -44
- package/Components/Screen/navigationHandler.ts +0 -82
- package/Components/Screen/orientationHandler.ts +1 -1
- package/Components/ScreenResolver/index.tsx +1 -1
- package/Components/Tabs/TV/styles.ts +1 -1
- package/Components/TrackedView/index.tsx +6 -3
- 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 +45 -13
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
- 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 +6 -3
- package/Components/VideoModal/PlayerWrapper.tsx +134 -103
- package/Components/VideoModal/VideoModal.tsx +25 -42
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +15 -3
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +242 -166
- package/Components/VideoModal/hooks/useModalSize.ts +13 -4
- package/Components/VideoModal/utils.ts +3 -3
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
- package/Components/Viewport/ViewportTracker/index.tsx +1 -0
- package/Components/Viewport/utils.js +1 -1
- package/Components/ZappUIComponent/index.tsx +22 -12
- package/Components/index.js +2 -0
- 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 +95 -29
- package/Contexts/ScreenDataContext/index.ts +3 -0
- package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
- package/Decorators/RiverResolver/index.tsx +0 -4
- package/Decorators/index.tsx +0 -4
- package/events/index.ts +1 -0
- package/package.json +5 -6
- package/Components/VideoModal/hooks/usePosition.ts +0 -50
- /package/Contexts/{index.js → index.ts} +0 -0
|
@@ -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
|
+
};
|
|
@@ -23,6 +23,8 @@ const containerStyle = ({
|
|
|
23
23
|
backgroundColor: modal_background_color,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
// const audioMarginStyle = { marginTop: 0, marginBottom: 0 };
|
|
27
|
+
|
|
26
28
|
export const PlayerDetails = ({
|
|
27
29
|
entry,
|
|
28
30
|
style,
|
|
@@ -40,12 +42,12 @@ export const PlayerDetails = ({
|
|
|
40
42
|
: {};
|
|
41
43
|
|
|
42
44
|
// Animation setup
|
|
43
|
-
const translateY = useRef(new Animated.Value(
|
|
45
|
+
const translateY = useRef(new Animated.Value(50)).current;
|
|
44
46
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
45
47
|
|
|
46
48
|
const runAnimation = () => {
|
|
47
49
|
Animated.timing(translateY, {
|
|
48
|
-
toValue:
|
|
50
|
+
toValue: -30,
|
|
49
51
|
duration: 500,
|
|
50
52
|
easing: Easing.inOut(Easing.ease),
|
|
51
53
|
useNativeDriver: true,
|
|
@@ -61,7 +63,7 @@ export const PlayerDetails = ({
|
|
|
61
63
|
|
|
62
64
|
useEffect(() => {
|
|
63
65
|
if (isAudioPlayer) {
|
|
64
|
-
setTimeout(() => runAnimation(),
|
|
66
|
+
setTimeout(() => runAnimation(), 1500);
|
|
65
67
|
}
|
|
66
68
|
}, [isAudioPlayer]);
|
|
67
69
|
|
|
@@ -75,6 +77,7 @@ export const PlayerDetails = ({
|
|
|
75
77
|
transform: [{ translateY }],
|
|
76
78
|
opacity,
|
|
77
79
|
},
|
|
80
|
+
// isAudioPlayer && audioMarginStyle,
|
|
78
81
|
]}
|
|
79
82
|
>
|
|
80
83
|
{screenData && (
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Platform,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
3
9
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
4
10
|
|
|
5
11
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
|
-
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks
|
|
12
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
7
13
|
import { PlayerDetails } from "./PlayerDetails";
|
|
8
14
|
import { playerDimesionsHack } from "./utils";
|
|
9
15
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
10
|
-
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
11
16
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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";
|
|
25
|
+
|
|
26
|
+
type DimensionsT = {
|
|
27
|
+
width: number | string;
|
|
28
|
+
height: number | string | undefined;
|
|
29
|
+
aspectRatio?: number;
|
|
16
30
|
};
|
|
17
31
|
|
|
18
32
|
type Configuration = {
|
|
@@ -23,25 +37,22 @@ type Configuration = {
|
|
|
23
37
|
|
|
24
38
|
type Props = {
|
|
25
39
|
entry: ZappEntry;
|
|
26
|
-
style: ViewStyle &
|
|
40
|
+
style: ViewStyle & DimensionsT;
|
|
27
41
|
containerStyle?: ViewStyle;
|
|
28
42
|
inline?: boolean;
|
|
29
43
|
docked?: boolean;
|
|
44
|
+
pip?: boolean;
|
|
30
45
|
isModal?: boolean;
|
|
31
46
|
fullscreen?: boolean;
|
|
32
47
|
isTabletPortrait?: boolean;
|
|
33
|
-
children: (playerDimensions:
|
|
48
|
+
children: (playerDimensions: DimensionsT) => React.ReactNode;
|
|
34
49
|
configuration: Configuration;
|
|
35
50
|
};
|
|
36
51
|
|
|
37
52
|
const defaultStyles = StyleSheet.create({
|
|
38
53
|
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
39
54
|
playerDetails: { flex: 1, paddingTop: 20 },
|
|
40
|
-
|
|
41
|
-
aspectRatio: 16 / 9,
|
|
42
|
-
width: "100%",
|
|
43
|
-
height: undefined,
|
|
44
|
-
},
|
|
55
|
+
flex: { flex: 1 },
|
|
45
56
|
});
|
|
46
57
|
|
|
47
58
|
const orientationStyles = StyleSheet.create({
|
|
@@ -57,6 +68,15 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
|
|
|
57
68
|
return orientationStyles.portrait;
|
|
58
69
|
};
|
|
59
70
|
|
|
71
|
+
const getScreenAspectRatio = () => {
|
|
72
|
+
const { width, height } = Dimensions.get("screen");
|
|
73
|
+
|
|
74
|
+
const longEdge = Math.max(width, height);
|
|
75
|
+
const shortEdge = Math.min(width, height);
|
|
76
|
+
|
|
77
|
+
return longEdge / shortEdge;
|
|
78
|
+
};
|
|
79
|
+
|
|
60
80
|
const safeAreaStyles = (
|
|
61
81
|
configuration: Configuration,
|
|
62
82
|
isTablet: boolean
|
|
@@ -71,9 +91,21 @@ const safeAreaStyles = (
|
|
|
71
91
|
};
|
|
72
92
|
};
|
|
73
93
|
|
|
94
|
+
const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
95
|
+
if (isTablet) {
|
|
96
|
+
return ["top"];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!isInlineModal && Platform.OS === "android") {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return ["top"];
|
|
104
|
+
};
|
|
105
|
+
|
|
74
106
|
const getTabletWidth = (
|
|
75
107
|
configuration: Configuration,
|
|
76
|
-
dimensions:
|
|
108
|
+
dimensions: DimensionsT
|
|
77
109
|
) => {
|
|
78
110
|
const tablet_landscape_sidebar_width =
|
|
79
111
|
configuration?.tablet_landscape_sidebar_width;
|
|
@@ -83,41 +115,14 @@ const getTabletWidth = (
|
|
|
83
115
|
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
84
116
|
|
|
85
117
|
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
86
|
-
return width * (1 - sidebarWidth / 100);
|
|
118
|
+
return Number(width) * (1 - sidebarWidth / 100);
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
if (Number.isNaN(sidebarWidth)) {
|
|
90
|
-
return width * 0.65;
|
|
122
|
+
return Number(width) * 0.65;
|
|
91
123
|
}
|
|
92
124
|
|
|
93
|
-
return width - sidebarWidth;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const defaultAspectRatioHeight = (width: number): number =>
|
|
97
|
-
(width / 16) * 9;
|
|
98
|
-
|
|
99
|
-
export const defaultAspectRatioWidth = (height: number): number =>
|
|
100
|
-
(height / 9) * 16;
|
|
101
|
-
|
|
102
|
-
const getEdges = (
|
|
103
|
-
isTablet: boolean,
|
|
104
|
-
docked: boolean,
|
|
105
|
-
isInlineModal: boolean
|
|
106
|
-
) => {
|
|
107
|
-
if (isTablet) {
|
|
108
|
-
return docked ? ["right", "left"] : ["top"];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// mobile
|
|
112
|
-
if (isInlineModal && docked) {
|
|
113
|
-
return ["bottom"];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (!isInlineModal && Platform.OS === "android") {
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return ["top"];
|
|
125
|
+
return Number(width) - sidebarWidth;
|
|
121
126
|
};
|
|
122
127
|
|
|
123
128
|
export const PlayerWrapper = (props: Props) => {
|
|
@@ -131,6 +136,7 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
131
136
|
children,
|
|
132
137
|
isTabletPortrait,
|
|
133
138
|
configuration,
|
|
139
|
+
pip,
|
|
134
140
|
} = props;
|
|
135
141
|
|
|
136
142
|
const isTablet = useIsTablet();
|
|
@@ -141,80 +147,105 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
141
147
|
|
|
142
148
|
const tabletWidth = getTabletWidth(configuration, style);
|
|
143
149
|
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
const containerDimensions: Dimensions = React.useMemo(
|
|
150
|
+
const baseDimensions: DimensionsT = React.useMemo(
|
|
147
151
|
() => ({
|
|
148
152
|
width:
|
|
149
|
-
isInlineModal && !docked && isTabletLandscape
|
|
150
|
-
|
|
151
|
-
: style.width,
|
|
152
|
-
height:
|
|
153
|
-
isInlineModal && !docked
|
|
154
|
-
? defaultAspectRatioHeight(
|
|
155
|
-
isTabletLandscape ? tabletWidth : screenWidth
|
|
156
|
-
)
|
|
157
|
-
: style.height,
|
|
153
|
+
isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
|
|
154
|
+
height: undefined,
|
|
158
155
|
}),
|
|
159
|
-
[isInlineModal,
|
|
156
|
+
[isInlineModal, tabletWidth, docked]
|
|
160
157
|
);
|
|
161
158
|
|
|
162
|
-
const playerDimensions:
|
|
159
|
+
const playerDimensions: DimensionsT = React.useMemo(
|
|
163
160
|
() => ({
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
: containerDimensions.width,
|
|
168
|
-
height: containerDimensions.height,
|
|
161
|
+
...baseDimensions,
|
|
162
|
+
width: isInlineModal && docked ? undefined : baseDimensions.width,
|
|
163
|
+
aspectRatio: !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9,
|
|
169
164
|
}),
|
|
170
|
-
[
|
|
165
|
+
[baseDimensions, isInlineModal, pip]
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const containerDimensions: DimensionsT = React.useMemo(
|
|
169
|
+
() => ({
|
|
170
|
+
...baseDimensions,
|
|
171
|
+
aspectRatio:
|
|
172
|
+
isInlineModal && docked ? undefined : playerDimensions.aspectRatio,
|
|
173
|
+
}),
|
|
174
|
+
[baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
|
|
171
175
|
);
|
|
172
176
|
|
|
173
177
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
174
178
|
|
|
175
179
|
const childrenStyles = React.useMemo(
|
|
176
180
|
() => ({ ...playerDimensions, ...playerDimesionsHack }),
|
|
177
|
-
[
|
|
181
|
+
[containerDimensions, playerDimesionsHack]
|
|
178
182
|
);
|
|
179
183
|
|
|
184
|
+
const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
|
|
185
|
+
|
|
180
186
|
return (
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
style={
|
|
195
|
-
defaultStyles.playerContainer,
|
|
196
|
-
containerDimensions,
|
|
197
|
-
containerStyle,
|
|
198
|
-
isInlineModal && !docked && !isTabletLandscape
|
|
199
|
-
? defaultStyles.inlinePlayerContainerDimensions
|
|
200
|
-
: {},
|
|
201
|
-
playerDimesionsHack,
|
|
202
|
-
]}
|
|
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)}
|
|
203
201
|
>
|
|
204
|
-
{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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>
|
|
219
250
|
);
|
|
220
251
|
};
|