@applicaster/zapp-react-native-ui-components 12.0.0-rc.13 → 12.0.0-rc.130

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.
Files changed (171) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  3. package/Components/AudioPlayer/helpers.tsx +1 -0
  4. package/Components/BaseFocusable/index.tsx +3 -3
  5. package/Components/Cell/Cell.tsx +32 -11
  6. package/Components/Cell/CellWithFocusable.tsx +40 -19
  7. package/Components/Cell/TvOSCellComponent.tsx +5 -9
  8. package/Components/ErrorScreen/index.tsx +1 -1
  9. package/Components/Focusable/Focusable.tsx +6 -1
  10. package/Components/Focusable/__tests__/index.android.test.tsx +72 -0
  11. package/Components/Focusable/index.android.tsx +15 -9
  12. package/Components/FocusableCell/index.tsx +7 -7
  13. package/Components/FocusableGroup/index.tsx +11 -2
  14. package/Components/FocusableList/FocusableChild.ts +26 -18
  15. package/Components/FocusableList/FocusableItem.tsx +1 -1
  16. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  17. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  18. package/Components/FocusableList/index.tsx +37 -37
  19. package/Components/FocusableScrollView/index.tsx +1 -1
  20. package/Components/FreezeWithCallback/Freeze.tsx +31 -0
  21. package/Components/FreezeWithCallback/LICENSE +21 -0
  22. package/Components/FreezeWithCallback/Suspender.tsx +17 -0
  23. package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
  24. package/Components/FreezeWithCallback/index.tsx +3 -0
  25. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  26. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  27. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  28. package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
  29. package/Components/HookRenderer/index.tsx +1 -6
  30. package/Components/Image/Image.android.tsx +3 -25
  31. package/Components/Image/Image.tsx +18 -2
  32. package/Components/Image/utils/index.ts +39 -0
  33. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  34. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  35. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  36. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  37. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  38. package/Components/Layout/TV/__tests__/index.test.tsx +20 -108
  39. package/Components/Layout/TV/index.tsx +15 -84
  40. package/Components/Layout/TV/index.web.tsx +33 -0
  41. package/Components/Layout/index.tsx +15 -11
  42. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
  43. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -117
  44. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  45. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  46. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +16 -1
  47. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  48. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +3 -0
  49. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +2 -2
  50. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  51. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
  52. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  53. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +37 -2
  54. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  55. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  56. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  57. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  58. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  59. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  60. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
  61. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  62. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
  63. package/Components/MasterCell/dataAdapter.ts +21 -7
  64. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  65. package/Components/MasterCell/index.tsx +5 -3
  66. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  67. package/Components/MasterCell/utils/index.ts +33 -35
  68. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  69. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  70. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  71. package/Components/ModalComponent/Button/Item.tsx +82 -0
  72. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  73. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  74. package/Components/ModalComponent/Button/assets.ts +4 -0
  75. package/Components/ModalComponent/Button/index.tsx +111 -0
  76. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  77. package/Components/ModalComponent/Header/Title.tsx +70 -0
  78. package/Components/ModalComponent/Header/assets.ts +4 -0
  79. package/Components/ModalComponent/Header/index.tsx +71 -0
  80. package/Components/ModalComponent/Header/utils.ts +79 -0
  81. package/Components/ModalComponent/index.tsx +38 -0
  82. package/Components/ModalComponent/utils.ts +126 -0
  83. package/Components/Navigator/StackNavigator.tsx +57 -0
  84. package/Components/Navigator/index.ts +1 -0
  85. package/Components/PlayerContainer/PlayerContainer.tsx +73 -34
  86. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  87. package/Components/PlayerImageBackground/index.tsx +34 -8
  88. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  89. package/Components/River/RefreshControl.tsx +55 -1
  90. package/Components/River/TV/River.tsx +2 -25
  91. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  92. package/Components/River/__tests__/componentsMap.test.js +7 -0
  93. package/Components/River/useScreenConfiguration.ts +2 -2
  94. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  95. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  96. package/Components/RouteManager/index.tsx +4 -2
  97. package/Components/Screen/TV/hooks/index.ts +1 -0
  98. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  99. package/Components/Screen/TV/index.web.tsx +178 -0
  100. package/Components/Screen/__tests__/Screen.test.tsx +43 -75
  101. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  102. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  103. package/Components/Screen/index.tsx +104 -65
  104. package/Components/Screen/navigationHandler.ts +6 -85
  105. package/Components/Screen/orientationHandler.ts +18 -7
  106. package/Components/Screen/utils.ts +16 -0
  107. package/Components/ScreenResolver/index.tsx +10 -13
  108. package/Components/Tabs/TV/styles.ts +1 -1
  109. package/Components/TrackedView/index.tsx +6 -3
  110. package/Components/Transitioner/Scene.tsx +39 -26
  111. package/Components/Transitioner/Transitioner.tsx +56 -48
  112. package/Components/Transitioner/__tests__/Scene.test.js +7 -0
  113. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
  114. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -0
  115. package/Components/VideoLive/LiveImageManager.ts +70 -14
  116. package/Components/VideoLive/PlayerLiveImageComponent.tsx +132 -95
  117. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  118. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +24 -27
  119. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +66 -0
  120. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +377 -0
  121. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +165 -0
  122. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +481 -0
  123. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +182 -0
  124. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  125. package/Components/VideoModal/ModalAnimation/utils.ts +302 -0
  126. package/Components/VideoModal/PlayerDetails.tsx +21 -4
  127. package/Components/VideoModal/PlayerWrapper.tsx +115 -55
  128. package/Components/VideoModal/VideoModal.tsx +32 -43
  129. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +6 -1
  130. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
  131. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
  132. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +358 -166
  133. package/Components/VideoModal/hooks/useModalSize.ts +10 -12
  134. package/Components/VideoModal/utils.ts +8 -5
  135. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  136. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  137. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  138. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  139. package/Components/Viewport/utils.js +1 -1
  140. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +7 -3
  141. package/Components/ZappFrameworkComponents/BarView/Buttons/BackButton.tsx +7 -2
  142. package/Components/ZappFrameworkComponents/BarView/Buttons/CloseButton.tsx +7 -2
  143. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +87 -0
  144. package/Components/ZappFrameworkComponents/Buttons/ActionButton.tsx +9 -4
  145. package/Components/ZappUIComponent/index.tsx +22 -12
  146. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
  147. package/Components/index.js +2 -0
  148. package/Contexts/CachedDimensionsContext/index.ts +13 -9
  149. package/Contexts/ConfirmDialogState/index.ts +1 -1
  150. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  151. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  152. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  153. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  154. package/Contexts/FocusableGroupContext/index.ts +7 -0
  155. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  156. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  157. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  158. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  159. package/Contexts/ScreenContext/index.tsx +101 -30
  160. package/Contexts/ScreenDataContext/index.tsx +20 -0
  161. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  162. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  163. package/const.ts +6 -0
  164. package/events/index.ts +1 -0
  165. package/index.js +3 -0
  166. package/package.json +5 -5
  167. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  168. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  169. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  170. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
  171. /package/Contexts/{index.js → index.ts} +0 -0
@@ -0,0 +1,302 @@
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
+ export const PROGRESS_BAR_HEIGHT = 3;
17
+
18
+ export const defaultAspectRatioWidth = (height: number): number =>
19
+ (height / 9) * 16;
20
+
21
+ export const getAnimationStyle = (component, animatedValue) => {
22
+ switch (component) {
23
+ case ComponentAnimationType.bottomBar: {
24
+ return { zIndex: 99, transform: [{ translateY: animatedValue }] };
25
+ }
26
+
27
+ case ComponentAnimationType.player: {
28
+ return { width: animatedValue.x, height: animatedValue.y };
29
+ }
30
+
31
+ case ComponentAnimationType.componentFade:
32
+ case ComponentAnimationType.componentAppears: {
33
+ return { opacity: animatedValue };
34
+ }
35
+
36
+ case ComponentAnimationType.moveUpComponent: {
37
+ return { transform: [{ translateY: animatedValue }] };
38
+ }
39
+
40
+ case ComponentAnimationType.audioPlayerPaddingHorizontal:
41
+ case ComponentAnimationType.moveComponentHorizontal: {
42
+ return { transform: [{ translateX: animatedValue }] };
43
+ }
44
+
45
+ default:
46
+ return null;
47
+ }
48
+ };
49
+
50
+ export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
51
+ switch (component) {
52
+ case ComponentAnimationType.bottomBar: {
53
+ return bottomTabBarHeight;
54
+ }
55
+
56
+ case ComponentAnimationType.player: {
57
+ return { x: 0, y: 0 };
58
+ }
59
+
60
+ case ComponentAnimationType.componentFade: {
61
+ return 1;
62
+ }
63
+
64
+ case ComponentAnimationType.audioPlayerPaddingHorizontal:
65
+ case ComponentAnimationType.moveComponentHorizontal:
66
+ case ComponentAnimationType.componentAppears:
67
+ case ComponentAnimationType.moveUpComponent: {
68
+ return 0;
69
+ }
70
+ }
71
+ };
72
+
73
+ export const calculateAnimationValue = (animationType, dragPosition, data) => {
74
+ const {
75
+ isAudioItem,
76
+ bottomTabBarHeight,
77
+ minimisedHeight,
78
+ minimisedWidth,
79
+ defaultValue,
80
+ moveUpValue,
81
+ moveComponentHorizontalValue,
82
+ isTablet,
83
+ isTabletLandscape,
84
+ isRTL,
85
+ fromMiniPlayer,
86
+ inlineAudioPlayer,
87
+ } = data;
88
+
89
+ switch (animationType) {
90
+ case ComponentAnimationType.bottomBar: {
91
+ if (fromMiniPlayer) {
92
+ return dragPosition < bottomTabBarHeight
93
+ ? dragPosition
94
+ : bottomTabBarHeight;
95
+ }
96
+
97
+ return dragPosition < bottomTabBarHeight
98
+ ? bottomTabBarHeight - dragPosition
99
+ : 0;
100
+ }
101
+
102
+ case ComponentAnimationType.player: {
103
+ const value =
104
+ isAudioItem && !inlineAudioPlayer
105
+ ? isTabletLandscape
106
+ ? fromMiniPlayer
107
+ ? { forWidth: 4, forHeight: 4.5 }
108
+ : { forWidth: 3, forHeight: 3 }
109
+ : { forWidth: 2, forHeight: 2 }
110
+ : isTabletLandscape
111
+ ? { forWidth: 8, forHeight: 6.5 }
112
+ : { forWidth: 3.5, forHeight: 2 };
113
+
114
+ const minWidth =
115
+ isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
116
+
117
+ if (fromMiniPlayer) {
118
+ const calculationWidth =
119
+ dragPosition * value.forWidth < minWidth
120
+ ? minWidth
121
+ : dragPosition * value.forWidth;
122
+ const calculationHeight =
123
+ dragPosition * value.forHeight < minimisedHeight
124
+ ? minimisedHeight
125
+ : dragPosition * value.forHeight;
126
+
127
+ return {
128
+ x:
129
+ calculationWidth < defaultValue.x
130
+ ? calculationWidth
131
+ : defaultValue.x,
132
+ y:
133
+ calculationHeight < defaultValue.y
134
+ ? calculationHeight
135
+ : defaultValue.y,
136
+ };
137
+ }
138
+
139
+ const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
140
+
141
+ const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
142
+
143
+ return {
144
+ x: calculationWidth > minWidth ? calculationWidth : minWidth,
145
+ y:
146
+ calculationHeight > minimisedHeight
147
+ ? calculationHeight
148
+ : minimisedHeight,
149
+ };
150
+ }
151
+
152
+ case ComponentAnimationType.componentFade: {
153
+ if (fromMiniPlayer) {
154
+ const calculation = dragPosition / (isTablet ? 200 : 150);
155
+
156
+ return calculation < 1 ? calculation : 1;
157
+ }
158
+
159
+ const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
160
+
161
+ return calculation > 0 ? calculation : 0;
162
+ }
163
+
164
+ case ComponentAnimationType.componentAppears: {
165
+ if (fromMiniPlayer) {
166
+ const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
167
+
168
+ return calculation > 0 ? calculation : 0;
169
+ }
170
+
171
+ const calculation = dragPosition / (isTablet ? 200 : 150);
172
+
173
+ return calculation < 1 ? calculation : 1;
174
+ }
175
+
176
+ case ComponentAnimationType.moveUpComponent: {
177
+ if (fromMiniPlayer) {
178
+ const calculation =
179
+ moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
180
+
181
+ return calculation < 0 ? calculation : 0;
182
+ }
183
+
184
+ const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
185
+
186
+ return calculation > moveUpValue ? calculation : moveUpValue;
187
+ }
188
+
189
+ case ComponentAnimationType.moveComponentHorizontal: {
190
+ if (fromMiniPlayer) {
191
+ const calculation = isRTL
192
+ ? moveComponentHorizontalValue - dragPosition * 2
193
+ : moveComponentHorizontalValue + dragPosition * 2;
194
+ const condition = isRTL ? calculation > 0 : calculation < 0;
195
+
196
+ return condition ? calculation : 0;
197
+ }
198
+
199
+ const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
200
+ const condition = isRTL
201
+ ? calculation < moveComponentHorizontalValue
202
+ : calculation > moveComponentHorizontalValue;
203
+
204
+ return condition ? calculation : moveComponentHorizontalValue;
205
+ }
206
+
207
+ case ComponentAnimationType.audioPlayerPaddingHorizontal: {
208
+ const padding = isRTL
209
+ ? AUDIO_PLAYER_HORIZONTAL_PADDING
210
+ : -AUDIO_PLAYER_HORIZONTAL_PADDING;
211
+
212
+ if (fromMiniPlayer) {
213
+ const calculation = isRTL
214
+ ? padding - dragPosition / 5
215
+ : padding + dragPosition / 5;
216
+ const condition = isRTL ? calculation > 0 : calculation < 0;
217
+
218
+ return condition ? calculation : 0;
219
+ }
220
+
221
+ const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
222
+ const condition = isRTL ? calculation < padding : calculation > padding;
223
+
224
+ return condition ? calculation : padding;
225
+ }
226
+ }
227
+ };
228
+
229
+ export const gestureListenerHelper = (data) => {
230
+ const {
231
+ listenerValue,
232
+ preparedValue,
233
+ animationType,
234
+ animatedValue,
235
+ calculationData,
236
+ modalSnapPoint,
237
+ startComponentsAnimationDistance,
238
+ startComponentsAnimation,
239
+ setStartComponentsAnimation,
240
+ getAnimationValue,
241
+ } = data;
242
+
243
+ if (calculationData.fromMiniPlayer) {
244
+ if (listenerValue <= 0) {
245
+ if (
246
+ preparedValue >= 0 &&
247
+ preparedValue <= modalSnapPoint - startComponentsAnimationDistance
248
+ ) {
249
+ !startComponentsAnimation && setStartComponentsAnimation(true);
250
+
251
+ animatedValue.setValue(
252
+ calculateAnimationValue(animationType, preparedValue, calculationData)
253
+ );
254
+ } else {
255
+ animatedValue.setValue(calculationData.defaultValue);
256
+ startComponentsAnimation && setStartComponentsAnimation(false);
257
+ }
258
+ } else {
259
+ const value = getAnimationValue(
260
+ animationType,
261
+ PlayerAnimationStateEnum.minimize
262
+ ).toValue;
263
+
264
+ animatedValue.setValue(value);
265
+ }
266
+ } else {
267
+ if (preparedValue >= startComponentsAnimationDistance) {
268
+ !startComponentsAnimation && setStartComponentsAnimation(true);
269
+ const value = Math.round(
270
+ preparedValue - startComponentsAnimationDistance
271
+ );
272
+
273
+ animatedValue.setValue(
274
+ calculateAnimationValue(animationType, value, calculationData)
275
+ );
276
+ } else {
277
+ animatedValue.setValue(calculationData.defaultValue);
278
+ startComponentsAnimation && setStartComponentsAnimation(false);
279
+ }
280
+ }
281
+ };
282
+
283
+ export const setScrollModalAnimatedValue = (
284
+ animatedValue,
285
+ value,
286
+ setLastSnap
287
+ ) => {
288
+ setLastSnap(value);
289
+ animatedValue.setValue(value);
290
+ };
291
+
292
+ export const resetScrollAnimatedValues = (
293
+ lastScrollY,
294
+ lastScrollYValue,
295
+ dragScrollY,
296
+ dragVideoPlayerY
297
+ ) => {
298
+ lastScrollY.setValue(0);
299
+ lastScrollYValue.current = 0;
300
+ dragScrollY.setValue(0);
301
+ dragVideoPlayerY.setValue(0);
302
+ };
@@ -1,9 +1,17 @@
1
1
  import React, { useEffect, useRef } from "react";
2
- import { StyleProp, ViewStyle, Animated, Easing } from "react-native";
2
+ import {
3
+ StyleProp,
4
+ ViewStyle,
5
+ Animated,
6
+ Easing,
7
+ Dimensions,
8
+ } from "react-native";
3
9
  import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
4
10
  import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
5
11
  import { useSafeAreaInsets } from "react-native-safe-area-context";
6
12
 
13
+ const { width: SCREEN_WIDTH } = Dimensions.get("screen");
14
+
7
15
  type Configuration = {
8
16
  [key: string]: any;
9
17
  modal_background_color?: string;
@@ -15,6 +23,7 @@ type Props = {
15
23
  configuration: Configuration;
16
24
  isTabletLandscape: boolean;
17
25
  isAudioPlayer?: boolean;
26
+ isTablet: boolean;
18
27
  };
19
28
 
20
29
  const containerStyle = ({
@@ -23,12 +32,15 @@ const containerStyle = ({
23
32
  backgroundColor: modal_background_color,
24
33
  });
25
34
 
35
+ // const audioMarginStyle = { marginTop: 0, marginBottom: 0 };
36
+
26
37
  export const PlayerDetails = ({
27
38
  entry,
28
39
  style,
29
40
  configuration,
30
41
  isTabletLandscape,
31
42
  isAudioPlayer,
43
+ isTablet,
32
44
  }: Props) => {
33
45
  const screenData = useTargetScreenData(entry);
34
46
  const insets = useSafeAreaInsets();
@@ -40,12 +52,12 @@ export const PlayerDetails = ({
40
52
  : {};
41
53
 
42
54
  // Animation setup
43
- const translateY = useRef(new Animated.Value(100)).current;
55
+ const translateY = useRef(new Animated.Value(50)).current;
44
56
  const opacity = useRef(new Animated.Value(0)).current;
45
57
 
46
58
  const runAnimation = () => {
47
59
  Animated.timing(translateY, {
48
- toValue: 0,
60
+ toValue: -30,
49
61
  duration: 500,
50
62
  easing: Easing.inOut(Easing.ease),
51
63
  useNativeDriver: true,
@@ -61,7 +73,7 @@ export const PlayerDetails = ({
61
73
 
62
74
  useEffect(() => {
63
75
  if (isAudioPlayer) {
64
- setTimeout(() => runAnimation(), 1000);
76
+ setTimeout(() => runAnimation(), 1500);
65
77
  }
66
78
  }, [isAudioPlayer]);
67
79
 
@@ -75,6 +87,11 @@ export const PlayerDetails = ({
75
87
  transform: [{ translateY }],
76
88
  opacity,
77
89
  },
90
+ {
91
+ // workaround for avoid wrong text-height after going back to portrait rotation
92
+ // we don't see this view in landscape mode, so we are able to use fixed width from portrait mode
93
+ width: isTablet ? undefined : SCREEN_WIDTH,
94
+ },
78
95
  ]}
79
96
  >
80
97
  {screenData && (
@@ -7,17 +7,26 @@ import {
7
7
  ViewStyle,
8
8
  } from "react-native";
9
9
  import { Edge, SafeAreaView } from "react-native-safe-area-context";
10
-
11
10
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
12
11
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
13
12
  import { PlayerDetails } from "./PlayerDetails";
14
13
  import { playerDimesionsHack } from "./utils";
15
14
  import { PathnameContext } from "../../Contexts/PathnameContext";
16
15
  import { ScreenContextProvider } from "../../Contexts/ScreenContext";
16
+ import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
17
+
18
+ import {
19
+ AnimatedScrollModal,
20
+ AnimatedVideoPlayerComponent,
21
+ AnimationComponent,
22
+ ComponentAnimationType,
23
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
24
+
25
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
17
26
 
18
27
  type DimensionsT = {
19
28
  width: number | string;
20
- height: number | string;
29
+ height: number | string | undefined;
21
30
  aspectRatio?: number;
22
31
  };
23
32
 
@@ -44,6 +53,7 @@ type Props = {
44
53
  const defaultStyles = StyleSheet.create({
45
54
  playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
46
55
  playerDetails: { flex: 1, paddingTop: 20 },
56
+ flex: { flex: 1 },
47
57
  });
48
58
 
49
59
  const orientationStyles = StyleSheet.create({
@@ -60,10 +70,8 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
60
70
  };
61
71
 
62
72
  const getScreenAspectRatio = () => {
63
- const { width, height } = Dimensions.get("screen");
64
-
65
- const longEdge = Math.max(width, height);
66
- const shortEdge = Math.min(width, height);
73
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
74
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
67
75
 
68
76
  return longEdge / shortEdge;
69
77
  };
@@ -82,18 +90,9 @@ const safeAreaStyles = (
82
90
  };
83
91
  };
84
92
 
85
- const getEdges = (
86
- isTablet: boolean,
87
- docked: boolean,
88
- isInlineModal: boolean
89
- ) => {
93
+ const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
90
94
  if (isTablet) {
91
- return docked ? ["right", "left"] : ["top"];
92
- }
93
-
94
- // mobile
95
- if (isInlineModal && docked) {
96
- return ["bottom"];
95
+ return ["top"];
97
96
  }
98
97
 
99
98
  if (!isInlineModal && Platform.OS === "android") {
@@ -125,10 +124,37 @@ const getTabletWidth = (
125
124
  return Number(width) - sidebarWidth;
126
125
  };
127
126
 
128
- export const PlayerWrapper = (props: Props) => {
127
+ const getStyles = (baseStyle, isMobile, isPortrait) => {
128
+ if (isMobile && isPortrait) {
129
+ return { width: SCREEN_WIDTH, height: SCREEN_HEIGHT };
130
+ }
131
+
132
+ if (isMobile && !isPortrait) {
133
+ return { width: SCREEN_HEIGHT, height: SCREEN_WIDTH };
134
+ }
135
+
136
+ return baseStyle;
137
+ };
138
+
139
+ const showDetails = (isMobile: boolean, docked: boolean): boolean => {
140
+ // for mobile we always show details. Mounting of it very heavy operation.
141
+ if (isMobile) {
142
+ return true;
143
+ }
144
+
145
+ // workaround for tablets we need to mount/unmount in order to avoid PlayerDetails content dissappearing
146
+ // FIXME - find out the reason of dissapearing of content
147
+ if (docked) {
148
+ return false;
149
+ }
150
+
151
+ return true;
152
+ };
153
+
154
+ const PlayerWrapperComponent = (props: Props) => {
129
155
  const {
130
156
  entry,
131
- style,
157
+ style: baseStyle,
132
158
  containerStyle,
133
159
  inline,
134
160
  docked,
@@ -143,6 +169,8 @@ export const PlayerWrapper = (props: Props) => {
143
169
 
144
170
  const isInlineModal = inline && isModal;
145
171
 
172
+ const style = getStyles(baseStyle, !isTablet, isInlineModal);
173
+
146
174
  const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
147
175
 
148
176
  const tabletWidth = getTabletWidth(configuration, style);
@@ -151,9 +179,9 @@ export const PlayerWrapper = (props: Props) => {
151
179
  () => ({
152
180
  width:
153
181
  isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
154
- height: isInlineModal && docked ? style.height : undefined,
182
+ height: undefined,
155
183
  }),
156
- [isInlineModal, tabletWidth, style.height, docked]
184
+ [isInlineModal, tabletWidth, docked]
157
185
  );
158
186
 
159
187
  const playerDimensions: DimensionsT = React.useMemo(
@@ -162,7 +190,7 @@ export const PlayerWrapper = (props: Props) => {
162
190
  width: isInlineModal && docked ? undefined : baseDimensions.width,
163
191
  aspectRatio: !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9,
164
192
  }),
165
- [baseDimensions, isInlineModal]
193
+ [baseDimensions, isInlineModal, pip]
166
194
  );
167
195
 
168
196
  const containerDimensions: DimensionsT = React.useMemo(
@@ -181,41 +209,73 @@ export const PlayerWrapper = (props: Props) => {
181
209
  [containerDimensions, playerDimesionsHack]
182
210
  );
183
211
 
212
+ const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
213
+
184
214
  return (
185
- <WrapperView
186
- edges={getEdges(isTablet, docked, isInlineModal) as readonly Edge[]}
187
- style={[
188
- directionStyles(isTabletLandscape),
189
- safeAreaStyles(configuration, isTablet),
190
- style,
191
- playerDimesionsHack,
192
- ]}
193
- >
194
- <ScreenContextProvider pathname={"videoModal"}>
195
- <PathnameContext.Provider value={"videoModal"}>
196
- <View
197
- testID={`${entry?.id}-player-container`}
198
- style={[
199
- defaultStyles.playerContainer,
200
- containerDimensions,
201
- containerStyle,
202
- playerDimesionsHack,
203
- ]}
215
+ <PathnameContext.Provider value={pathname}>
216
+ <ScreenContextProvider pathname={pathname}>
217
+ <WrapperView
218
+ edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
219
+ style={[
220
+ safeAreaStyles(configuration, isTablet),
221
+ style,
222
+ playerDimesionsHack,
223
+ ]}
224
+ >
225
+ <AnimationComponent
226
+ animationType={ComponentAnimationType.moveUpComponent}
227
+ additionalData={{ saveArea: true }}
228
+ style={[directionStyles(isTabletLandscape), defaultStyles.flex]}
204
229
  >
205
- {children(childrenStyles)}
206
- </View>
207
- {isInlineModal && !docked ? (
208
- <PlayerDetails
209
- configuration={configuration}
210
- style={defaultStyles.playerDetails}
211
- entry={entry}
212
- isTabletLandscape={isTabletLandscape}
213
- />
214
- ) : (
215
- <View style={defaultStyles.playerDetails} />
216
- )}
217
- </PathnameContext.Provider>
230
+ <PathnameContext.Provider value={pathname}>
231
+ <ScreenContextProvider pathname={pathname}>
232
+ <View
233
+ testID={`${entry?.id}-player-container`}
234
+ style={[
235
+ defaultStyles.playerContainer,
236
+ containerDimensions,
237
+ containerStyle,
238
+ playerDimesionsHack,
239
+ ]}
240
+ >
241
+ <AnimationComponent
242
+ animationType={ComponentAnimationType.moveUpComponent}
243
+ style={isTabletLandscape ? defaultStyles.flex : undefined}
244
+ additionalData={{
245
+ useLayoutMeasure: isTabletLandscape,
246
+ disableAnimatedComponent: !isTabletLandscape,
247
+ resetAnimationValue: isTabletLandscape && docked,
248
+ }}
249
+ >
250
+ <AnimatedVideoPlayerComponent>
251
+ {children(childrenStyles)}
252
+ </AnimatedVideoPlayerComponent>
253
+ </AnimationComponent>
254
+ </View>
255
+
256
+ <AnimatedScrollModal>
257
+ {showDetails(!isTablet, docked) && (
258
+ <AnimationComponent
259
+ animationType={ComponentAnimationType.componentFade}
260
+ style={defaultStyles.flex}
261
+ >
262
+ <PlayerDetails
263
+ configuration={configuration}
264
+ style={defaultStyles.playerDetails}
265
+ entry={entry}
266
+ isTabletLandscape={isTabletLandscape}
267
+ isTablet={isTablet}
268
+ />
269
+ </AnimationComponent>
270
+ )}
271
+ </AnimatedScrollModal>
272
+ </ScreenContextProvider>
273
+ </PathnameContext.Provider>
274
+ </AnimationComponent>
275
+ </WrapperView>
218
276
  </ScreenContextProvider>
219
- </WrapperView>
277
+ </PathnameContext.Provider>
220
278
  );
221
279
  };
280
+
281
+ export const PlayerWrapper = PlayerWrapperComponent;