@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5468407101 → 12.0.0-alpha.5471145113

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 (53) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +5 -5
  3. package/Components/Cell/CellWithFocusable.tsx +17 -5
  4. package/Components/FocusableGroup/index.tsx +1 -0
  5. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  6. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  7. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  8. package/Components/Layout/TV/__tests__/index.test.tsx +19 -75
  9. package/Components/Layout/TV/index.tsx +12 -11
  10. package/Components/Layout/TV/index.web.tsx +33 -0
  11. package/Components/Layout/index.tsx +15 -11
  12. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  13. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -109
  14. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  15. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  16. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  17. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  18. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  19. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  20. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  21. package/Components/MasterCell/utils/index.ts +12 -29
  22. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  23. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  24. package/Components/Navigator/StackNavigator.tsx +48 -0
  25. package/Components/Navigator/index.ts +1 -0
  26. package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
  27. package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
  28. package/Components/River/RefreshControl.tsx +2 -2
  29. package/Components/River/TV/River.tsx +0 -23
  30. package/Components/RouteManager/index.tsx +2 -2
  31. package/Components/Screen/TV/hooks/index.ts +3 -0
  32. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  33. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  34. package/Components/Screen/TV/index.web.tsx +179 -0
  35. package/Components/Screen/__tests__/Screen.test.tsx +3 -0
  36. package/Components/Screen/index.tsx +29 -1
  37. package/Components/ScreenResolver/index.tsx +3 -1
  38. package/Components/Transitioner/Scene.tsx +24 -19
  39. package/Components/Transitioner/Transitioner.tsx +21 -28
  40. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  41. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  42. package/Components/VideoLive/LiveImageManager.ts +18 -1
  43. package/Components/VideoModal/PlayerDetails.tsx +3 -3
  44. package/Components/VideoModal/PlayerWrapper.tsx +67 -60
  45. package/Components/VideoModal/VideoModal.tsx +4 -4
  46. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
  47. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  48. package/Contexts/ScreenContext/index.tsx +6 -0
  49. package/Contexts/ScreenDataContext/index.tsx +20 -0
  50. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  51. package/events/index.ts +1 -0
  52. package/package.json +5 -5
  53. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
@@ -7,50 +7,24 @@ type BorderPosition = "inside" | "outside" | "center";
7
7
  interface Props {
8
8
  style: ImageStyle | ViewStyle;
9
9
  borderPosition: BorderPosition;
10
+ borderPaddingTop: number;
11
+ borderPaddingRight: number;
12
+ borderPaddingBottom: number;
13
+ borderPaddingLeft: number;
10
14
  children: React.ReactNode;
11
15
  }
12
16
 
13
- const MARGINS = [
14
- "marginTop",
15
- "marginBottom",
16
- "marginLeft",
17
- "marginRight",
18
- ] as const;
17
+ const COLOR_TRANSPARENT = "transparent";
19
18
 
20
- const PADDINGS = [
21
- "paddingTop",
22
- "paddingBottom",
23
- "paddingLeft",
24
- "paddingRight",
25
- ] as const;
19
+ const styles = StyleSheet.create({
20
+ container: {
21
+ overflow: "visible",
22
+ borderWidth: 0,
23
+ borderColor: COLOR_TRANSPARENT,
24
+ },
25
+ });
26
26
 
27
- const isPercentageValue = (value: number | string) => {
28
- if (typeof value === "string" && value.endsWith("%")) {
29
- return true;
30
- }
31
-
32
- return false;
33
- };
34
-
35
- const calculateContainerSpacing = ({
36
- spacingKey,
37
- style,
38
- additionalSpacing,
39
- }: {
40
- spacingKey: typeof MARGINS[number] | typeof PADDINGS[number];
41
- style: ImageStyle | ViewStyle;
42
- additionalSpacing: number;
43
- }) => {
44
- return {
45
- [spacingKey]:
46
- toNumberWithDefaultZero(style[spacingKey]) + additionalSpacing,
47
- };
48
- };
49
-
50
- const getContainerBorderWidth = (
51
- borderPosition: BorderPosition,
52
- borderWidth
53
- ) => {
27
+ const getBorderPadding = (borderPosition: BorderPosition, borderWidth) => {
54
28
  switch (borderPosition) {
55
29
  case "inside":
56
30
  return 0;
@@ -63,104 +37,101 @@ const getContainerBorderWidth = (
63
37
  }
64
38
  };
65
39
 
66
- const getContainerPadding = (borderPosition: BorderPosition, borderWidth) => {
67
- switch (borderPosition) {
68
- case "inside":
69
- return borderWidth;
70
- case "center":
71
- return borderWidth / 2;
72
- case "outside":
73
- return 0;
74
- default:
75
- return 0;
76
- }
77
- };
78
-
79
- const InsideBorder = ({
40
+ const Border = ({
80
41
  style,
42
+ padding,
81
43
  borderPosition,
82
44
  }: {
83
45
  style: ViewStyle;
46
+ padding: ViewStyle;
84
47
  borderPosition: BorderPosition;
85
48
  }) => {
86
- if (borderPosition === "outside") {
49
+ if (!borderPosition) {
87
50
  return null;
88
51
  }
89
52
 
90
- const insideBorderWidth =
91
- borderPosition === "center" ? style.borderWidth / 2 : style.borderWidth;
53
+ const borderWidth = toNumberWithDefaultZero(style.borderWidth);
54
+ const containerPadding = getBorderPadding(borderPosition, borderWidth);
55
+
56
+ const initialBorderRadius = toNumberWithDefaultZero(style.borderRadius);
57
+ const paddingTop = toNumberWithDefaultZero(padding.paddingTop);
58
+ const paddingRight = toNumberWithDefaultZero(padding.paddingRight);
59
+ const paddingBottom = toNumberWithDefaultZero(padding.paddingBottom);
60
+ const paddingLeft = toNumberWithDefaultZero(padding.paddingLeft);
61
+
62
+ const borderRadiusStyle = initialBorderRadius
63
+ ? {
64
+ borderTopLeftRadius:
65
+ initialBorderRadius +
66
+ containerPadding +
67
+ Math.min(paddingTop, paddingLeft),
68
+ borderTopRightRadius:
69
+ initialBorderRadius +
70
+ containerPadding +
71
+ Math.min(paddingTop, paddingRight),
72
+ borderBottomLeftRadius:
73
+ initialBorderRadius +
74
+ containerPadding +
75
+ Math.min(paddingBottom, paddingLeft),
76
+ borderBottomRightRadius:
77
+ initialBorderRadius +
78
+ containerPadding +
79
+ Math.min(paddingBottom, paddingRight),
80
+ }
81
+ : {
82
+ borderTopLeftRadius: 0,
83
+ borderTopRightRadius: 0,
84
+ borderBottomLeftRadius: 0,
85
+ borderBottomRightRadius: 0,
86
+ };
92
87
 
93
88
  return (
94
89
  <View
95
90
  style={{
96
91
  ...StyleSheet.absoluteFillObject,
97
- borderWidth: insideBorderWidth,
92
+ right: -containerPadding - paddingRight,
93
+ bottom: -containerPadding - paddingBottom,
94
+ left: -containerPadding - paddingLeft,
95
+ top: -containerPadding - paddingTop,
96
+ borderWidth,
98
97
  borderColor: style.borderColor,
99
- borderRadius: style.borderRadius,
98
+ ...borderRadiusStyle,
100
99
  }}
101
100
  />
102
101
  );
103
102
  };
104
103
 
105
104
  export const BorderContainerView = (props: Props) => {
106
- const { style, children } = props;
107
- // Return border position prop after re-implementing
108
- const borderPosition = "outside";
109
-
110
- const borderWidth = toNumberWithDefaultZero(style.borderWidth);
111
- const spacing = getContainerPadding(borderPosition, borderWidth);
105
+ const {
106
+ borderPosition,
107
+ borderPaddingTop,
108
+ borderPaddingRight,
109
+ borderPaddingBottom,
110
+ borderPaddingLeft,
111
+ style,
112
+ children,
113
+ } = props;
112
114
 
113
115
  const borderStyleForMissingBorder =
114
116
  style?.borderWidth === 0 || !style?.borderColor ? { borderRadius: 0 } : {};
115
117
 
116
- const updatedMargins = MARGINS.reduce((acc, margin) => {
117
- const marginValue = calculateContainerSpacing({
118
- spacingKey: margin,
119
- style,
120
- additionalSpacing: spacing,
121
- });
122
-
123
- return { ...acc, ...marginValue };
124
- }, {});
125
-
126
- const updatedPaddings = PADDINGS.reduce((acc, padding) => {
127
- const paddingValue = calculateContainerSpacing({
128
- spacingKey: padding,
129
- style,
130
- additionalSpacing: spacing,
131
- });
132
-
133
- return { ...acc, ...paddingValue };
134
- }, {});
135
-
136
- const updatedWidth = style.width
137
- ? isPercentageValue(style.width)
138
- ? style.width
139
- : toNumberWithDefaultZero(style.width) - spacing * 2
140
- : undefined;
141
-
142
- const updatedHeight = style.height
143
- ? isPercentageValue(style.height)
144
- ? style.height
145
- : toNumberWithDefaultZero(style.height) - spacing * 2
146
- : undefined;
147
-
148
- const containerStyle = {
149
- borderWidth: getContainerBorderWidth(borderPosition, borderWidth),
150
- padding: spacing,
151
- ...updatedMargins,
152
- ...updatedPaddings,
153
- width: updatedWidth,
154
- height: updatedHeight,
155
- };
118
+ const padding =
119
+ borderPosition === "outside"
120
+ ? {
121
+ paddingTop: borderPaddingTop,
122
+ paddingRight: borderPaddingRight,
123
+ paddingBottom: borderPaddingBottom,
124
+ paddingLeft: borderPaddingLeft,
125
+ }
126
+ : {};
156
127
 
157
128
  return (
158
- <View {...props} style={[style, containerStyle]}>
129
+ <View
130
+ {...props}
131
+ style={[style, styles.container, borderStyleForMissingBorder]}
132
+ >
159
133
  {children}
160
- <InsideBorder
161
- style={{ ...style, ...borderStyleForMissingBorder }}
162
- borderPosition={borderPosition}
163
- />
134
+ <Border style={style} padding={padding} borderPosition={borderPosition} />
164
135
  </View>
165
136
  );
166
137
  };
@@ -4,6 +4,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
4
4
 
5
5
  type DynamicBadgeProps = {
6
6
  cellUUID?: string;
7
+ uri?: string;
7
8
  };
8
9
 
9
10
  const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
@@ -12,11 +13,12 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
12
13
  // TODO: Initial value should depends on player state (playing or not)
13
14
  const [showImage, setShowImage] = React.useState(true);
14
15
  const player = usePlayer(playerId);
16
+ const uri = props?.uri;
15
17
 
16
18
  React.useEffect(() => {
17
19
  if (playerId && player) {
18
20
  return player.addListener({
19
- id: "dynamic-badges",
21
+ id: `dynamic-badges-${uri}`,
20
22
  listener: {
21
23
  onPlayerClose: () => {
22
24
  setShowImage(true);
@@ -35,7 +37,7 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
35
37
  } else {
36
38
  setShowImage(true);
37
39
  }
38
- }, [player]);
40
+ }, [player, uri]);
39
41
 
40
42
  if (!showImage) {
41
43
  return null;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
3
3
  import { LiveImage } from "../LiveImage";
4
4
  import PureImage from "../Image";
5
+ import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
5
6
 
6
7
  type Props = {
7
8
  enable_video_preview: boolean;
@@ -9,7 +10,10 @@ type Props = {
9
10
  };
10
11
 
11
12
  export const ImageContainer = (props: Props) => {
12
- const Component = isVideoPreviewEnabled(props) ? LiveImage : PureImage;
13
+ const isActive = useIsScreenActive();
14
+
15
+ const Component =
16
+ isVideoPreviewEnabled(props) && isActive ? LiveImage : PureImage;
13
17
 
14
18
  return <Component {...props} />;
15
19
  };
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Text } from "react-native";
3
3
  import { omit } from "ramda";
4
- import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
5
4
  import {
6
5
  textTransform,
7
6
  dateFormat,
@@ -9,6 +8,9 @@ import {
9
8
 
10
9
  import { useTextLabel, withFocusedStyles } from "./hooks";
11
10
  import { withScaledLineHeight } from "./utils";
11
+ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
12
+ import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
13
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
12
14
 
13
15
  type Props = {
14
16
  style: any;
@@ -32,14 +34,24 @@ const _Text = ({
32
34
  ...otherProps
33
35
  }: Props) => {
34
36
  const _label = useTextLabel({ label, entry });
37
+ const isMeasurement = React.useContext(MeasurementPortalContext);
35
38
 
36
39
  if (isNilOrEmpty(_label)) {
37
40
  return null;
38
41
  }
39
42
 
43
+ // set maximum possible height for the text in case of measurement
44
+ const height =
45
+ isMeasurement && otherProps.numberOfLines && style.lineHeight
46
+ ? toNumber(otherProps.numberOfLines) * toNumber(style.lineHeight)
47
+ : undefined;
48
+
40
49
  return (
41
50
  <Text
42
- style={withScaledLineHeight(withFocusedStyles({ style, otherProps }))}
51
+ style={[
52
+ withScaledLineHeight(withFocusedStyles({ style, otherProps })),
53
+ { height },
54
+ ]}
43
55
  {...withoutLabel(otherProps)}
44
56
  >
45
57
  {dateTransformEnabled
@@ -1,11 +1,23 @@
1
1
  import React from "react";
2
- import { Text } from "react-native";
2
+ import RN from "react-native";
3
3
  import { Provider } from "react-redux";
4
4
  import TestRenderer from "react-test-renderer";
5
- import configureStore from "redux-mock-store";
6
- import CustomText from "../Text";
5
+ import configureStoreFn from "redux-mock-store";
7
6
 
8
- const mockStore = configureStore();
7
+ const mockUseIsRTL = jest.fn(() => true);
8
+ const mockGetIsRTL = jest.fn(() => true);
9
+ const mockUseLocalizedStrings = jest.fn(() => ({}));
10
+ const mockGetUILanguage = jest.fn(() => "he-HE");
11
+
12
+ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
13
+ useIsRTL: mockUseIsRTL,
14
+ getIsRTL: mockGetIsRTL,
15
+ useLocalizedStrings: mockUseLocalizedStrings,
16
+ getUILanguage: mockGetUILanguage,
17
+ }));
18
+
19
+ const CustomText = require("../Text").default;
20
+ const mockStore = configureStoreFn();
9
21
 
10
22
  const defaultProps = {
11
23
  entry: {},
@@ -22,7 +34,7 @@ const getRenderedText = (label: string, store: any) => {
22
34
  </Provider>
23
35
  );
24
36
 
25
- return testRenderer.root.findByType(Text).props.children;
37
+ return testRenderer.root.findByType(RN.Text).props.children;
26
38
  };
27
39
 
28
40
  describe("RTL app: Hebrew text contains english word", () => {
@@ -34,7 +46,7 @@ describe("RTL app: Hebrew text contains english word", () => {
34
46
  remoteConfigurations: { localizations: { he: {} } },
35
47
  appData: {
36
48
  languageCode: "he",
37
- countryCode: "HE",
49
+ countryCode: "IL",
38
50
  },
39
51
  });
40
52
 
@@ -47,18 +59,22 @@ describe("RTL app: Hebrew text contains english word", () => {
47
59
 
48
60
  it("Hebrew text contains not first english word", () => {
49
61
  const renderedText = getRenderedText(textWithNotFirstEnglishWord, store);
50
-
51
62
  expect(renderedText).toEqual(textWithNotFirstEnglishWord);
52
63
  });
53
64
 
54
65
  it("Hebrew text doesn't contain english word", () => {
55
66
  const renderedText = getRenderedText(textWithoutEnglishWord, store);
56
-
57
67
  expect(renderedText).toEqual(textWithoutEnglishWord);
58
68
  });
59
69
  });
60
70
 
61
71
  describe("LTR app: English text", () => {
72
+ beforeAll(() => {
73
+ mockUseIsRTL.mockReturnValue(false);
74
+ mockGetIsRTL.mockReturnValue(false);
75
+ mockGetUILanguage.mockReturnValue("en-US");
76
+ });
77
+
62
78
  const englishText = "Test sentence";
63
79
 
64
80
  const store = mockStore({
@@ -71,7 +87,6 @@ describe("LTR app: English text", () => {
71
87
 
72
88
  it("English text", () => {
73
89
  const renderedText = getRenderedText(englishText, store);
74
-
75
90
  expect(renderedText).toEqual(englishText);
76
91
  });
77
92
  });
@@ -61,7 +61,10 @@ export function ButtonContainerView({
61
61
  <View style={applyRTLStylesIfNeeded(style, isRTL)}>
62
62
  {insertBetween(
63
63
  (index) => (
64
- <HorizontalSeparator key={index} width={horizontalGutter} />
64
+ <HorizontalSeparator
65
+ key={`separator_${index}`}
66
+ width={horizontalGutter}
67
+ />
65
68
  ),
66
69
  cloneElementsWithIds(buttonIds, filteredChildren)
67
70
  )}
@@ -29,7 +29,10 @@ export function ButtonContainerView({
29
29
  <View style={style}>
30
30
  {insertBetween(
31
31
  (index) => (
32
- <HorizontalSeparator key={index} width={horizontalGutter} />
32
+ <HorizontalSeparator
33
+ key={`separator_${index}`}
34
+ width={horizontalGutter}
35
+ />
33
36
  ),
34
37
  filteredChildren
35
38
  )}
@@ -53,7 +53,7 @@ export const useAsyncRendering = (viewRef: React.RefObject<View>): Return => {
53
53
  measure(viewRef?.current, ({ width, height }) => {
54
54
  setDimensions({
55
55
  width,
56
- height,
56
+ height: Math.ceil(height),
57
57
  });
58
58
  });
59
59
  })
@@ -9,6 +9,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
9
9
  import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
10
10
  import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
11
11
  import { getCellState } from "../../Cell/utils";
12
+ import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
12
13
 
13
14
  const hasElementSpecificViewType = (viewType) => (element) => {
14
15
  if (R.isNil(element)) {
@@ -47,44 +48,26 @@ export const hasElementsSpecificViewType = (viewType) => (elements) => {
47
48
  return R.any(hasElementSpecificViewType(viewType))(elements);
48
49
  };
49
50
 
50
- const isColorOrEmpty = (value) =>
51
- value === null ||
52
- value === undefined ||
53
- value === "" ||
54
- value.startsWith("#") ||
55
- value.startsWith("rgba") ||
56
- value === "transparent";
57
-
58
51
  function resolveColorForProp(entry, style, colorProp) {
59
- const colorValue = style[colorProp];
52
+ const colorFromProp = style[colorProp];
53
+ const nestedEntryValue = R.path(colorFromProp.split("."), entry);
60
54
 
61
- if (isColorOrEmpty(colorValue)) {
62
- return style;
55
+ if (nestedEntryValue === undefined) {
56
+ logWarning(colorFromProp, style, entry, nestedEntryValue);
63
57
  }
64
58
 
65
- const pathParts = colorValue.split(".");
66
- let nestedEntryValue = entry;
67
-
68
- for (const part of pathParts) {
69
- if (nestedEntryValue === null || typeof nestedEntryValue !== "object") {
70
- logWarning(colorValue, style, entry, nestedEntryValue);
71
-
72
- return style;
73
- }
59
+ const colorValue = getColorFromData({
60
+ data: entry,
61
+ valueFromLayout: colorFromProp,
62
+ });
74
63
 
75
- nestedEntryValue = nestedEntryValue[part];
76
- }
77
-
78
- if (nestedEntryValue === undefined) {
79
- logWarning(colorValue, style, entry, nestedEntryValue);
64
+ if (!colorValue) {
65
+ logWarning(colorProp, style, entry, colorValue);
80
66
 
81
67
  return style;
82
68
  }
83
69
 
84
- // After successful traversal, set the value.
85
- style[colorProp] = nestedEntryValue;
86
-
87
- return style;
70
+ return { ...style, [colorProp]: colorValue };
88
71
  }
89
72
 
90
73
  export function resolveColor(entry, style) {
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { View, StyleSheet } from "react-native";
3
+ import { MeasurementPortalContext } from "./MeasurementsPortal";
3
4
 
4
5
  type Props = {
5
6
  Component: React.ElementType;
@@ -19,13 +20,16 @@ const _MeasurementsPortal = (
19
20
  { Component, onLayout, componentProps, containerStyle }: Props,
20
21
  ref
21
22
  ) => (
22
- <View
23
- onLayout={onLayout}
24
- style={[styles.container, containerStyle]}
25
- ref={ref}
26
- >
27
- <Component {...componentProps} />
28
- </View>
23
+ // hack for cell to determine if cell is in measurement mode
24
+ <MeasurementPortalContext.Provider value={{}}>
25
+ <View
26
+ onLayout={onLayout}
27
+ style={[styles.container, containerStyle]}
28
+ ref={ref}
29
+ >
30
+ <Component {...componentProps} />
31
+ </View>
32
+ </MeasurementPortalContext.Provider>
29
33
  );
30
34
 
31
35
  export const MeasurementsPortal = React.forwardRef(_MeasurementsPortal);
@@ -35,7 +35,16 @@ const MeasurementsPortal = ({ Component, onLayout, componentProps }: Props) => {
35
35
  );
36
36
  };
37
37
 
38
- const MeasurementPortalContext = React.createContext(null);
38
+ type MeasurementPortalContextType = {
39
+ measureComponent?: (
40
+ comp: React.ElementType,
41
+ props: Record<any, any>
42
+ ) => Promise<any>;
43
+ measuringInProgress?: boolean;
44
+ };
45
+
46
+ const MeasurementPortalContext =
47
+ React.createContext<null | MeasurementPortalContextType>(null);
39
48
 
40
49
  const MeasurementsPortalContextProvider = ({ children }) => {
41
50
  const Component = React.useRef(View);
@@ -0,0 +1,48 @@
1
+ import * as React from "react";
2
+ import { isEmpty } from "ramda";
3
+
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
5
+ import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
6
+ import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
7
+ import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
8
+ import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
9
+
10
+ import { Screen } from "../Screen/TV/index.web";
11
+
12
+ type Components = {
13
+ NavBar: React.ComponentType<any>;
14
+ Background: React.ComponentType<any>;
15
+ };
16
+
17
+ type Props = {
18
+ Components: Components;
19
+ };
20
+
21
+ export const StackNavigator = ({ Components }: Props) => {
22
+ const { mainStack, currentRoute } = useNavigation();
23
+
24
+ const renderScreen = ({ route, state }) => {
25
+ const pathAttributes = getPathAttributes({ pathname: route });
26
+
27
+ if (isEmpty(pathAttributes)) {
28
+ return null;
29
+ }
30
+
31
+ return (
32
+ <FocusableGroup
33
+ id={route}
34
+ preferredFocus={route === currentRoute}
35
+ excludeFromFocusSearching
36
+ key={route}
37
+ >
38
+ <ScreenDataContext.Provider value={state}>
39
+ <PathnameContext.Provider value={route}>
40
+ <Screen route={route} Components={Components} />
41
+ </PathnameContext.Provider>
42
+ </ScreenDataContext.Provider>
43
+ </FocusableGroup>
44
+ );
45
+ };
46
+
47
+ return <>{mainStack.map(renderScreen)}</>;
48
+ };
@@ -0,0 +1 @@
1
+ export { StackNavigator } from "./StackNavigator";
@@ -68,6 +68,7 @@ type Props = {
68
68
  mode?: VideoModalMode;
69
69
  loadPipesData: (url: string, options: {}) => void;
70
70
  disableCastAction?: boolean;
71
+ groupId?: string;
71
72
  };
72
73
 
73
74
  type ScreenStyles = ZappRiver["styles"] & {
@@ -200,6 +201,7 @@ const PlayerContainerComponent = (props: Props) => {
200
201
  style: videoStyle,
201
202
  mode = VideoModalMode.MAXIMIZED,
202
203
  disableCastAction = false,
204
+ groupId,
203
205
  } = props;
204
206
 
205
207
  // Hooks
@@ -249,8 +251,12 @@ const PlayerContainerComponent = (props: Props) => {
249
251
  return;
250
252
  }
251
253
 
252
- navigator.goBack();
253
254
  showNavBar(true);
255
+
256
+ // Hack to close player screen on mobile only (tv handles that in InteractionManager)
257
+ if (!isTV()) {
258
+ navigator.goBack();
259
+ }
254
260
  }, [isModal, navigator.goBack, showNavBar]);
255
261
 
256
262
  const playEntry = (entry) => navigator.replaceTop(entry, { mode });
@@ -629,6 +635,7 @@ const PlayerContainerComponent = (props: Props) => {
629
635
  style={styles.focusableGroup}
630
636
  preferredFocus
631
637
  shouldUsePreferredFocus
638
+ groupId={groupId}
632
639
  >
633
640
  {/* Video player and components */}
634
641
  <View
@@ -271,6 +271,12 @@ function ComponentsMapComponent(props: Props) {
271
271
 
272
272
  if (y >= 0 && y + height <= contentHeight) {
273
273
  scrollY.setValue(y);
274
+ } else {
275
+ if (y <= 0) {
276
+ scrollY.setValue(0);
277
+ } else if (y + height > contentHeight) {
278
+ scrollY.setValue(contentHeight - height);
279
+ }
274
280
  }
275
281
  }, []);
276
282
 
@@ -134,10 +134,10 @@ export const useGetProgressViewOffset = () => {
134
134
  switch (contentPosition) {
135
135
  case "on_bottom_status_bar":
136
136
  // navbar height
137
- return offset + height - top;
137
+ return offset + height;
138
138
  case "on_top_screen":
139
139
  // navbar height + status bar height
140
- return offset + height;
140
+ return offset + height + top;
141
141
  default:
142
142
  return offset;
143
143
  }