@applicaster/zapp-react-native-ui-components 13.0.0-alpha.2807014304 → 13.0.0-alpha.2886020207

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 (45) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +0 -4
  2. package/Components/AudioPlayer/helpers.tsx +0 -1
  3. package/Components/Cell/CellWithFocusable.tsx +4 -2
  4. package/Components/Cell/CellWrapper.tsx +18 -0
  5. package/Components/CellRendererResolver/index.ts +2 -1
  6. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
  7. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +4 -2
  8. package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
  9. package/Components/HandlePlayable/HandlePlayable.tsx +10 -3
  10. package/Components/Layout/TV/LayoutBackground.tsx +28 -0
  11. package/Components/Layout/TV/ScreenContainer.tsx +0 -1
  12. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
  13. package/Components/Layout/TV/__tests__/index.test.tsx +8 -2
  14. package/Components/Layout/TV/index.tsx +6 -20
  15. package/Components/Layout/TV/index.web.tsx +4 -1
  16. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
  17. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
  18. package/Components/ModalComponent/BottomSheetModalContent.tsx +59 -43
  19. package/Components/ModalComponent/Button/Item.tsx +6 -5
  20. package/Components/ModalComponent/Button/index.tsx +45 -62
  21. package/Components/ModalComponent/Header/index.tsx +9 -8
  22. package/Components/ModalComponent/utils.ts +55 -7
  23. package/Components/PlayerContainer/PlayerContainer.tsx +25 -2
  24. package/Components/River/ComponentsMap/ComponentsMap.tsx +11 -3
  25. package/Components/River/RiverItem.tsx +8 -3
  26. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +7 -1
  27. package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
  28. package/Components/Screen/__tests__/Screen.test.tsx +22 -14
  29. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -2
  30. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
  31. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +4 -2
  32. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +21 -10
  33. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +8 -1
  34. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  35. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  36. package/Components/VideoModal/ModalAnimation/index.ts +2 -0
  37. package/Components/VideoModal/ModalAnimation/utils.ts +30 -0
  38. package/Components/VideoModal/PlayerDetails.tsx +9 -4
  39. package/Components/VideoModal/PlayerWrapper.tsx +35 -22
  40. package/Components/VideoModal/VideoModal.tsx +19 -4
  41. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
  42. package/Components/VideoModal/utils.ts +3 -4
  43. package/Components/ZappUIComponent/index.tsx +4 -4
  44. package/package.json +5 -5
  45. package/Components/Cell/CellWrapper.ts +0 -5
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
2
  import { Animated } from "react-native";
3
3
 
4
4
  import {
@@ -95,6 +95,13 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
95
95
  setStartComponentsAnimation(false);
96
96
  }, []);
97
97
 
98
+ useEffect(() => {
99
+ // Reset player animation state when video modal is closed
100
+ if (!visible) {
101
+ resetPlayerAnimationState();
102
+ }
103
+ }, [visible, resetPlayerAnimationState]);
104
+
98
105
  // Animated values
99
106
  const lastScrollY = React.useRef(new Animated.Value(0)).current;
100
107
  const dragScrollY = React.useRef(new Animated.Value(0)).current;
@@ -0,0 +1,108 @@
1
+ import { getMoveUpValue } from "../utils";
2
+
3
+ describe("getMoveUpValue", () => {
4
+ it("returns correct value when additionalData.saveArea is true and isAudioItem is false", () => {
5
+ const result = getMoveUpValue({
6
+ additionalData: { saveArea: true },
7
+ insets: { top: 20 },
8
+ isAudioItem: false,
9
+ progressBarHeight: 10,
10
+ isTablet: false,
11
+ isTabletLandscape: false,
12
+ inlineAudioPlayer: false,
13
+ tabletLandscapePlayerTopPosition: 100,
14
+ });
15
+
16
+ expect(result).toBe(-20 + 10);
17
+ });
18
+
19
+ it("returns correct value when additionalData.saveArea is true and isAudioItem is true", () => {
20
+ const result = getMoveUpValue({
21
+ additionalData: { saveArea: true },
22
+ insets: { top: 15 },
23
+ isAudioItem: true,
24
+ progressBarHeight: 5,
25
+ isTablet: false,
26
+ isTabletLandscape: false,
27
+ inlineAudioPlayer: false,
28
+ tabletLandscapePlayerTopPosition: 100,
29
+ });
30
+
31
+ expect(result).toBe(-15 + 0);
32
+ });
33
+
34
+ it("returns correct value for audio item (tablet or not)", () => {
35
+ const result = getMoveUpValue({
36
+ additionalData: { marginTop: 30 },
37
+ insets: { top: 0 },
38
+ isAudioItem: true,
39
+ progressBarHeight: 0,
40
+ isTablet: false,
41
+ isTabletLandscape: false,
42
+ inlineAudioPlayer: false,
43
+ tabletLandscapePlayerTopPosition: 0,
44
+ });
45
+
46
+ expect(result).toBe(-30);
47
+ });
48
+
49
+ it("returns correct value for tablet landscape with inline audio player", () => {
50
+ const result = getMoveUpValue({
51
+ additionalData: {},
52
+ insets: { top: 0 },
53
+ isAudioItem: true,
54
+ progressBarHeight: 8,
55
+ isTablet: true,
56
+ isTabletLandscape: true,
57
+ inlineAudioPlayer: true,
58
+ tabletLandscapePlayerTopPosition: 50,
59
+ });
60
+
61
+ expect(result).toBe(-0);
62
+ });
63
+
64
+ it("returns correct value for tablet landscape without audio item", () => {
65
+ const result = getMoveUpValue({
66
+ additionalData: {},
67
+ insets: { top: 0 },
68
+ isAudioItem: false,
69
+ progressBarHeight: 12,
70
+ isTablet: true,
71
+ isTabletLandscape: true,
72
+ inlineAudioPlayer: false,
73
+ tabletLandscapePlayerTopPosition: 60,
74
+ });
75
+
76
+ expect(result).toBe(-60 + 12);
77
+ });
78
+
79
+ it("returns -130 for tablet portrait (not landscape)", () => {
80
+ const result = getMoveUpValue({
81
+ additionalData: {},
82
+ insets: { top: 0 },
83
+ isAudioItem: false,
84
+ progressBarHeight: 0,
85
+ isTablet: true,
86
+ isTabletLandscape: false,
87
+ inlineAudioPlayer: false,
88
+ tabletLandscapePlayerTopPosition: 0,
89
+ });
90
+
91
+ expect(result).toBe(-130);
92
+ });
93
+
94
+ it("returns -50 + progressBarHeight for mobile audio player in docked mode", () => {
95
+ const result = getMoveUpValue({
96
+ additionalData: {},
97
+ insets: { top: 0 },
98
+ isAudioItem: false,
99
+ progressBarHeight: 7,
100
+ isTablet: false,
101
+ isTabletLandscape: false,
102
+ inlineAudioPlayer: false,
103
+ tabletLandscapePlayerTopPosition: 0,
104
+ });
105
+
106
+ expect(result).toBe(-50 + 7);
107
+ });
108
+ });
@@ -0,0 +1,5 @@
1
+ export const DURATION_TO_MINIMIZE = 200; // old value 200
2
+
3
+ export const DURATION_TO_MAXIMIZE = 0;
4
+
5
+ export const DEFAULT_DURATION_FOR_ANIMATION = 200; // old value 100
@@ -14,3 +14,5 @@ export { useModalAnimationContext } from "./useModalAnimationContext";
14
14
  export { AnimationComponent } from "./AnimationComponent";
15
15
 
16
16
  export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
17
+
18
+ export { DURATION_TO_MINIMIZE, DURATION_TO_MAXIMIZE } from "./const";
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable padding-line-between-statements */
2
2
 
3
3
  import { PlayerAnimationStateEnum } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
4
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
4
5
 
5
6
  export enum ComponentAnimationType {
6
7
  bottomBar = "bottomBar",
@@ -300,3 +301,32 @@ export const resetScrollAnimatedValues = (
300
301
  dragScrollY.setValue(0);
301
302
  dragVideoPlayerY.setValue(0);
302
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
+ };
@@ -10,6 +10,7 @@ import {
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";
12
12
  import { useSafeAreaInsets } from "react-native-safe-area-context";
13
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
13
14
 
14
15
  const { width: SCREEN_WIDTH } = Dimensions.get("screen");
15
16
 
@@ -22,9 +23,9 @@ type Props = {
22
23
  entry: ZappEntry;
23
24
  style: StyleProp<ViewStyle>;
24
25
  configuration: Configuration;
25
- isTabletLandscape: boolean;
26
+ isTabletLandscape?: boolean;
26
27
  isAudioPlayer?: boolean;
27
- isTablet: boolean;
28
+ isTablet?: boolean;
28
29
  };
29
30
 
30
31
  const containerStyle = ({
@@ -39,9 +40,9 @@ export const PlayerDetails = ({
39
40
  entry,
40
41
  style,
41
42
  configuration,
42
- isTabletLandscape,
43
+ isTabletLandscape = false,
43
44
  isAudioPlayer,
44
- isTablet,
45
+ isTablet = false,
45
46
  }: Props) => {
46
47
  const screenData = useTargetScreenData(entry);
47
48
  const insets = useSafeAreaInsets();
@@ -78,6 +79,10 @@ export const PlayerDetails = ({
78
79
  }
79
80
  }, [isAudioPlayer]);
80
81
 
82
+ if (isNilOrEmpty(screenData?.ui_components)) {
83
+ return null;
84
+ }
85
+
81
86
  return (
82
87
  <Animated.View
83
88
  style={[
@@ -74,20 +74,6 @@ const getScreenAspectRatio = () => {
74
74
  return longEdge / shortEdge;
75
75
  };
76
76
 
77
- const safeAreaStyles = (
78
- configuration: Configuration,
79
- isTablet: boolean
80
- ): ViewStyle => {
81
- const tablet_landscape_player_container_background_color =
82
- configuration?.tablet_landscape_player_container_background_color;
83
-
84
- return {
85
- backgroundColor: isTablet
86
- ? tablet_landscape_player_container_background_color
87
- : "transparent",
88
- };
89
- };
90
-
91
77
  const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
92
78
  if (isTablet) {
93
79
  return ["top"];
@@ -100,6 +86,24 @@ const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
100
86
  return ["top"];
101
87
  };
102
88
 
89
+ const isPercentage = (value: string | number): boolean => {
90
+ if (typeof value === "string") {
91
+ return value.includes("%");
92
+ }
93
+
94
+ return false;
95
+ };
96
+
97
+ const getPercentageOf = (percent: string, value: number) => {
98
+ const percentageValue = parseFloat(percent.replace("%", ""));
99
+
100
+ if (isNaN(percentageValue)) {
101
+ return value;
102
+ }
103
+
104
+ return (value * percentageValue) / 100;
105
+ };
106
+
103
107
  const getTabletWidth = (
104
108
  configuration: Configuration,
105
109
  dimensions: DimensionsT
@@ -108,18 +112,23 @@ const getTabletWidth = (
108
112
  configuration?.tablet_landscape_sidebar_width;
109
113
 
110
114
  const { width } = dimensions;
115
+ let widthValue = Number(width);
116
+
117
+ if (isPercentage(width)) {
118
+ widthValue = getPercentageOf(width.toString(), SCREEN_WIDTH);
119
+ }
111
120
 
112
121
  const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
113
122
 
114
123
  if (tablet_landscape_sidebar_width?.includes("%")) {
115
- return Number(width) * (1 - sidebarWidth / 100);
124
+ return widthValue * (1 - sidebarWidth / 100);
116
125
  }
117
126
 
118
127
  if (Number.isNaN(sidebarWidth)) {
119
- return Number(width) * 0.65;
128
+ return widthValue * 0.65;
120
129
  }
121
130
 
122
- return Number(width) - sidebarWidth;
131
+ return widthValue - sidebarWidth;
123
132
  };
124
133
 
125
134
  const PlayerWrapperComponent = (props: Props) => {
@@ -133,6 +142,7 @@ const PlayerWrapperComponent = (props: Props) => {
133
142
  children,
134
143
  isTabletPortrait,
135
144
  configuration,
145
+ fullscreen,
136
146
  pip,
137
147
  } = props;
138
148
 
@@ -188,14 +198,17 @@ const PlayerWrapperComponent = (props: Props) => {
188
198
  [containerDimensions, playerDimensionsHack]
189
199
  );
190
200
 
201
+ const wrapperViewStyle: ViewStyle = {
202
+ backgroundColor:
203
+ isTablet && !fullscreen
204
+ ? configuration?.tablet_landscape_player_container_background_color
205
+ : "transparent",
206
+ };
207
+
191
208
  return (
192
209
  <WrapperView
193
210
  edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
194
- style={[
195
- safeAreaStyles(configuration, isTablet),
196
- style,
197
- playerDimensionsHack,
198
- ]}
211
+ style={[wrapperViewStyle, style, playerDimensionsHack]}
199
212
  >
200
213
  <AnimationComponent
201
214
  animationType={ComponentAnimationType.moveUpComponent}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { equals } from "ramda";
3
- import { StyleSheet, StatusBar } from "react-native";
3
+ import { StyleSheet, StatusBar, View } from "react-native";
4
4
 
5
5
  import { HandlePlayable } from "@applicaster/zapp-react-native-ui-components/Components/HandlePlayable";
6
6
  import {
@@ -30,10 +30,13 @@ import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHook
30
30
  import { requiresAuthentication } from "@applicaster/zapp-react-native-utils/configurationUtils";
31
31
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
32
32
  import { ScreenContextProvider } from "../../Contexts/ScreenContext";
33
+ import { Spinner } from "../Spinner";
33
34
  import { OpaqueLayer } from "./OpaqueLayer";
34
35
 
35
36
  import { AnimatedPlayerModalWrapper } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
36
37
 
38
+ const LOADER_BACKGROUND_COLOR = "rgba(64,64,64,0.5)";
39
+
37
40
  const styles = StyleSheet.create({
38
41
  container: {
39
42
  top: 0,
@@ -42,6 +45,16 @@ const styles = StyleSheet.create({
42
45
  bottom: 0,
43
46
  position: "absolute",
44
47
  },
48
+ loaderContainer: {
49
+ top: 0,
50
+ left: 0,
51
+ right: 0,
52
+ bottom: 0,
53
+ position: "absolute",
54
+ alignItems: "center",
55
+ justifyContent: "center",
56
+ backgroundColor: LOADER_BACKGROUND_COLOR,
57
+ },
45
58
  });
46
59
 
47
60
  const VideoModalComponent = () => {
@@ -131,14 +144,12 @@ const VideoModalComponent = () => {
131
144
  {/* Hide content underneath when we switch to next video in fullscreen mode */}
132
145
  {mode === "FULLSCREEN" && <OpaqueLayer />}
133
146
 
134
- {itemIdHooksFinished === item?.id && (
147
+ {itemIdHooksFinished === item?.id ? (
135
148
  <AnimatedPlayerModalWrapper
136
149
  style={[
137
150
  styles.container,
138
151
  {
139
152
  backgroundColor,
140
- width: modalSize.width,
141
- height: modalSize.height,
142
153
  },
143
154
  ]}
144
155
  >
@@ -148,6 +159,10 @@ const VideoModalComponent = () => {
148
159
  mode={mode}
149
160
  />
150
161
  </AnimatedPlayerModalWrapper>
162
+ ) : (
163
+ <View style={styles.loaderContainer}>
164
+ <Spinner />
165
+ </View>
151
166
  )}
152
167
  </ScreenContextProvider>
153
168
  </PathnameContext.Provider>
@@ -1,43 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`PlayerDetails renders properly 1`] = `
4
- <View
5
- collapsable={false}
6
- style={
7
- {
8
- "backgroundColor": "transparent",
9
- "flex": 1,
10
- "marginTop": -8,
11
- "paddingTop": -8,
12
- "width": 750,
13
- }
14
- }
15
- >
16
- <View
17
- feed="test-source"
18
- riverComponents={[]}
19
- riverId="test-id"
20
- />
21
- </View>
22
- `;
3
+ exports[`PlayerDetails renders properly 1`] = `null`;
23
4
 
24
- exports[`PlayerDetails renders properly on tablet in landscape orientation 1`] = `
25
- <View
26
- collapsable={false}
27
- style={
28
- {
29
- "backgroundColor": "transparent",
30
- "flex": 1,
31
- "marginTop": -20,
32
- "paddingTop": 40,
33
- "width": 750,
34
- }
35
- }
36
- >
37
- <View
38
- feed="test-source"
39
- riverComponents={[]}
40
- riverId="test-id"
41
- />
42
- </View>
43
- `;
5
+ exports[`PlayerDetails renders properly on tablet in landscape orientation 1`] = `null`;
@@ -1,5 +1,4 @@
1
- import * as R from "ramda";
2
-
1
+ import { mergeRight } from "ramda";
3
2
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
4
3
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
@@ -25,10 +24,10 @@ export const useConfiguration = () => {
25
24
 
26
25
  const playerPluginConfig = playerManager.getPluginConfiguration();
27
26
 
28
- const config = R.mergeRight(playerPluginConfig, {
27
+ const config = mergeRight(playerPluginConfig, {
28
+ ...pluginConfiguration,
29
29
  ...targetScreenConfiguration?.general,
30
30
  ...targetScreenConfiguration?.styles,
31
- ...pluginConfiguration,
32
31
  });
33
32
 
34
33
  const {
@@ -8,7 +8,6 @@ import {
8
8
 
9
9
  import { Placeholder } from "./Placeholder";
10
10
  import { useInitialLoading } from "./hooks";
11
- import { useIsFocusable } from "@applicaster/zapp-react-native-utils/focusManager";
12
11
 
13
12
  type ReactComponent = React.ComponentType<any>;
14
13
 
@@ -138,12 +137,13 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
138
137
  );
139
138
 
140
139
  const componentProps = React.useMemo(
141
- () => ({ ...props, parent }),
140
+ () => ({
141
+ ...props,
142
+ parent,
143
+ }),
142
144
  [props, parent]
143
145
  );
144
146
 
145
- useIsFocusable(componentProps);
146
-
147
147
  React.useEffect(() => {
148
148
  if (!skipOnLoadFinished && !isLoading) {
149
149
  onLoadFinished();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "13.0.0-alpha.2807014304",
3
+ "version": "13.0.0-alpha.2886020207",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,10 +31,10 @@
31
31
  "redux-mock-store": "^1.5.3"
32
32
  },
33
33
  "dependencies": {
34
- "@applicaster/applicaster-types": "13.0.0-alpha.2807014304",
35
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2807014304",
36
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2807014304",
37
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2807014304",
34
+ "@applicaster/applicaster-types": "13.0.0-alpha.2886020207",
35
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2886020207",
36
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2886020207",
37
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2886020207",
38
38
  "promise": "^8.3.0",
39
39
  "react-router-native": "^5.1.2",
40
40
  "url": "^0.11.0",
@@ -1,5 +0,0 @@
1
- import { isTvOSPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
2
- import React from "react";
3
- import { View } from "react-native";
4
-
5
- export const CellWrapper = isTvOSPlatform() ? View : React.Fragment;