@applicaster/zapp-react-native-ui-components 14.0.0-alpha.5974411329 → 14.0.0-alpha.6000342231

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 (95) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/BaseFocusable/index.tsx +23 -12
  3. package/Components/Cell/Cell.tsx +91 -64
  4. package/Components/Cell/CellWithFocusable.tsx +3 -0
  5. package/Components/Cell/FocusableWrapper.tsx +44 -0
  6. package/Components/Cell/TvOSCellComponent.tsx +80 -14
  7. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  8. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  9. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  10. package/Components/FeedLoader/index.js +2 -8
  11. package/Components/Focusable/Focusable.tsx +10 -3
  12. package/Components/Focusable/FocusableTvOS.tsx +2 -2
  13. package/Components/Focusable/Touchable.tsx +5 -3
  14. package/Components/Focusable/index.android.tsx +8 -4
  15. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  16. package/Components/FocusableList/FocusableItem.tsx +4 -3
  17. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  18. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  19. package/Components/FocusableList/index.tsx +16 -9
  20. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  21. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +14 -17
  22. package/Components/HandlePlayable/HandlePlayable.tsx +14 -65
  23. package/Components/HandlePlayable/const.ts +3 -0
  24. package/Components/HandlePlayable/utils.ts +74 -0
  25. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  26. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  27. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +0 -12
  28. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  29. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  30. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  31. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  32. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  33. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  34. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  35. package/Components/MasterCell/utils/behaviorProvider.ts +2 -2
  36. package/Components/MasterCell/utils/index.ts +1 -19
  37. package/Components/OfflineHandler/__tests__/index.test.tsx +6 -13
  38. package/Components/PlayerContainer/PlayerContainer.tsx +5 -17
  39. package/Components/PlayerImageBackground/index.tsx +3 -22
  40. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -42
  41. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  42. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  43. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +0 -1
  44. package/Components/River/RefreshControl.tsx +11 -19
  45. package/Components/River/__tests__/river.test.js +12 -26
  46. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  47. package/Components/Screen/__tests__/Screen.test.tsx +5 -17
  48. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  49. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  50. package/Components/Screen/index.tsx +22 -5
  51. package/Components/Screen/navigationHandler.ts +20 -2
  52. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +2 -2
  53. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  54. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +54 -24
  55. package/Components/Tabs/TV/Tabs.android.tsx +1 -1
  56. package/Components/Tabs/Tabs.tsx +2 -3
  57. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  58. package/Components/TextInputTv/index.tsx +11 -0
  59. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  60. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  61. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +117 -157
  62. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  63. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  64. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  65. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  66. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  67. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  68. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  69. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  70. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  71. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  72. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  73. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  74. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  75. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  76. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  77. package/Contexts/ScreenContext/index.tsx +28 -32
  78. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  79. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  80. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  81. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  82. package/Decorators/RiverFeedLoader/index.tsx +21 -13
  83. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  84. package/Decorators/RiverFeedLoader/utils/index.ts +0 -35
  85. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +27 -27
  86. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +3 -5
  87. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +68 -76
  88. package/events/index.ts +3 -0
  89. package/package.json +5 -5
  90. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  91. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  92. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -421
  93. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  94. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  95. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
@@ -1,193 +1,153 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { Animated, Dimensions } from "react-native";
3
3
 
4
- import {
5
- useSafeAreaInsets,
6
- useSafeAreaFrame,
7
- } from "react-native-safe-area-context";
8
- import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useGetBottomTabBarHeight";
9
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
10
- import { isLive } from "@applicaster/zapp-react-native-utils/playerUtils";
11
5
 
12
- import { PROGRESS_BAR_HEIGHT } from "./utils";
13
6
  import { useConfiguration } from "../utils";
14
- import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
15
-
16
- export enum PlayerAnimationStateEnum {
17
- minimize = "minimize",
18
- maximize = "maximize",
19
- drag_player = "drag_player",
20
- drag_scroll = "drag_scroll",
21
- appear_as_docked = "appear_as_docked",
22
- }
7
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks/usePlugins";
8
+ import { isMenuVisible } from "../../Screen/navigationHandler";
23
9
 
24
- export type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
10
+ import {
11
+ useSafeAreaFrame,
12
+ useSafeAreaInsets,
13
+ } from "react-native-safe-area-context";
14
+ import {
15
+ isAndroidPlatform,
16
+ isAndroidVersionAtLeast,
17
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
18
+ import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
19
+ import { PROGRESS_BAR_HEIGHT } from "./utils";
20
+ import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
21
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux";
25
22
 
26
23
  export type ModalAnimationContextT = {
27
- yTranslate: React.MutableRefObject<Animated.Value | null>;
28
- isActiveGesture: boolean;
29
- playerAnimationState: PlayerAnimationStateT;
30
- setPlayerAnimationState: (value: PlayerAnimationStateT) => void;
31
- startComponentsAnimation: boolean;
32
- setStartComponentsAnimation: (value: boolean) => void;
33
- resetPlayerAnimationState: () => void;
24
+ yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
25
+ offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
26
+ offset: React.MutableRefObject<number>;
27
+ gestureTranslationRef: React.MutableRefObject<Animated.Value>;
34
28
  minimisedHeight: number;
35
- animatedValues: {
36
- lastScrollY: Animated.Value;
37
- dragScrollY: Animated.Value;
38
- dragVideoPlayerY: Animated.Value;
39
- translateYOffset: Animated.Value;
40
- };
41
- lastScrollYValue: React.MutableRefObject<number>;
42
- scrollPosition: React.MutableRefObject<number>;
43
- modalSnapPoints: number[];
44
- lastSnap: number;
45
- setLastSnap: (value: number) => void;
46
- tabletLandscapePlayerTopPosition: number;
47
- setTabletLandscapePlayerTopPosition: (value: number) => void;
48
- startComponentsAnimationDistance: number;
49
- progressBarHeight: number;
50
29
  };
51
30
 
52
31
  export const ReactContext = React.createContext<ModalAnimationContextT>({
53
32
  yTranslate: React.createRef<Animated.Value | null>(),
54
- isActiveGesture: false,
55
- playerAnimationState: null,
56
- setPlayerAnimationState: () => null,
57
- startComponentsAnimation: false,
58
- setStartComponentsAnimation: () => null,
59
- resetPlayerAnimationState: () => null,
33
+ offsetAnimatedValueRef: React.createRef<Animated.Value>(),
34
+ offset: React.createRef<number>(),
35
+ gestureTranslationRef: React.createRef<Animated.Value>(),
60
36
  minimisedHeight: 60,
61
- animatedValues: {
62
- lastScrollY: new Animated.Value(0),
63
- dragScrollY: new Animated.Value(0),
64
- dragVideoPlayerY: new Animated.Value(0),
65
- translateYOffset: new Animated.Value(0),
66
- },
67
- lastScrollYValue: null,
68
- scrollPosition: null,
69
- modalSnapPoints: [0, 0],
70
- lastSnap: 0,
71
- setLastSnap: () => null,
72
- tabletLandscapePlayerTopPosition: 0,
73
- setTabletLandscapePlayerTopPosition: () => null,
74
- startComponentsAnimationDistance: 0,
75
- progressBarHeight: 0,
76
37
  });
77
38
 
39
+ const SAFE_AREA_BREAKING_API_VERSION = 35;
40
+
41
+ export const isOldAndroidDevice =
42
+ isAndroidPlatform() &&
43
+ !isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
44
+
45
+ const bottomTabBarHeight = getTabBarHeight();
46
+
78
47
  const Provider = ({ children }: { children: React.ReactNode }) => {
48
+ const { height } = Dimensions.get("window");
49
+
79
50
  const yTranslate = React.useRef(
80
- new Animated.Value(Dimensions.get("window").height)
51
+ new Animated.Value(height).interpolate<number>({
52
+ inputRange: [0, height],
53
+ outputRange: [0, height],
54
+ })
81
55
  );
82
56
 
83
- const [playerAnimationState, setPlayerAnimationState] =
84
- React.useState<PlayerAnimationStateT>(null);
85
-
86
- const [
87
- tabletLandscapePlayerTopPosition,
88
- setTabletLandscapePlayerTopPosition,
89
- ] = React.useState<number>(0);
90
-
91
- const [startComponentsAnimation, setStartComponentsAnimation] =
92
- React.useState<boolean>(false);
57
+ const { minimised_height: minimisedHeight } = useConfiguration();
93
58
 
94
59
  const {
95
- videoModalState: { mode, visible, item },
60
+ videoModalState: { visible, mode },
61
+ currentRoute,
62
+ screenData,
96
63
  } = useNavigation();
97
64
 
98
- const isLiveItem = isLive(item);
99
- const { minimised_height: minimisedHeight } = useConfiguration();
65
+ const isTabletPortrait = useAppSelector(
66
+ (state) => state.appData.isTabletPortrait
67
+ );
100
68
 
101
- const resetPlayerAnimationState = React.useCallback(() => {
102
- setPlayerAnimationState(null);
103
- setStartComponentsAnimation(false);
104
- }, []);
105
-
106
- // Animated values
107
- const lastScrollY = React.useRef(new Animated.Value(0)).current;
108
- const dragScrollY = React.useRef(new Animated.Value(0)).current;
109
- const translateYOffset = React.useRef(new Animated.Value(0)).current;
110
- const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
111
-
112
- const { height: safeAreaFrameHeight } = useSafeAreaFrame();
113
- const [height, setHeight] = React.useState<number>(safeAreaFrameHeight);
114
- const progressBarHeight = isLiveItem ? 0 : PROGRESS_BAR_HEIGHT;
115
- const { bottom: bottomSafeArea } = useSafeAreaInsets();
116
- const bottomTabBarHeight = useGetBottomTabBarHeight();
117
- const startComponentsAnimationDistance = Math.round((height * 60) / 100);
118
- const isTabletLandscape = useIsTabletLandscape();
119
- const windowDimensions = Dimensions.get("window");
120
-
121
- useEffect(() => {
122
- // Reset player animation state when video modal is closed
123
- if (!visible) {
124
- resetPlayerAnimationState();
125
-
126
- if (!isTabletLandscape) {
127
- // restore to portrait ( in portrait mode height is bigger)
128
- if (windowDimensions.height > windowDimensions.width) {
129
- yTranslate.current?.setValue(windowDimensions.height);
130
- }
131
- } else {
132
- yTranslate.current?.setValue(windowDimensions.height);
133
- }
134
- }
135
- }, [
136
- visible,
137
- resetPlayerAnimationState,
138
- windowDimensions.height,
139
- isTabletLandscape,
140
- ]);
69
+ const plugins = usePlugins();
70
+
71
+ const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
72
+
73
+ const frame = useSafeAreaFrame();
74
+ const insets = useSafeAreaInsets();
75
+
76
+ const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
77
+
78
+ // memoizing heightAboveMinimised value
79
+ const offset = React.useRef(heightAboveMinimised);
80
+
81
+ // Used for memoizing modal y position after start/end of transition
82
+ const offsetAnimatedValueRef = React.useRef(
83
+ new Animated.Value(-offset.current)
84
+ );
85
+
86
+ // Used for gesture handling
87
+ const gestureTranslationRef = React.useRef(new Animated.Value(0));
88
+
89
+ const videoModalStateRef = React.useRef({ visible, mode });
141
90
 
142
91
  React.useEffect(() => {
143
- if (visible && mode === "MAXIMIZED" && height !== safeAreaFrameHeight) {
144
- setHeight(safeAreaFrameHeight);
145
- }
146
- }, [height, safeAreaFrameHeight, mode, visible]);
92
+ videoModalStateRef.current = { visible, mode };
93
+ }, [visible, mode]);
147
94
 
148
- /*
149
- If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
150
- Because of this we need to minus bottom SafeArea offset.
151
- */
95
+ const translateY = useMemo(() => {
96
+ const maxRange = heightAboveMinimised;
152
97
 
153
- const minValue =
154
- height -
155
- (minimisedHeight + bottomTabBarHeight + progressBarHeight + bottomSafeArea);
98
+ const combined: Animated.AnimatedAddition<number> = Animated.add(
99
+ offsetAnimatedValueRef.current,
100
+ gestureTranslationRef.current
101
+ );
102
+
103
+ return combined.interpolate({
104
+ inputRange: [0, maxRange],
105
+ outputRange: [0, maxRange],
106
+ extrapolate: "clamp",
107
+ });
108
+ }, [visible, heightAboveMinimised]);
109
+
110
+ offset.current = heightAboveMinimised;
111
+ yTranslate.current = translateY;
112
+
113
+ React.useEffect(() => {
114
+ const collapsedHeight =
115
+ minimisedHeight +
116
+ (menuVisible ? bottomTabBarHeight : 0) +
117
+ (isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
118
+ PROGRESS_BAR_HEIGHT;
156
119
 
157
- const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
158
- // Last snap state which will helps us to make smooth responder to scrollview animation
159
- const [lastSnap, setLastSnap] = React.useState<number>(modalSnapPoints[0]);
160
- // Extracted animated values which we will use for calculations
161
- const lastScrollYValue = React.useRef<number>(0);
162
- const scrollPosition = React.useRef<number>(0);
120
+ const heightAboveMinimised = frame.height - collapsedHeight;
121
+
122
+ const isLandscape = frame.width > frame.height;
123
+
124
+ const isTablet = getIsTablet();
125
+
126
+ const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
127
+
128
+ if (
129
+ heightAboveMinimised !== offset.current &&
130
+ videoModalStateRef.current.mode !== "PIP" &&
131
+ videoModalStateRef.current.mode !== "FULLSCREEN"
132
+ ) {
133
+ if (isLandscape && shouldIgnoreLandscape) return;
134
+ setHeightAboveMinimised(heightAboveMinimised);
135
+ offset.current = heightAboveMinimised;
136
+ }
137
+ }, [frame.height, insets.bottom, menuVisible, minimisedHeight]);
163
138
 
164
139
  return (
165
140
  <ReactContext.Provider
166
- value={{
167
- yTranslate,
168
- startComponentsAnimation,
169
- setStartComponentsAnimation,
170
- isActiveGesture: playerAnimationState !== null,
171
- playerAnimationState,
172
- setPlayerAnimationState,
173
- resetPlayerAnimationState,
174
- minimisedHeight,
175
- animatedValues: {
176
- lastScrollY,
177
- dragScrollY,
178
- dragVideoPlayerY,
179
- translateYOffset,
180
- },
181
- lastScrollYValue,
182
- scrollPosition,
183
- modalSnapPoints,
184
- lastSnap,
185
- setLastSnap,
186
- tabletLandscapePlayerTopPosition,
187
- setTabletLandscapePlayerTopPosition,
188
- startComponentsAnimationDistance,
189
- progressBarHeight,
190
- }}
141
+ value={useMemo(
142
+ () => ({
143
+ yTranslate,
144
+ offsetAnimatedValueRef,
145
+ offset,
146
+ minimisedHeight,
147
+ gestureTranslationRef,
148
+ }),
149
+ [minimisedHeight]
150
+ )}
191
151
  >
192
152
  {children}
193
153
  </ReactContext.Provider>
@@ -1,18 +1,7 @@
1
- export { AnimatedPlayerModalWrapper } from "./AnimatedPlayerModalWrapper";
2
-
3
- export { AnimatedScrollModal } from "./AnimatedScrollModal";
4
-
5
- export { AnimatedVideoPlayerComponent } from "./AnimatedVideoPlayerComponent";
6
-
7
- export {
8
- withModalAnimationProvider,
9
- PlayerAnimationStateEnum,
10
- } from "./ModalAnimationContext";
1
+ export { withModalAnimationProvider } from "./ModalAnimationContext";
11
2
 
12
3
  export { useModalAnimationContext } from "./useModalAnimationContext";
13
4
 
14
- export { AnimationComponent } from "./AnimationComponent";
15
-
16
- export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
5
+ export { defaultAspectRatioWidth } from "./utils";
17
6
 
18
7
  export { DURATION_TO_MINIMIZE, DURATION_TO_MAXIMIZE } from "./const";
@@ -1,332 +1,6 @@
1
- /* eslint-disable padding-line-between-statements */
2
-
3
- import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
4
- import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
5
-
6
- export enum ComponentAnimationType {
7
- bottomBar = "bottomBar",
8
- player = "player",
9
- componentFade = "componentFade",
10
- componentAppears = "componentAppears",
11
- moveUpComponent = "moveUpComponent",
12
- moveComponentHorizontal = "moveComponentHorizontal",
13
- audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
14
- }
15
-
16
1
  export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
2
+
17
3
  export const PROGRESS_BAR_HEIGHT = 3;
18
4
 
19
5
  export const defaultAspectRatioWidth = (height: number): number =>
20
6
  (height / 9) * 16;
21
-
22
- export const getAnimationStyle = (component, animatedValue) => {
23
- switch (component) {
24
- case ComponentAnimationType.bottomBar: {
25
- return { zIndex: 99, transform: [{ translateY: animatedValue }] };
26
- }
27
-
28
- case ComponentAnimationType.player: {
29
- return { width: animatedValue.x, height: animatedValue.y };
30
- }
31
-
32
- case ComponentAnimationType.componentFade:
33
- case ComponentAnimationType.componentAppears: {
34
- return { opacity: animatedValue };
35
- }
36
-
37
- case ComponentAnimationType.moveUpComponent: {
38
- return { transform: [{ translateY: animatedValue }] };
39
- }
40
-
41
- case ComponentAnimationType.audioPlayerPaddingHorizontal:
42
- case ComponentAnimationType.moveComponentHorizontal: {
43
- return { transform: [{ translateX: animatedValue }] };
44
- }
45
-
46
- default:
47
- return null;
48
- }
49
- };
50
-
51
- export const getAnimationDefaultValue = (component, bottomTabBarHeight) => {
52
- switch (component) {
53
- case ComponentAnimationType.bottomBar: {
54
- return bottomTabBarHeight;
55
- }
56
-
57
- case ComponentAnimationType.player: {
58
- return { x: 0, y: 0 };
59
- }
60
-
61
- case ComponentAnimationType.componentFade: {
62
- return 1;
63
- }
64
-
65
- case ComponentAnimationType.audioPlayerPaddingHorizontal:
66
- case ComponentAnimationType.moveComponentHorizontal:
67
- case ComponentAnimationType.componentAppears:
68
- case ComponentAnimationType.moveUpComponent: {
69
- return 0;
70
- }
71
- }
72
- };
73
-
74
- export const calculateAnimationValue = (animationType, dragPosition, data) => {
75
- const {
76
- isAudioItem,
77
- bottomTabBarHeight,
78
- minimisedHeight,
79
- minimisedWidth,
80
- defaultValue,
81
- moveUpValue,
82
- moveComponentHorizontalValue,
83
- isTablet,
84
- isTabletLandscape,
85
- isRTL,
86
- fromMiniPlayer,
87
- inlineAudioPlayer,
88
- } = data;
89
-
90
- switch (animationType) {
91
- case ComponentAnimationType.bottomBar: {
92
- if (fromMiniPlayer) {
93
- return dragPosition < bottomTabBarHeight
94
- ? dragPosition
95
- : bottomTabBarHeight;
96
- }
97
-
98
- return dragPosition < bottomTabBarHeight
99
- ? bottomTabBarHeight - dragPosition
100
- : 0;
101
- }
102
-
103
- case ComponentAnimationType.player: {
104
- const value =
105
- isAudioItem && !inlineAudioPlayer
106
- ? isTabletLandscape
107
- ? fromMiniPlayer
108
- ? { forWidth: 4, forHeight: 4.5 }
109
- : { forWidth: 3, forHeight: 3 }
110
- : { forWidth: 2, forHeight: 2 }
111
- : isTabletLandscape
112
- ? { forWidth: 8, forHeight: 6.5 }
113
- : { forWidth: 3.5, forHeight: 2 };
114
-
115
- const minWidth =
116
- isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
117
-
118
- if (fromMiniPlayer) {
119
- const calculationWidth =
120
- dragPosition * value.forWidth < minWidth
121
- ? minWidth
122
- : dragPosition * value.forWidth;
123
- const calculationHeight =
124
- dragPosition * value.forHeight < minimisedHeight
125
- ? minimisedHeight
126
- : dragPosition * value.forHeight;
127
-
128
- return {
129
- x:
130
- calculationWidth < defaultValue.x
131
- ? calculationWidth
132
- : defaultValue.x,
133
- y:
134
- calculationHeight < defaultValue.y
135
- ? calculationHeight
136
- : defaultValue.y,
137
- };
138
- }
139
-
140
- const calculationWidth = defaultValue.x - dragPosition * value.forWidth;
141
-
142
- const calculationHeight = defaultValue.y - dragPosition * value.forHeight;
143
-
144
- return {
145
- x: calculationWidth > minWidth ? calculationWidth : minWidth,
146
- y:
147
- calculationHeight > minimisedHeight
148
- ? calculationHeight
149
- : minimisedHeight,
150
- };
151
- }
152
-
153
- case ComponentAnimationType.componentFade: {
154
- if (fromMiniPlayer) {
155
- const calculation = dragPosition / (isTablet ? 200 : 150);
156
-
157
- return calculation < 1 ? calculation : 1;
158
- }
159
-
160
- const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
161
-
162
- return calculation > 0 ? calculation : 0;
163
- }
164
-
165
- case ComponentAnimationType.componentAppears: {
166
- if (fromMiniPlayer) {
167
- const calculation = 1 - dragPosition / (isTablet ? 200 : 150);
168
-
169
- return calculation > 0 ? calculation : 0;
170
- }
171
-
172
- const calculation = dragPosition / (isTablet ? 200 : 150);
173
-
174
- return calculation < 1 ? calculation : 1;
175
- }
176
-
177
- case ComponentAnimationType.moveUpComponent: {
178
- if (fromMiniPlayer) {
179
- const calculation =
180
- moveUpValue + dragPosition / (isTabletLandscape ? 1 : 4);
181
-
182
- return calculation < 0 ? calculation : 0;
183
- }
184
-
185
- const calculation = 0 - dragPosition / (isTabletLandscape ? 1 : 2);
186
-
187
- return calculation > moveUpValue ? calculation : moveUpValue;
188
- }
189
-
190
- case ComponentAnimationType.moveComponentHorizontal: {
191
- if (fromMiniPlayer) {
192
- const calculation = isRTL
193
- ? moveComponentHorizontalValue - dragPosition * 2
194
- : moveComponentHorizontalValue + dragPosition * 2;
195
- const condition = isRTL ? calculation > 0 : calculation < 0;
196
-
197
- return condition ? calculation : 0;
198
- }
199
-
200
- const calculation = isRTL ? dragPosition * 2 : -(dragPosition * 2);
201
- const condition = isRTL
202
- ? calculation < moveComponentHorizontalValue
203
- : calculation > moveComponentHorizontalValue;
204
-
205
- return condition ? calculation : moveComponentHorizontalValue;
206
- }
207
-
208
- case ComponentAnimationType.audioPlayerPaddingHorizontal: {
209
- const padding = isRTL
210
- ? AUDIO_PLAYER_HORIZONTAL_PADDING
211
- : -AUDIO_PLAYER_HORIZONTAL_PADDING;
212
-
213
- if (fromMiniPlayer) {
214
- const calculation = isRTL
215
- ? padding - dragPosition / 5
216
- : padding + dragPosition / 5;
217
- const condition = isRTL ? calculation > 0 : calculation < 0;
218
-
219
- return condition ? calculation : 0;
220
- }
221
-
222
- const calculation = isRTL ? dragPosition / 5 : -(dragPosition / 5);
223
- const condition = isRTL ? calculation < padding : calculation > padding;
224
-
225
- return condition ? calculation : padding;
226
- }
227
- }
228
- };
229
-
230
- export const gestureListenerHelper = (data) => {
231
- const {
232
- listenerValue,
233
- preparedValue,
234
- animationType,
235
- animatedValue,
236
- calculationData,
237
- modalSnapPoint,
238
- startComponentsAnimationDistance,
239
- startComponentsAnimation,
240
- setStartComponentsAnimation,
241
- getAnimationValue,
242
- } = data;
243
-
244
- if (calculationData.fromMiniPlayer) {
245
- if (listenerValue <= 0) {
246
- if (
247
- preparedValue >= 0 &&
248
- preparedValue <= modalSnapPoint - startComponentsAnimationDistance
249
- ) {
250
- !startComponentsAnimation && setStartComponentsAnimation(true);
251
-
252
- animatedValue.setValue(
253
- calculateAnimationValue(animationType, preparedValue, calculationData)
254
- );
255
- } else {
256
- animatedValue.setValue(calculationData.defaultValue);
257
- startComponentsAnimation && setStartComponentsAnimation(false);
258
- }
259
- } else {
260
- const value = getAnimationValue(
261
- animationType,
262
- PlayerAnimationStateEnum.minimize
263
- ).toValue;
264
-
265
- animatedValue.setValue(value);
266
- }
267
- } else {
268
- if (preparedValue >= startComponentsAnimationDistance) {
269
- !startComponentsAnimation && setStartComponentsAnimation(true);
270
- const value = Math.round(
271
- preparedValue - startComponentsAnimationDistance
272
- );
273
-
274
- animatedValue.setValue(
275
- calculateAnimationValue(animationType, value, calculationData)
276
- );
277
- } else {
278
- animatedValue.setValue(calculationData.defaultValue);
279
- startComponentsAnimation && setStartComponentsAnimation(false);
280
- }
281
- }
282
- };
283
-
284
- export const setScrollModalAnimatedValue = (
285
- animatedValue,
286
- value,
287
- setLastSnap
288
- ) => {
289
- setLastSnap(value);
290
- animatedValue.setValue(value);
291
- };
292
-
293
- export const resetScrollAnimatedValues = (
294
- lastScrollY,
295
- lastScrollYValue,
296
- dragScrollY,
297
- dragVideoPlayerY
298
- ) => {
299
- lastScrollY.setValue(0);
300
- lastScrollYValue.current = 0;
301
- dragScrollY.setValue(0);
302
- dragVideoPlayerY.setValue(0);
303
- };
304
-
305
- export const getMoveUpValue = ({
306
- additionalData,
307
- insets,
308
- isAudioItem,
309
- progressBarHeight,
310
- isTablet,
311
- isTabletLandscape,
312
- tabletLandscapePlayerTopPosition,
313
- }) => {
314
- if (additionalData.saveArea) {
315
- return -insets.top + (isAudioItem ? 0 : progressBarHeight);
316
- }
317
-
318
- if (isAudioItem) {
319
- // for any layouts in audioPlayer
320
- return -1 * toNumberWithDefaultZero(additionalData?.marginTop);
321
- }
322
-
323
- if (isTablet) {
324
- if (isTabletLandscape) {
325
- return -tabletLandscapePlayerTopPosition + progressBarHeight;
326
- } else {
327
- return -130;
328
- }
329
- }
330
-
331
- return -50 + progressBarHeight;
332
- };
@@ -4,8 +4,8 @@ import {
4
4
  Dimensions,
5
5
  Easing,
6
6
  StyleProp,
7
- ViewStyle,
8
7
  StyleSheet,
8
+ ViewStyle,
9
9
  } from "react-native";
10
10
  import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
11
11
  import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
@@ -69,11 +69,10 @@ export const PlayerDetails = ({
69
69
  const screenData = useTargetScreenData(entry);
70
70
  const insets = useSafeAreaInsets();
71
71
 
72
- const extraTabletStyles = !isAudioPlayer
73
- ? isTabletLandscape
72
+ const extraTabletStyles =
73
+ !isAudioPlayer && isTabletLandscape
74
74
  ? { marginTop: -insets.top, paddingTop: insets.top + 20 }
75
- : { marginTop: -8, paddingTop: -8 }
76
- : {};
75
+ : null;
77
76
 
78
77
  // Animation setup
79
78
  const translateY = useRef(new Animated.Value(50)).current;
@@ -129,6 +128,7 @@ export const PlayerDetails = ({
129
128
  riverId={screenData.id}
130
129
  feed={screenData?.data?.source}
131
130
  riverComponents={screenData.ui_components}
131
+ isScreenWrappedInContainer
132
132
  />
133
133
  ) : null}
134
134
  </Animated.View>