@applicaster/zapp-react-native-ui-components 14.0.0-alpha.3011001369 → 14.0.0-alpha.3065652724

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 (46) hide show
  1. package/Components/Cell/Cell.tsx +91 -64
  2. package/Components/Cell/CellWithFocusable.tsx +3 -0
  3. package/Components/FeedLoader/FeedLoader.tsx +1 -1
  4. package/Components/Focusable/Focusable.tsx +10 -3
  5. package/Components/Focusable/FocusableTvOS.tsx +2 -2
  6. package/Components/Focusable/Touchable.tsx +5 -3
  7. package/Components/Focusable/index.android.tsx +8 -4
  8. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  9. package/Components/FocusableList/FocusableItem.tsx +4 -3
  10. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  11. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  12. package/Components/FocusableList/index.tsx +16 -9
  13. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +9 -11
  14. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +0 -12
  15. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  16. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  17. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  18. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  19. package/Components/PlayerContainer/PlayerContainer.tsx +4 -1
  20. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -42
  21. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  22. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  23. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  24. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  25. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  26. package/Components/Screen/index.tsx +22 -5
  27. package/Components/Screen/navigationHandler.ts +20 -2
  28. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +2 -2
  29. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  30. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +12 -0
  31. package/Components/Tabs/TV/Tabs.android.tsx +1 -1
  32. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  33. package/Components/TextInputTv/index.tsx +11 -0
  34. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -1
  35. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
  36. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
  37. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +42 -22
  38. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  39. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  40. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  41. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  42. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  43. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  44. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  45. package/events/index.ts +2 -0
  46. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  import React from "react";
3
- import { View } from "react-native";
3
+ import { AccessibilityInfo, findNodeHandle, View } from "react-native";
4
4
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
5
 
6
6
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
@@ -12,6 +12,7 @@ import {
12
12
  } from "@applicaster/zapp-react-native-utils/navigationUtils";
13
13
  import {
14
14
  useCurrentScreenData,
15
+ useIsScreenActive,
15
16
  useNavbarState,
16
17
  useNavigation,
17
18
  useRoute,
@@ -57,8 +58,8 @@ export function Screen(_props: Props) {
57
58
  const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
58
59
 
59
60
  const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
60
- getNavBarProps(currentRiver, pathname, title),
61
- [currentRiver, pathname]
61
+ () => getNavBarProps(currentRiver, pathname, title),
62
+ [currentRiver, pathname, title]
62
63
  );
63
64
 
64
65
  const NavBar = React.useMemo(
@@ -89,13 +90,29 @@ export function Screen(_props: Props) {
89
90
  [theme.app_background_color, backgroundColor]
90
91
  );
91
92
 
92
- // Set ready state when screen is rotated to desired orientation
93
+ const isActive = useIsScreenActive();
94
+
95
+ const ref = React.useRef(null);
93
96
  const isReady = useWaitForValidOrientation();
94
97
 
98
+ React.useEffect(() => {
99
+ if (ref.current && isActive && isReady) {
100
+ const nodeHandle = findNodeHandle(ref.current);
101
+
102
+ if (nodeHandle != null) {
103
+ AccessibilityInfo.setAccessibilityFocus(nodeHandle);
104
+ }
105
+ }
106
+ }, [isActive, isReady]);
107
+
95
108
  // We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
96
109
  // This saves unnecessary re-renders and user will not see distorted aspect screen.
97
110
  return (
98
- <View style={style}>
111
+ <View
112
+ ref={ref}
113
+ style={style}
114
+ importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
115
+ >
99
116
  {isReady ? (
100
117
  <>
101
118
  {navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
@@ -1,3 +1,5 @@
1
+ import { resolveNavigationPlugin } from "@applicaster/zapp-react-native-utils/navigationUtils";
2
+
1
3
  /**
2
4
  * This function helps to decide wether the menu should be presented on the screen
3
5
  * based on route and / or screen Data
@@ -14,12 +16,28 @@
14
16
  * @param {Object} screenData payload associated with the currently presented screen
15
17
  * @returns {Boolean}
16
18
  */
17
- export function isMenuVisible(route, screenData) {
19
+ export function isMenuVisible(route, screenData, plugins) {
20
+ const plugin = resolveNavigationPlugin({
21
+ category: "menu",
22
+ navigations:
23
+ screenData?.navigations || screenData?.targetScreen?.navigations,
24
+ plugins,
25
+ });
26
+
27
+ const isBottomTabsPlugin = plugin?.identifier === "quick-brick-bottom-tabs";
28
+
29
+ if (!isBottomTabsPlugin) {
30
+ return false;
31
+ }
32
+
18
33
  if (route.includes("playable")) {
19
34
  return false;
20
35
  }
21
36
 
22
- if (screenData.type === "qb_search_screen") {
37
+ if (
38
+ screenData.type === "qb_search_screen" ||
39
+ screenData?.targetScreen?.type === "qb_search_screen"
40
+ ) {
23
41
  return false;
24
42
  }
25
43
 
@@ -19,9 +19,9 @@ describe("ScreenRevealManager", () => {
19
19
 
20
20
  const manager = new ScreenRevealManager(componentsToRender, mockCallback);
21
21
 
22
- expect(manager["numberOfComponentsWaitToLoadBeforePresent"]).toBe(3);
22
+ expect(manager.numberOfComponentsWaitToLoadBeforePresent).toBe(3);
23
23
 
24
- expect(manager["renderingState"]).toEqual([
24
+ expect(manager.renderingState).toEqual([
25
25
  COMPONENT_LOADING_STATE.UNKNOWN,
26
26
  COMPONENT_LOADING_STATE.UNKNOWN,
27
27
  COMPONENT_LOADING_STATE.UNKNOWN,
@@ -0,0 +1,23 @@
1
+ import { ReplaySubject } from "rxjs";
2
+ import { pairwise, filter, first } from "rxjs/operators";
3
+
4
+ // we are interested in last 2 events, because we wait transition from <false> to <true>
5
+ const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
6
+
7
+ export const emitScreenRevealManagerIsReadyToShow = () => {
8
+ screenRevealManagerSubject$.next(true);
9
+ };
10
+
11
+ export const emitScreenRevealManagerIsNotReadyToShow = () => {
12
+ screenRevealManagerSubject$.next(false);
13
+ };
14
+
15
+ export const waitUntilScreenRevealManagerIsReady = () => {
16
+ return screenRevealManagerSubject$.pipe(
17
+ pairwise(), // emit consecutive pairs: [prev, curr]
18
+ filter(
19
+ ([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady
20
+ ), // detect transition from not_ready to ready
21
+ first()
22
+ );
23
+ };
@@ -5,6 +5,10 @@ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils"
5
5
  import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
6
6
 
7
7
  import { ScreenRevealManager } from "./ScreenRevealManager";
8
+ import {
9
+ emitScreenRevealManagerIsReadyToShow,
10
+ emitScreenRevealManagerIsNotReadyToShow,
11
+ } from "./utils";
8
12
 
9
13
  const flex = platformSelect({
10
14
  tvos: 1,
@@ -43,6 +47,14 @@ export const withScreenRevealManager = (Component) => {
43
47
  () => new Animated.Value(HIDDEN)
44
48
  );
45
49
 
50
+ React.useEffect(() => {
51
+ if (!isReadyToShow) {
52
+ emitScreenRevealManagerIsNotReadyToShow();
53
+ } else {
54
+ emitScreenRevealManagerIsReadyToShow();
55
+ }
56
+ }, [isReadyToShow]);
57
+
46
58
  React.useEffect(() => {
47
59
  if (isReadyToShow) {
48
60
  Animated.timing(opacityRef.current, {
@@ -62,7 +62,7 @@ const TabsComponent = ({
62
62
  );
63
63
 
64
64
  const renderItem = useCallback(
65
- ({ item, index, focused }) => {
65
+ ({ item, index, focused }: { item: any; index: any; focused?: any }) => {
66
66
  const itemId = generateFocusableId(getId(item));
67
67
 
68
68
  const isSelected = R.equals(index, selectedEntryIndex);
@@ -2,6 +2,19 @@
2
2
 
3
3
  exports[`<TextInputTv /> renders 1`] = `
4
4
  <input
5
+ accessibilityProps={
6
+ {
7
+ "accessibilityHint": "Enter text into Search",
8
+ "accessibilityLabel": "Search",
9
+ "accessibilityRole": "searchbox",
10
+ "accessible": true,
11
+ "aria-description": "Enter text into Search",
12
+ "aria-label": "Search",
13
+ "aria-role": "searchbox",
14
+ "role": "searchbox",
15
+ "tabindex": 0,
16
+ }
17
+ }
5
18
  testID="TextInput-tv"
6
19
  />
7
20
  `;
@@ -4,6 +4,7 @@ import { Appearance, Platform, StyleSheet, TextInput } from "react-native";
4
4
  import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
5
5
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
6
6
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
7
+ import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
7
8
 
8
9
  type Props = Partial<{
9
10
  style: any;
@@ -42,6 +43,8 @@ function TextInputTV(props: Props, ref) {
42
43
  const [colorScheme, setColorScheme] = useState(getInitialColorScheme());
43
44
  const isRTL = useIsRTL();
44
45
 
46
+ const accessibilityManager = useAccessibilityManager({});
47
+
45
48
  const onColorChange = useCallback(
46
49
  ({ colorScheme: color }) => {
47
50
  if (color !== colorScheme) {
@@ -153,6 +156,13 @@ function TextInputTV(props: Props, ref) {
153
156
  ])
154
157
  )(props);
155
158
 
159
+ const getAccessibilityProps = () => {
160
+ return {
161
+ accessibilityProps:
162
+ accessibilityManager.getInputAccessibilityProps("Search"),
163
+ };
164
+ };
165
+
156
166
  const inputProps = {
157
167
  ...getProps(),
158
168
  ...getStyle(),
@@ -161,6 +171,7 @@ function TextInputTV(props: Props, ref) {
161
171
  ...getSecureTextEntry(),
162
172
  ...getOnEndEditing(),
163
173
  ...getOnPress(),
174
+ ...getAccessibilityProps(),
164
175
  };
165
176
 
166
177
  if (
@@ -42,6 +42,8 @@ type Props = {
42
42
  children: React.ReactNode;
43
43
  };
44
44
 
45
+ const activeOffsetY = [-5, 5] as [number, number];
46
+
45
47
  export const AnimatedScrollModalComponent = ({ children }: Props) => {
46
48
  const {
47
49
  isActiveGesture,
@@ -372,9 +374,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
372
374
  ref={panHandlerRef}
373
375
  simultaneousHandlers={[scrollRef, tapHandlerRef]}
374
376
  shouldCancelWhenOutside={isMaximizedModal}
377
+ activeOffsetY={activeOffsetY}
375
378
  onGestureEvent={onGestureEvent}
376
379
  onHandlerStateChange={onHandlerStateChange}
377
- activeOffsetY={[-5, 5]}
378
380
  >
379
381
  <Animated.View>
380
382
  <NativeViewGestureHandler
@@ -0,0 +1,294 @@
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
+ };
@@ -0,0 +1,93 @@
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
+ };