@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4840257570 → 12.0.0-alpha.4876423277

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 (78) hide show
  1. package/Components/BaseFocusable/index.tsx +3 -3
  2. package/Components/Cell/Cell.tsx +30 -9
  3. package/Components/Cell/CellWithFocusable.tsx +23 -9
  4. package/Components/Cell/TvOSCellComponent.tsx +3 -7
  5. package/Components/Focusable/Focusable.tsx +6 -1
  6. package/Components/FocusableGroup/index.tsx +11 -2
  7. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  8. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  9. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  10. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  11. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  12. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  13. package/Components/Layout/TV/__tests__/index.test.tsx +20 -75
  14. package/Components/Layout/TV/index.tsx +14 -67
  15. package/Components/Layout/TV/index.web.tsx +33 -0
  16. package/Components/Layout/index.tsx +15 -11
  17. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -1
  18. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -116
  19. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  20. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
  21. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +57 -0
  22. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
  23. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  24. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  25. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
  26. package/Components/MasterCell/dataAdapter.ts +21 -7
  27. package/Components/MasterCell/index.tsx +5 -3
  28. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  29. package/Components/MasterCell/utils/index.ts +17 -30
  30. package/Components/Navigator/StackNavigator.tsx +57 -0
  31. package/Components/Navigator/index.ts +1 -0
  32. package/Components/PlayerContainer/PlayerContainer.tsx +5 -1
  33. package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
  34. package/Components/River/RefreshControl.tsx +2 -2
  35. package/Components/River/TV/River.tsx +0 -23
  36. package/Components/RouteManager/index.tsx +2 -2
  37. package/Components/Screen/TV/hooks/index.ts +3 -0
  38. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  39. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  40. package/Components/Screen/TV/index.web.tsx +165 -0
  41. package/Components/Screen/__tests__/Screen.test.tsx +3 -0
  42. package/Components/Screen/index.tsx +55 -58
  43. package/Components/Screen/navigationHandler.ts +5 -0
  44. package/Components/ScreenResolver/index.tsx +9 -12
  45. package/Components/Transitioner/Scene.tsx +32 -26
  46. package/Components/Transitioner/Transitioner.tsx +38 -43
  47. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
  48. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  49. package/Components/VideoLive/LiveImageManager.ts +28 -1
  50. package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
  51. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
  52. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
  53. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +79 -45
  54. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +47 -33
  55. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +121 -86
  56. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -4
  57. package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
  58. package/Components/VideoModal/PlayerDetails.tsx +3 -3
  59. package/Components/VideoModal/PlayerWrapper.tsx +67 -60
  60. package/Components/VideoModal/VideoModal.tsx +4 -4
  61. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
  62. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +80 -14
  63. package/Components/VideoModal/hooks/useModalSize.ts +10 -12
  64. package/Components/VideoModal/utils.ts +5 -2
  65. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  66. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
  67. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  68. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  69. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  70. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  71. package/Contexts/FocusableGroupContext/index.ts +7 -0
  72. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  73. package/Contexts/ScreenDataContext/index.tsx +20 -0
  74. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  75. package/package.json +5 -5
  76. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  77. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  78. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
@@ -10,6 +10,7 @@ exports[`<TransitionerComponent /> renders correctly 1`] = `
10
10
  }
11
11
  >
12
12
  <Scene
13
+ isActive={true}
13
14
  screenUniqueId="mocked-uuid"
14
15
  >
15
16
  <View
@@ -10,7 +10,11 @@ import { Component } from "react";
10
10
 
11
11
  const { log_debug, log_info, log_error } = loggerLiveImageManager;
12
12
 
13
- export type LiveImageManagerEvent = "onEnd" | "onStart" | "onError";
13
+ export type LiveImageManagerEvent =
14
+ | "onEnd"
15
+ | "onStart"
16
+ | "onError"
17
+ | "onDestroy";
14
18
 
15
19
  export type LiveImageManagerListenerData = {
16
20
  id: string;
@@ -102,6 +106,16 @@ export class LiveImageManager implements PlayerLifecycleListener {
102
106
  }
103
107
 
104
108
  this.items = this.items.filter((i) => i !== item);
109
+
110
+ this.invokeListenersUpdate({
111
+ callbackName: "onDestroy",
112
+ event: {
113
+ item,
114
+ playerId: this.currentlyPlaying?.playerId,
115
+ primaryPlayerId: this.primaryPlayer?.playerId,
116
+ entry: item.getPlayer().getEntry(),
117
+ },
118
+ });
105
119
  };
106
120
 
107
121
  public onViewportEnter = (item: LiveImage) => {
@@ -351,6 +365,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
351
365
  item,
352
366
  playerId: this.currentlyPlaying?.playerId,
353
367
  primaryPlayerId: this.primaryPlayer?.playerId,
368
+ entry: item.getPlayer().getEntry(),
354
369
  },
355
370
  });
356
371
  };
@@ -385,6 +400,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
385
400
  item,
386
401
  playerId: this.currentlyPlaying?.playerId,
387
402
  primaryPlayerId: this.primaryPlayer?.playerId,
403
+ entry: item.getPlayer().getEntry(),
388
404
  },
389
405
  });
390
406
  };
@@ -419,6 +435,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
419
435
  error,
420
436
  playerId: currentItem?.playerId,
421
437
  primaryPlayerId: currentItem?.playerId,
438
+ entry: item.getPlayer().getEntry(),
422
439
  },
423
440
  });
424
441
  };
@@ -508,6 +525,16 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
508
525
  LiveImageManager.instance.onLiveImageError(this, error);
509
526
  };
510
527
 
528
+ onVideoError = (error: Error) => {
529
+ log_error(
530
+ `onVideoError: live-image, fail to play, switching back to image. error: ${
531
+ error?.message
532
+ }, ${playerInfo(this.player)}`
533
+ );
534
+
535
+ LiveImageManager.instance.onLiveImageError(this, error);
536
+ };
537
+
511
538
  onVideoEnd = (_event) => {
512
539
  log_info(
513
540
  `onVideoEnd: live-image, video completed, switching back to image, ${playerInfo(
@@ -2,7 +2,7 @@
2
2
  //
3
3
  import * as React from "react";
4
4
 
5
- import { AppState, AppStateStatus } from "react-native";
5
+ import { AppState, AppStateStatus, View } from "react-native";
6
6
  import { TrackedView } from "../TrackedView";
7
7
  import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
8
8
 
@@ -25,8 +25,9 @@ import { PlayerRole } from "@applicaster/zapp-react-native-utils/appUtils/player
25
25
  import { getAutoplaySettings } from "./utils";
26
26
  import { isString } from "@applicaster/zapp-react-native-utils/stringUtils";
27
27
  import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
28
+ import { useEffect } from "react";
28
29
 
29
- const { log_error } = loggerLiveImageComponent;
30
+ const { log_error, log_debug } = loggerLiveImageComponent;
30
31
 
31
32
  const isMeasurement = (item: ZappEntry) =>
32
33
  isString(item.id) && item.id.startsWith("pre-measurement-");
@@ -56,6 +57,7 @@ const PlayerLiveImageComponent = (props: Props) => {
56
57
  );
57
58
 
58
59
  const ref = React.useRef(null);
60
+ const trackViewRef = React.useRef(null);
59
61
 
60
62
  /**
61
63
  * Debounced setMode function.
@@ -86,6 +88,30 @@ const PlayerLiveImageComponent = (props: Props) => {
86
88
  [mode]
87
89
  );
88
90
 
91
+ const entryToViewIdMapping = React.useRef({});
92
+
93
+ useEffect(() => {
94
+ const nativeTag = trackViewRef.current?._nativeTag?.toString();
95
+
96
+ if (!nativeTag) {
97
+ return;
98
+ }
99
+
100
+ const prevValue = entryToViewIdMapping.current[nativeTag];
101
+
102
+ if (prevValue && prevValue.itemId !== item.id) {
103
+ if (mode === LiveImageType.Video) {
104
+ log_debug(
105
+ "Entry to view association changed, stopping current live image"
106
+ );
107
+
108
+ setMode(LiveImageType.Image);
109
+ }
110
+ }
111
+
112
+ entryToViewIdMapping.current[nativeTag] = { itemId: item.id };
113
+ }, [trackViewRef.current, item.id, mode]);
114
+
89
115
  const { screenConfig, playerPluginId } = props;
90
116
 
91
117
  const liveImageItem: LiveImage = React.useMemo(() => {
@@ -295,28 +321,30 @@ const PlayerLiveImageComponent = (props: Props) => {
295
321
  testId={`tracked-view-${playerId}-${item.title}`}
296
322
  onPositionUpdated={onPositionUpdated}
297
323
  >
298
- {isVideoMode && (
299
- <Player
300
- autoplay={false}
301
- ref={_assignRoot}
302
- entry={item} // Must be passed first in list
303
- style={videoStyles}
304
- playerId={playerId}
305
- muted={muted}
306
- listener={controller?.getListener()}
307
- resizeMode={"cover"}
308
- {...platformSpecificProps}
309
- />
310
- )}
311
- {
312
- <AnimatedInOut
313
- visible={isBackgroundImageVisible}
314
- animationConfig={overlayFadeIn}
315
- staticStyles={style}
316
- >
317
- <Image {...props} resizeMode="cover" style={style} applyMaxSize />
318
- </AnimatedInOut>
319
- }
324
+ <View ref={trackViewRef}>
325
+ {isVideoMode && (
326
+ <Player
327
+ autoplay={false}
328
+ ref={_assignRoot}
329
+ entry={item} // Must be passed first in list
330
+ style={videoStyles}
331
+ playerId={playerId}
332
+ muted={muted}
333
+ listener={controller?.getListener()}
334
+ resizeMode={"cover"}
335
+ {...platformSpecificProps}
336
+ />
337
+ )}
338
+ {
339
+ <AnimatedInOut
340
+ visible={isBackgroundImageVisible}
341
+ animationConfig={overlayFadeIn}
342
+ staticStyles={style}
343
+ >
344
+ <Image {...props} resizeMode="cover" style={style} applyMaxSize />
345
+ </AnimatedInOut>
346
+ }
347
+ </View>
320
348
  </TrackedView>
321
349
  );
322
350
  };
@@ -5,33 +5,35 @@ exports[`PlayerLiveImageComponent should render correctly with default props 1`]
5
5
  onPositionUpdated={[Function]}
6
6
  testId="tracked-view-player1-Test"
7
7
  >
8
- <View
9
- collapsable={false}
10
- style={
11
- Object {
12
- "opacity": 1,
13
- }
14
- }
15
- >
16
- <Image
17
- applyMaxSize={true}
18
- audioMutedByDefault={false}
19
- imageKey="image1"
20
- item={
8
+ <View>
9
+ <View
10
+ collapsable={false}
11
+ style={
21
12
  Object {
22
- "id": "1",
23
- "title": "Test",
24
- "type": Object {
25
- "value": "",
26
- },
13
+ "opacity": 1,
27
14
  }
28
15
  }
29
- onError={[Function]}
30
- playerId="player1"
31
- resizeMode="cover"
32
- screenConfig={Object {}}
33
- style={Object {}}
34
- />
16
+ >
17
+ <Image
18
+ applyMaxSize={true}
19
+ audioMutedByDefault={false}
20
+ imageKey="image1"
21
+ item={
22
+ Object {
23
+ "id": "1",
24
+ "title": "Test",
25
+ "type": Object {
26
+ "value": "",
27
+ },
28
+ }
29
+ }
30
+ onError={[Function]}
31
+ playerId="player1"
32
+ resizeMode="cover"
33
+ screenConfig={Object {}}
34
+ style={Object {}}
35
+ />
36
+ </View>
35
37
  </View>
36
38
  </TrackedView>
37
39
  `;
@@ -5,7 +5,6 @@ import {
5
5
  useModalAnimationContext,
6
6
  PlayerAnimationStateEnum,
7
7
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
8
- import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
9
8
 
10
9
  type Props = {
11
10
  style: ViewStyle[];
@@ -18,13 +17,8 @@ export const AnimatedPlayerModalWrapper = (props: Props) => {
18
17
  animatedValues: { lastScrollY, dragScrollY, translateYOffset },
19
18
  modalSnapPoints,
20
19
  setStartComponentsAnimation,
21
- lastScrollYValue,
22
20
  } = useModalAnimationContext();
23
21
 
24
- const { height: screenHeight } = useDimensions("screen", {
25
- deviceInfo: true,
26
- });
27
-
28
22
  const interpolateConfig: Animated.InterpolationConfigType = React.useMemo(
29
23
  () => ({
30
24
  inputRange: modalSnapPoints,
@@ -51,16 +45,10 @@ export const AnimatedPlayerModalWrapper = (props: Props) => {
51
45
  }
52
46
 
53
47
  React.useEffect(() => {
54
- const translateYListener = translateY.addListener(({ value }) => {
55
- const preparedValue = Math.round(
56
- Math.abs(value) - lastScrollYValue.current
57
- );
58
-
48
+ const translateYListener = translateY.addListener(() => {
59
49
  (playerAnimationState === PlayerAnimationStateEnum.minimize ||
60
50
  playerAnimationState === PlayerAnimationStateEnum.maximaze) &&
61
- setStartComponentsAnimation(
62
- preparedValue >= Math.round((screenHeight * 10) / 100)
63
- );
51
+ setStartComponentsAnimation(true);
64
52
  });
65
53
 
66
54
  return () => {
@@ -58,6 +58,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
58
58
  modalSnapPoints,
59
59
  lastSnap,
60
60
  setLastSnap,
61
+ setStartComponentsAnimation,
61
62
  } = useModalAnimationContext();
62
63
 
63
64
  const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
@@ -100,58 +101,68 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
100
101
  { useNativeDriver: true }
101
102
  );
102
103
 
103
- const onHandlerStateChange = ({ nativeEvent }) => {
104
- if (nativeEvent.oldState === State.ACTIVE && scrollPosition.current === 0) {
105
- // eslint-disable-next-line prefer-const
106
- const { velocityY, translationY } = nativeEvent;
107
- const dragToss = 0.05;
104
+ const onHandlerStateChange = React.useCallback(
105
+ ({ nativeEvent }) => {
106
+ if (
107
+ nativeEvent.oldState === State.ACTIVE &&
108
+ scrollPosition.current === 0
109
+ ) {
110
+ // eslint-disable-next-line prefer-const
111
+ const { velocityY, translationY } = nativeEvent;
112
+ const dragToss = 0.05;
108
113
 
109
- const preparedTranslationY =
110
- Math.abs(translationY) - lastScrollYValue.current;
114
+ const preparedTranslationY =
115
+ Math.abs(translationY) - lastScrollYValue.current;
111
116
 
112
- if (videoModalState.mode === "MAXIMIZED") {
113
- const endOffsetY =
114
- lastSnap + preparedTranslationY + dragToss * velocityY + 150;
117
+ if (videoModalState.mode === "MAXIMIZED") {
118
+ const endOffsetY =
119
+ lastSnap + preparedTranslationY + dragToss * velocityY + 150;
115
120
 
116
- let destSnapPoint = modalSnapPoints[0];
121
+ let destSnapPoint = modalSnapPoints[0];
117
122
 
118
- for (const snapPoint of modalSnapPoints) {
119
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
123
+ for (const snapPoint of modalSnapPoints) {
124
+ const distFromSnap = Math.abs(snapPoint - endOffsetY);
120
125
 
121
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
122
- destSnapPoint = snapPoint;
126
+ if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
127
+ destSnapPoint = snapPoint;
128
+ }
123
129
  }
124
- }
125
130
 
126
- setLastSnap(destSnapPoint);
131
+ setLastSnap(destSnapPoint);
127
132
 
128
- if (destSnapPoint === modalSnapPoints[0]) {
129
- translateYOffset.extractOffset();
130
- translateYOffset.setValue(preparedTranslationY);
131
- translateYOffset.flattenOffset();
132
- dragScrollY.setValue(0);
133
+ if (destSnapPoint === modalSnapPoints[0]) {
134
+ translateYOffset.extractOffset();
135
+ translateYOffset.setValue(preparedTranslationY);
136
+ translateYOffset.flattenOffset();
137
+ dragScrollY.setValue(0);
133
138
 
134
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
139
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
140
+ } else {
141
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
142
+ }
135
143
  } else {
136
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
144
+ if (translationY < 0) {
145
+ // from mini to full
146
+ setLastSnap(modalSnapPoints[0]);
147
+
148
+ translateYOffset.setValue(
149
+ modalSnapPoints[1] - preparedTranslationY
150
+ );
151
+
152
+ dragScrollY.setValue(0);
153
+
154
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
155
+ } else {
156
+ resetPlayerAnimationState();
157
+ }
137
158
  }
138
159
  } else {
139
- if (translationY < 0) {
140
- // from mini to full
141
- setLastSnap(modalSnapPoints[0]);
142
- translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
143
- dragScrollY.setValue(0);
144
-
145
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
146
- } else {
160
+ playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
147
161
  resetPlayerAnimationState();
148
- }
149
162
  }
150
- } else {
151
- playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
152
- resetPlayerAnimationState();
153
- }
154
- };
163
+ },
164
+ [lastSnap, modalSnapPoints, playerAnimationState, videoModalState.mode]
165
+ );
155
166
 
156
167
  const onScroll = React.useCallback(({ nativeEvent }) => {
157
168
  scrollPosition.current = nativeEvent.contentOffset.y;
@@ -189,12 +200,29 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
189
200
  videoModalState.mode === "MINIMIZED" &&
190
201
  videoModalState.previousMode === "MAXIMIZED"
191
202
  ) {
192
- resetPlayerAnimationState();
203
+ // set animation to the minimize values if moving from the player to another screen
204
+ if (playerAnimationState === null) {
205
+ setScrollModalAnimatedValue(
206
+ translateYOffset,
207
+ modalSnapPoints[1],
208
+ setLastSnap
209
+ );
210
+
211
+ resetScrollAnimatedValues(
212
+ lastScrollY,
213
+ lastScrollYValue,
214
+ dragScrollY,
215
+ dragVideoPlayerY
216
+ );
217
+ } else {
218
+ resetPlayerAnimationState();
219
+ }
193
220
  }
194
221
 
195
222
  if (
196
223
  (videoModalState.mode === "MAXIMIZED" &&
197
- videoModalState.previousMode === "MAXIMIZED") ||
224
+ videoModalState.previousMode === "MINIMIZED" &&
225
+ previousItemId === videoModalState.item?.id) ||
198
226
  previousItemId !== videoModalState.item?.id
199
227
  ) {
200
228
  setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
@@ -271,10 +299,11 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
271
299
  if (
272
300
  preparedValue > 0 &&
273
301
  scrollPosition.current === 0 &&
274
- playerAnimationState !== PlayerAnimationStateEnum.drag_player
302
+ playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
303
+ playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
275
304
  ) {
276
- playerAnimationState !== PlayerAnimationStateEnum.drag_scroll &&
277
- setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
305
+ isMinimizedModal && setStartComponentsAnimation(true);
306
+ setPlayerAnimationState(PlayerAnimationStateEnum.drag_scroll);
278
307
  }
279
308
  });
280
309
 
@@ -282,7 +311,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
282
311
  lastScrollY.removeListener(lastScrollYListenerId);
283
312
  dragScrollY.removeListener(dragListenerId);
284
313
  };
285
- }, [playerAnimationState, isAudioItem, modalSnapPoints]);
314
+ }, [playerAnimationState, isAudioItem, modalSnapPoints, isMinimizedModal]);
286
315
 
287
316
  const Wrapper = React.useMemo(
288
317
  () => (Platform.OS === "android" ? GestureHandlerRootView : View),
@@ -336,7 +365,12 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
336
365
  };
337
366
 
338
367
  export const AnimatedScrollModal = ({ children }: Props) => {
339
- const Component = !isTV() ? AnimatedScrollModalComponent : React.Fragment;
368
+ const {
369
+ videoModalState: { visible },
370
+ } = useNavigation();
371
+
372
+ const Component =
373
+ !isTV() && visible ? AnimatedScrollModalComponent : React.Fragment;
340
374
 
341
375
  return <Component>{children}</Component>;
342
376
  };
@@ -34,6 +34,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
34
34
  lastSnap,
35
35
  setLastSnap,
36
36
  resetPlayerAnimationState,
37
+ setStartComponentsAnimation,
37
38
  } = useModalAnimationContext();
38
39
 
39
40
  const { videoModalState } = useNavigation();
@@ -50,50 +51,57 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
50
51
  { useNativeDriver: true }
51
52
  );
52
53
 
53
- const onHandlerStateChange = ({ nativeEvent }) => {
54
- if (nativeEvent.oldState === State.ACTIVE) {
55
- // eslint-disable-next-line prefer-const
56
- const { velocityY, translationY } = nativeEvent;
57
- const preparedTranslationY = Math.abs(translationY);
58
- const dragToss = 0.05;
54
+ const onHandlerStateChange = React.useCallback(
55
+ ({ nativeEvent }) => {
56
+ if (nativeEvent.oldState === State.ACTIVE) {
57
+ // eslint-disable-next-line prefer-const
58
+ const { velocityY, translationY } = nativeEvent;
59
+ const preparedTranslationY = Math.abs(translationY);
60
+ const dragToss = 0.05;
59
61
 
60
- if (videoModalState.mode === "MAXIMIZED") {
61
- if (translationY > 0) {
62
- const endOffsetY =
63
- lastSnap + preparedTranslationY + dragToss * velocityY + 200;
62
+ if (videoModalState.mode === "MAXIMIZED") {
63
+ if (translationY > 0) {
64
+ const endOffsetY =
65
+ lastSnap + preparedTranslationY + dragToss * velocityY + 200;
64
66
 
65
- let destSnapPoint = modalSnapPoints[0];
67
+ let destSnapPoint = modalSnapPoints[0];
66
68
 
67
- for (const snapPoint of modalSnapPoints) {
68
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
69
+ for (const snapPoint of modalSnapPoints) {
70
+ const distFromSnap = Math.abs(snapPoint - endOffsetY);
69
71
 
70
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
71
- destSnapPoint = snapPoint;
72
+ if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
73
+ destSnapPoint = snapPoint;
74
+ }
75
+ }
76
+
77
+ setLastSnap(destSnapPoint);
78
+
79
+ if (destSnapPoint === modalSnapPoints[0]) {
80
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
81
+ } else {
82
+ lastScrollY.setValue(0);
83
+ lastScrollYValue.current = 0;
84
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
72
85
  }
73
86
  }
87
+ } else if (videoModalState.mode === "MINIMIZED") {
88
+ if (translationY < 0) {
89
+ // from mini to full
90
+ setLastSnap(modalSnapPoints[0]);
74
91
 
75
- setLastSnap(destSnapPoint);
92
+ translateYOffset.setValue(
93
+ modalSnapPoints[1] - preparedTranslationY
94
+ );
76
95
 
77
- if (destSnapPoint === modalSnapPoints[0]) {
78
96
  setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
79
97
  } else {
80
- lastScrollY.setValue(0);
81
- lastScrollYValue.current = 0;
82
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
98
+ resetPlayerAnimationState();
83
99
  }
84
100
  }
85
- } else if (videoModalState.mode === "MINIMIZED") {
86
- if (translationY < 0) {
87
- // from mini to full
88
- setLastSnap(modalSnapPoints[0]);
89
- translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
90
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
91
- } else {
92
- resetPlayerAnimationState();
93
- }
94
101
  }
95
- }
96
- };
102
+ },
103
+ [lastSnap, modalSnapPoints, videoModalState.mode]
104
+ );
97
105
 
98
106
  React.useEffect(() => {
99
107
  const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
@@ -114,8 +122,10 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
114
122
  preparedValue > 0 &&
115
123
  playerAnimationState !== PlayerAnimationStateEnum.drag_scroll
116
124
  ) {
117
- playerAnimationState !== PlayerAnimationStateEnum.drag_player &&
125
+ if (playerAnimationState !== PlayerAnimationStateEnum.drag_player) {
126
+ isMinimizedModal && setStartComponentsAnimation(true);
118
127
  setPlayerAnimationState(PlayerAnimationStateEnum.drag_player);
128
+ }
119
129
 
120
130
  translateYOffset.setValue(
121
131
  isMaximazedModal
@@ -145,7 +155,11 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
145
155
  };
146
156
 
147
157
  export const AnimatedVideoPlayerComponent = ({ children }: Props) => {
148
- const Component = !isTV() ? AnimatedVideoPlayer : React.Fragment;
158
+ const {
159
+ videoModalState: { visible },
160
+ } = useNavigation();
161
+
162
+ const Component = !isTV() && visible ? AnimatedVideoPlayer : React.Fragment;
149
163
 
150
164
  return <Component>{children}</Component>;
151
165
  };