@applicaster/zapp-react-native-ui-components 15.0.0-rc.1 → 15.0.0-rc.100

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 (123) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/BaseFocusable/index.ios.ts +12 -2
  3. package/Components/Cell/Cell.tsx +14 -3
  4. package/Components/Cell/CellWithFocusable.tsx +9 -0
  5. package/Components/Cell/FocusableWrapper.tsx +47 -0
  6. package/Components/Cell/TvOSCellComponent.tsx +106 -19
  7. package/Components/Focusable/Focusable.tsx +4 -2
  8. package/Components/Focusable/FocusableTvOS.tsx +18 -1
  9. package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
  10. package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
  11. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
  12. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +31 -17
  13. package/Components/HandlePlayable/HandlePlayable.tsx +17 -65
  14. package/Components/HandlePlayable/const.ts +3 -0
  15. package/Components/HandlePlayable/utils.ts +74 -0
  16. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  17. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  18. package/Components/Layout/TV/index.tsx +3 -4
  19. package/Components/Layout/TV/index.web.tsx +3 -4
  20. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  21. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  22. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  23. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  24. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  25. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  26. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  27. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
  28. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
  29. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
  30. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
  31. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
  32. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  33. package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
  34. package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
  35. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -2
  36. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +233 -11
  37. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +19 -15
  38. package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
  39. package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
  40. package/Components/MasterCell/index.tsx +2 -0
  41. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  42. package/Components/MasterCell/utils/index.ts +61 -31
  43. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  44. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  45. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
  46. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
  47. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  48. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  49. package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
  50. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  51. package/Components/PlayerContainer/PlayerContainer.tsx +51 -55
  52. package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +101 -0
  53. package/Components/PlayerImageBackground/index.tsx +3 -22
  54. package/Components/River/ComponentsMap/ComponentsMap.tsx +65 -42
  55. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  56. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  57. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  58. package/Components/River/TV/River.tsx +31 -14
  59. package/Components/River/TV/index.tsx +8 -4
  60. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  61. package/Components/River/TV/utils/index.ts +4 -0
  62. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  63. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  64. package/Components/River/__tests__/componentsMap.test.js +38 -0
  65. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  66. package/Components/Screen/TV/index.web.tsx +4 -2
  67. package/Components/Screen/__tests__/Screen.test.tsx +65 -42
  68. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -42
  69. package/Components/Screen/hooks.ts +2 -3
  70. package/Components/Screen/index.tsx +24 -8
  71. package/Components/Screen/navigationHandler.ts +49 -24
  72. package/Components/Screen/orientationHandler.ts +10 -13
  73. package/Components/ScreenResolver/index.tsx +21 -9
  74. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  75. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  76. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  77. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
  78. package/Components/Tabs/TV/Tabs.tsx +20 -3
  79. package/Components/Tabs/TabContent.tsx +7 -4
  80. package/Components/Transitioner/Scene.tsx +15 -2
  81. package/Components/Transitioner/index.js +3 -3
  82. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  83. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  84. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  85. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  86. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  87. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  88. package/Components/VideoModal/VideoModal.tsx +1 -5
  89. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  90. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  91. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  92. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  93. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  94. package/Components/VideoModal/utils.ts +19 -9
  95. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  96. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
  97. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  98. package/Contexts/ScreenContext/index.tsx +25 -18
  99. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  100. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  101. package/Contexts/index.ts +0 -2
  102. package/Decorators/Analytics/index.tsx +6 -5
  103. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  104. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  105. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  106. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  107. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  108. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  109. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  110. package/Helpers/DataSourceHelper/index.ts +19 -0
  111. package/events/index.ts +3 -0
  112. package/events/scrollEndReached.ts +15 -0
  113. package/index.d.ts +7 -0
  114. package/package.json +6 -5
  115. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  116. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  117. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -415
  118. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  119. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  120. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  121. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  122. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  123. package/Helpers/DataSourceHelper/index.js +0 -19
@@ -1,294 +0,0 @@
1
- import React from "react";
2
- import { Animated, StyleSheet, View } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
-
6
- import {
7
- PlayerAnimationStateEnum,
8
- useModalAnimationContext,
9
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
10
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
11
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
12
-
13
- import {
14
- resetScrollAnimatedValues,
15
- setScrollModalAnimatedValue,
16
- } from "./utils";
17
-
18
- import { DURATION_TO_MINIMIZE } from "./const";
19
-
20
- const getAnimatedConfig = (toValue) => {
21
- return {
22
- toValue,
23
- duration: DURATION_TO_MINIMIZE,
24
- useNativeDriver: true,
25
- };
26
- };
27
-
28
- const generalStyles = StyleSheet.create({
29
- container: {
30
- flex: 1,
31
- },
32
- });
33
-
34
- type Props = {
35
- children: React.ReactNode;
36
- };
37
-
38
- export const AnimatedScrollModalComponent = ({ children }: Props) => {
39
- const {
40
- isActiveGesture,
41
- playerAnimationState,
42
- setPlayerAnimationState,
43
- resetPlayerAnimationState,
44
- animatedValues: {
45
- lastScrollY,
46
- dragScrollY,
47
- dragVideoPlayerY,
48
- translateYOffset,
49
- },
50
- lastScrollYValue,
51
- scrollPosition,
52
- modalSnapPoints,
53
- setLastSnap,
54
- setStartComponentsAnimation,
55
- } = useModalAnimationContext();
56
-
57
- const [enableGesture, setIEnableGesture] = React.useState<boolean>(true);
58
-
59
- const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
60
- useNavigation();
61
-
62
- const {
63
- mode: videoModalMode,
64
- previousMode: previousVideoModalMode,
65
- item: videoModalItem,
66
- } = videoModalState;
67
-
68
- const isMaximizedModal: boolean = videoModalMode === "MAXIMIZED";
69
- const isMinimizedModal: boolean = videoModalMode === "MINIMIZED";
70
- const previousItemId = usePrevious(videoModalItem?.id);
71
-
72
- const isNotMinimizeMaximazeAnimation =
73
- playerAnimationState !== PlayerAnimationStateEnum.minimize &&
74
- playerAnimationState !== PlayerAnimationStateEnum.maximize;
75
-
76
- const isAudioItem = React.useMemo(
77
- () =>
78
- videoModalItem?.content?.type?.includes?.("audio") ||
79
- videoModalItem?.type?.value === "audio",
80
- [videoModalItem]
81
- );
82
-
83
- const onRegisterLastScroll = Animated.event(
84
- [{ nativeEvent: { contentOffset: { y: lastScrollY } } }],
85
- { useNativeDriver: true }
86
- );
87
-
88
- const onScroll = React.useCallback(({ nativeEvent }) => {
89
- scrollPosition.current = nativeEvent.contentOffset.y;
90
- }, []);
91
-
92
- // Workaround for onMomentumScrollEnd issue
93
- // https://github.com/facebook/react-native/issues/32696#issuecomment-1104217223
94
- const canMomentum = React.useRef(false);
95
-
96
- const onMomentumScrollBegin = React.useCallback(() => {
97
- canMomentum.current = true;
98
- }, []);
99
-
100
- const onMomentumScrollEnd = React.useCallback(
101
- ({ nativeEvent }) => {
102
- if (canMomentum.current && !isActiveGesture) {
103
- if (nativeEvent.contentOffset.y === 0) {
104
- resetScrollAnimatedValues(
105
- lastScrollY,
106
- lastScrollYValue,
107
- dragScrollY,
108
- dragVideoPlayerY
109
- );
110
-
111
- setIEnableGesture(true);
112
- } else {
113
- setIEnableGesture(false);
114
- }
115
-
116
- canMomentum.current = false;
117
- }
118
- },
119
- [isActiveGesture]
120
- );
121
-
122
- React.useEffect(() => {
123
- return () => {
124
- scrollPosition.current = 0;
125
-
126
- resetScrollAnimatedValues(
127
- lastScrollY,
128
- lastScrollYValue,
129
- dragScrollY,
130
- dragVideoPlayerY
131
- );
132
- };
133
- }, []);
134
-
135
- React.useEffect(() => {
136
- if (
137
- videoModalMode === "MAXIMIZED" &&
138
- !enableGesture &&
139
- scrollPosition.current === 0
140
- ) {
141
- setIEnableGesture(true);
142
- }
143
-
144
- if (
145
- videoModalMode === "MINIMIZED" &&
146
- previousVideoModalMode === "MAXIMIZED"
147
- ) {
148
- // set animation to the minimize values if moving from the player to another screen
149
- if (playerAnimationState === null) {
150
- setScrollModalAnimatedValue(
151
- translateYOffset,
152
- modalSnapPoints[1],
153
- setLastSnap
154
- );
155
-
156
- resetScrollAnimatedValues(
157
- lastScrollY,
158
- lastScrollYValue,
159
- dragScrollY,
160
- dragVideoPlayerY
161
- );
162
- }
163
- } else if (
164
- playerAnimationState === null &&
165
- ((previousItemId === videoModalItem?.id &&
166
- videoModalMode === "MAXIMIZED" &&
167
- (previousVideoModalMode === "MINIMIZED" ||
168
- previousVideoModalMode === "MAXIMIZED")) ||
169
- (previousItemId !== videoModalItem?.id &&
170
- videoModalMode !== "FULLSCREEN"))
171
- ) {
172
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
173
- }
174
- }, [videoModalMode, previousVideoModalMode, videoModalItem]);
175
-
176
- React.useEffect(() => {
177
- if (playerAnimationState === PlayerAnimationStateEnum.minimize) {
178
- if (
179
- (scrollPosition.current === 0 &&
180
- (lastScrollY as any)._value !== 0 &&
181
- (dragScrollY as any)._value === 0 &&
182
- (dragVideoPlayerY as any)._value === 0) ||
183
- (scrollPosition.current !== 0 &&
184
- ((dragScrollY as any)._value !== 0 ||
185
- (dragVideoPlayerY as any)._value !== 0))
186
- ) {
187
- resetScrollAnimatedValues(
188
- lastScrollY,
189
- lastScrollYValue,
190
- dragScrollY,
191
- dragVideoPlayerY
192
- );
193
- }
194
-
195
- Animated.timing(
196
- translateYOffset,
197
- getAnimatedConfig(modalSnapPoints[1])
198
- ).start(() => {
199
- minimiseVideoModal();
200
-
201
- setScrollModalAnimatedValue(
202
- translateYOffset,
203
- modalSnapPoints[1],
204
- setLastSnap
205
- );
206
-
207
- resetScrollAnimatedValues(
208
- lastScrollY,
209
- lastScrollYValue,
210
- dragScrollY,
211
- dragVideoPlayerY
212
- );
213
-
214
- resetPlayerAnimationState();
215
- });
216
- } else if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
217
- Animated.timing(translateYOffset, getAnimatedConfig(0)).start(() => {
218
- maximiseVideoModal();
219
- setScrollModalAnimatedValue(translateYOffset, 0, setLastSnap);
220
-
221
- resetScrollAnimatedValues(
222
- lastScrollY,
223
- lastScrollYValue,
224
- dragScrollY,
225
- dragVideoPlayerY
226
- );
227
-
228
- resetPlayerAnimationState();
229
- });
230
- }
231
- }, [playerAnimationState]);
232
-
233
- React.useEffect(() => {
234
- const lastScrollYListenerId = lastScrollY.addListener(({ value }) => {
235
- lastScrollYValue.current = value;
236
- });
237
-
238
- const dragListenerId = dragScrollY.addListener(({ value }) => {
239
- const preparedValue =
240
- isMinimizedModal && value >= 0
241
- ? 0
242
- : Math.round(isAudioItem ? Math.abs(value) : value);
243
-
244
- if (
245
- preparedValue > 0 &&
246
- scrollPosition.current === 0 &&
247
- playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
248
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
249
- ) {
250
- isMinimizedModal && setStartComponentsAnimation(true);
251
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
252
- }
253
- });
254
-
255
- return () => {
256
- lastScrollY.removeListener(lastScrollYListenerId);
257
- dragScrollY.removeListener(dragListenerId);
258
- };
259
- }, [playerAnimationState, isAudioItem, isMinimizedModal]);
260
-
261
- const scrollEnabled = isMaximizedModal && isNotMinimizeMaximazeAnimation;
262
-
263
- return (
264
- <View style={generalStyles.container}>
265
- <View pointerEvents="box-none">
266
- <Animated.View>
267
- <Animated.ScrollView
268
- scrollEnabled={scrollEnabled}
269
- bounces={false}
270
- onScrollBeginDrag={onRegisterLastScroll}
271
- onScroll={onScroll}
272
- onMomentumScrollBegin={onMomentumScrollBegin}
273
- onMomentumScrollEnd={onMomentumScrollEnd}
274
- scrollEventThrottle={1}
275
- showsVerticalScrollIndicator={false}
276
- >
277
- {children}
278
- </Animated.ScrollView>
279
- </Animated.View>
280
- </View>
281
- </View>
282
- );
283
- };
284
-
285
- export const AnimatedScrollModal = ({ children }: Props) => {
286
- const {
287
- videoModalState: { visible },
288
- } = useNavigation();
289
-
290
- const Component =
291
- !isTV() && visible ? AnimatedScrollModalComponent : React.Fragment;
292
-
293
- return <Component>{children}</Component>;
294
- };
@@ -1,176 +0,0 @@
1
- import React from "react";
2
- import { Animated, StyleSheet } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
- import { PanGestureHandler, State } from "react-native-gesture-handler";
6
-
7
- import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
8
- import {
9
- useModalAnimationContext,
10
- PlayerAnimationStateEnum,
11
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
12
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
13
-
14
- const generalStyles = StyleSheet.create({
15
- container: {
16
- flex: 1,
17
- width: "100%",
18
- position: "absolute",
19
- zIndex: 201,
20
- },
21
- });
22
-
23
- type Props = {
24
- children: React.ReactNode;
25
- };
26
-
27
- export const AnimatedVideoPlayer = ({ children }: Props) => {
28
- const {
29
- playerAnimationState,
30
- setPlayerAnimationState,
31
- animatedValues: { translateYOffset, dragVideoPlayerY, lastScrollY },
32
- lastScrollYValue,
33
- modalSnapPoints,
34
- lastSnap,
35
- setLastSnap,
36
- resetPlayerAnimationState,
37
- setStartComponentsAnimation,
38
- } = useModalAnimationContext();
39
-
40
- const {
41
- videoModalState: { mode: videoModalMode },
42
- } = useNavigation();
43
-
44
- const { isLanguageOverlayVisible, isSeekBarTouch } = React.useContext(
45
- PlayerContainerContext
46
- );
47
-
48
- const isMaximazedModal = videoModalMode === "MAXIMIZED";
49
- const isMinimizedModal = videoModalMode === "MINIMIZED";
50
-
51
- const isNotMinimizeMaximazeAnimation =
52
- playerAnimationState !== PlayerAnimationStateEnum.minimize &&
53
- playerAnimationState !== PlayerAnimationStateEnum.maximize;
54
-
55
- const isEnablePanGesture =
56
- !isLanguageOverlayVisible &&
57
- isNotMinimizeMaximazeAnimation &&
58
- !isSeekBarTouch &&
59
- (isMaximazedModal || isMinimizedModal);
60
-
61
- const onGestureEvent = Animated.event(
62
- [{ nativeEvent: { translationY: dragVideoPlayerY } }],
63
- { useNativeDriver: true }
64
- );
65
-
66
- const onHandlerStateChange = React.useCallback(
67
- ({ nativeEvent }) => {
68
- if (nativeEvent.oldState === State.ACTIVE) {
69
- // eslint-disable-next-line prefer-const
70
- const { velocityY, translationY } = nativeEvent;
71
- const preparedTranslationY = Math.abs(translationY);
72
- const dragToss = 0.05;
73
-
74
- if (videoModalMode === "MAXIMIZED") {
75
- if (translationY > 0) {
76
- const endOffsetY =
77
- lastSnap + preparedTranslationY + dragToss * velocityY + 200;
78
-
79
- let destSnapPoint = modalSnapPoints[0];
80
-
81
- for (const snapPoint of modalSnapPoints) {
82
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
83
-
84
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
85
- destSnapPoint = snapPoint;
86
- }
87
- }
88
-
89
- setLastSnap(destSnapPoint);
90
-
91
- if (destSnapPoint === modalSnapPoints[0]) {
92
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
93
- } else {
94
- lastScrollY.setValue(0);
95
- lastScrollYValue.current = 0;
96
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
97
- }
98
- }
99
- } else if (videoModalMode === "MINIMIZED") {
100
- if (translationY < 0) {
101
- // from mini to full
102
- setLastSnap(modalSnapPoints[0]);
103
-
104
- translateYOffset.setValue(
105
- modalSnapPoints[1] - preparedTranslationY
106
- );
107
-
108
- setPlayerAnimationState(PlayerAnimationStateEnum.maximize);
109
- } else {
110
- resetPlayerAnimationState();
111
- }
112
- }
113
- }
114
- },
115
- [lastSnap, modalSnapPoints, videoModalMode]
116
- );
117
-
118
- React.useEffect(() => {
119
- const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
120
- ({ value }) => {
121
- if (
122
- (isMinimizedModal && value >= 0) ||
123
- (isMaximazedModal && value <= 0)
124
- ) {
125
- if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
126
- translateYOffset.setValue(
127
- modalSnapPoints[isMinimizedModal ? 1 : 0]
128
- );
129
- }
130
- } else {
131
- const preparedValue = Math.round(Math.abs(value));
132
-
133
- if (
134
- preparedValue > 0 &&
135
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
136
- ) {
137
- if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
138
- isMinimizedModal && setStartComponentsAnimation(true);
139
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
140
- }
141
-
142
- translateYOffset.setValue(
143
- isMaximazedModal
144
- ? preparedValue
145
- : modalSnapPoints[1] - preparedValue
146
- );
147
- }
148
- }
149
- }
150
- );
151
-
152
- return () => {
153
- dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
154
- };
155
- }, [playerAnimationState, isMinimizedModal, isMaximazedModal]);
156
-
157
- return (
158
- <PanGestureHandler
159
- enabled={isEnablePanGesture}
160
- onGestureEvent={onGestureEvent}
161
- onHandlerStateChange={onHandlerStateChange}
162
- >
163
- <Animated.View style={generalStyles.container}>{children}</Animated.View>
164
- </PanGestureHandler>
165
- );
166
- };
167
-
168
- export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
169
- const {
170
- videoModalState: { visible },
171
- } = useNavigation();
172
-
173
- const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
174
-
175
- return <Component>{children}</Component>;
176
- };
@@ -1,93 +0,0 @@
1
- import React from "react";
2
- import { Animated, StyleSheet } from "react-native";
3
-
4
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
-
6
- import {
7
- useModalAnimationContext,
8
- PlayerAnimationStateEnum,
9
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
10
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
11
-
12
- const generalStyles = StyleSheet.create({
13
- container: {
14
- flex: 1,
15
- width: "100%",
16
- position: "absolute",
17
- zIndex: 201,
18
- },
19
- });
20
-
21
- type Props = {
22
- children: React.ReactNode;
23
- };
24
-
25
- export const AnimatedVideoPlayer = ({ children }: Props) => {
26
- const {
27
- playerAnimationState,
28
- setPlayerAnimationState,
29
- animatedValues: { translateYOffset, dragVideoPlayerY },
30
- modalSnapPoints,
31
- setStartComponentsAnimation,
32
- } = useModalAnimationContext();
33
-
34
- const {
35
- videoModalState: { mode: videoModalMode },
36
- } = useNavigation();
37
-
38
- const isMaximazedModal = videoModalMode === "MAXIMIZED";
39
- const isMinimizedModal = videoModalMode === "MINIMIZED";
40
-
41
- React.useEffect(() => {
42
- const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
43
- ({ value }) => {
44
- if (
45
- (isMinimizedModal && value >= 0) ||
46
- (isMaximazedModal && value <= 0)
47
- ) {
48
- if (playerAnimationState === PlayerAnimationStateEnum.drag_player) {
49
- translateYOffset.setValue(
50
- modalSnapPoints[isMinimizedModal ? 1 : 0]
51
- );
52
- }
53
- } else {
54
- const preparedValue = Math.round(Math.abs(value));
55
-
56
- if (
57
- preparedValue > 0 &&
58
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
59
- ) {
60
- if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
61
- isMinimizedModal && setStartComponentsAnimation(true);
62
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
63
- }
64
-
65
- translateYOffset.setValue(
66
- isMaximazedModal
67
- ? preparedValue
68
- : modalSnapPoints[1] - preparedValue
69
- );
70
- }
71
- }
72
- }
73
- );
74
-
75
- return () => {
76
- dragVideoPlayerY.removeListener(dragVideoPlayerYListenerId);
77
- };
78
- }, [playerAnimationState, isMinimizedModal, isMaximazedModal]);
79
-
80
- return (
81
- <Animated.View style={generalStyles.container}>{children}</Animated.View>
82
- );
83
- };
84
-
85
- export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
86
- const {
87
- videoModalState: { visible },
88
- } = useNavigation();
89
-
90
- const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
91
-
92
- return <Component>{children}</Component>;
93
- };