@applicaster/zapp-react-native-ui-components 15.1.0-rc.9 → 16.0.0-alpha.1833861900

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 (155) hide show
  1. package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
  2. package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
  3. package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
  4. package/Components/BackgroundImage/index.ts +1 -0
  5. package/Components/BaseFocusable/index.ios.ts +12 -2
  6. package/Components/Cell/FocusableWrapper.tsx +3 -0
  7. package/Components/Cell/TvOSCellComponent.tsx +6 -3
  8. package/Components/Focusable/Focusable.tsx +4 -2
  9. package/Components/Focusable/FocusableTvOS.tsx +18 -1
  10. package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
  11. package/Components/FocusableGroup/FocusableTvOS.tsx +41 -8
  12. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
  13. package/Components/HandlePlayable/HandlePlayable.tsx +13 -8
  14. package/Components/Layout/TV/NavBarContainer.tsx +1 -10
  15. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  16. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
  17. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
  18. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  19. package/Components/Layout/TV/index.tsx +5 -7
  20. package/Components/Layout/TV/index.web.tsx +5 -7
  21. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  22. package/Components/MasterCell/CONFIG_BUILDER_TO_REACT_COMPONENT.md +144 -0
  23. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  24. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
  25. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
  26. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
  27. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
  28. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +165 -0
  29. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +405 -0
  30. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/index.ts +1 -0
  31. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
  32. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
  33. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
  34. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
  35. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
  36. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -10
  37. package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
  38. package/Components/MasterCell/DefaultComponents/ButtonContainerView/components/HorizontalSeparator.tsx +8 -0
  39. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +15 -0
  40. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tv.android.tsx +58 -0
  41. package/Components/MasterCell/DefaultComponents/{tv/ButtonContainerView/index.tsx → ButtonContainerView/index.tv.tsx} +3 -11
  42. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.web.ts +1 -0
  43. package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +40 -0
  44. package/Components/MasterCell/DefaultComponents/DataProvider/index.tsx +163 -0
  45. package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +2 -23
  46. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -22
  47. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +8 -2
  48. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  49. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  50. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  51. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +1 -2
  52. package/Components/MasterCell/DefaultComponents/PressableView.tsx +34 -0
  53. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  54. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +11 -0
  55. package/Components/MasterCell/DefaultComponents/__tests__/DataProvider.test.tsx +141 -0
  56. package/Components/MasterCell/DefaultComponents/index.ts +9 -3
  57. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +135 -0
  58. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +33 -0
  59. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +22 -0
  60. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +125 -0
  61. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
  62. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
  63. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +37 -0
  64. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +393 -0
  65. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +141 -0
  66. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +343 -0
  67. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
  68. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +122 -0
  69. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
  70. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +238 -0
  71. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Asset.ts +4 -18
  72. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Button.ts +24 -73
  73. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TextLabelsContainer.ts +37 -18
  74. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TvActionButton.tsx +27 -0
  75. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +89 -0
  76. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/renderedTree.test.tsx +231 -0
  77. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +47 -48
  78. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
  79. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +101 -144
  80. package/Components/MasterCell/MappingFunctions/index.js +3 -2
  81. package/Components/MasterCell/README.md +4 -0
  82. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +24 -0
  83. package/Components/MasterCell/__tests__/configInflater.test.js +1 -0
  84. package/Components/MasterCell/__tests__/elementMapper.test.js +46 -0
  85. package/Components/MasterCell/dataAdapter.ts +4 -1
  86. package/Components/MasterCell/elementMapper.tsx +52 -7
  87. package/Components/MasterCell/utils/__tests__/cloneChildrenWithIds.test.tsx +43 -0
  88. package/Components/MasterCell/utils/__tests__/useFilterChildren.test.tsx +80 -0
  89. package/Components/MasterCell/utils/index.ts +85 -15
  90. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  91. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  92. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  93. package/Components/PlayerContainer/PlayerContainer.tsx +8 -5
  94. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
  95. package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -19
  96. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  97. package/Components/River/RefreshControl.tsx +19 -88
  98. package/Components/River/River.tsx +9 -82
  99. package/Components/River/TV/River.tsx +31 -14
  100. package/Components/River/TV/index.tsx +8 -4
  101. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  102. package/Components/River/TV/utils/index.ts +4 -0
  103. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  104. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -0
  105. package/Components/River/__tests__/componentsMap.test.js +38 -0
  106. package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
  107. package/Components/River/hooks/index.ts +1 -0
  108. package/Components/River/hooks/usePullToRefresh.ts +51 -0
  109. package/Components/Screen/TV/index.web.tsx +4 -2
  110. package/Components/Screen/__tests__/Screen.test.tsx +65 -42
  111. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  112. package/Components/Screen/hooks.ts +2 -3
  113. package/Components/Screen/index.tsx +2 -3
  114. package/Components/Screen/orientationHandler.ts +3 -3
  115. package/Components/ScreenResolver/index.tsx +9 -5
  116. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  117. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  118. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  119. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  120. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +9 -20
  121. package/Components/Tabs/TabContent.tsx +7 -4
  122. package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +201 -0
  123. package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
  124. package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
  125. package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
  126. package/Components/TopCutoffOverlay/index.tsx +55 -0
  127. package/Components/Transitioner/index.js +3 -3
  128. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +5 -5
  129. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  130. package/Components/VideoModal/utils.ts +12 -10
  131. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
  132. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  133. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  134. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
  135. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  136. package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
  137. package/Contexts/ScreenContext/index.tsx +25 -18
  138. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  139. package/Decorators/Analytics/index.tsx +6 -5
  140. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  141. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  142. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
  143. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  144. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  145. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  146. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
  147. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  148. package/Helpers/DataSourceHelper/index.ts +19 -0
  149. package/Helpers/index.js +7 -1
  150. package/package.json +5 -5
  151. package/Components/Layout/TV/LayoutBackground.tsx +0 -28
  152. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +0 -135
  153. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/types.ts +0 -25
  154. package/Components/River/TV/withTVEventHandler.tsx +0 -36
  155. package/Helpers/DataSourceHelper/index.js +0 -19
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { View, ViewStyle } from "react-native";
3
+
4
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
+ import {
6
+ selectRemoteConfigurations,
7
+ useAppSelector,
8
+ } from "@applicaster/zapp-react-native-redux";
9
+
10
+ import { getBackgroundImageUrl } from "../Layout/utils";
11
+
12
+ const baseBackgroundStyles = (imageUrl, backgroundColor) =>
13
+ ({
14
+ position: "absolute",
15
+ left: 0,
16
+ top: 0,
17
+ right: 0,
18
+ bottom: 0,
19
+ zIndex: -1,
20
+ backgroundSize: "cover",
21
+ background: imageUrl
22
+ ? `url(${imageUrl}) no-repeat top center ${backgroundColor}`
23
+ : backgroundColor,
24
+ }) as ViewStyle;
25
+
26
+ export const BackgroundImage = ({ children }: React.PropsWithChildren) => {
27
+ const theme = useTheme();
28
+
29
+ const remoteConfigurations = useAppSelector(selectRemoteConfigurations);
30
+
31
+ const backgroundColor = theme.app_background_color;
32
+ const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
33
+
34
+ return (
35
+ <View
36
+ id="background"
37
+ style={baseBackgroundStyles(backgroundImageUrl, backgroundColor)}
38
+ >
39
+ {children}
40
+ </View>
41
+ );
42
+ };
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ ImageURISource,
6
+ ImageBackground,
7
+ } from "react-native";
8
+
9
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
10
+
11
+ const imageSource: ImageURISource = {
12
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
13
+ };
14
+
15
+ const styles = StyleSheet.create({
16
+ container: { flex: 1 },
17
+ backgroundImage: { width: "100%", height: "100%" },
18
+ });
19
+
20
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
21
+ return (
22
+ <View style={styles.container}>
23
+ <ImageBackground style={styles.backgroundImage} source={imageSource}>
24
+ {children}
25
+ </ImageBackground>
26
+ </View>
27
+ );
28
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, ImageURISource } from "react-native";
3
+
4
+ import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
5
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
6
+
7
+ const imageSource: ImageURISource = {
8
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
9
+ };
10
+
11
+ const styles = StyleSheet.create({
12
+ container: { flex: 1 },
13
+ backgroundImage: { width: "100%", height: "100%" },
14
+ });
15
+
16
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
17
+ return (
18
+ <View style={styles.container}>
19
+ <Image style={styles.backgroundImage} source={imageSource}>
20
+ {children}
21
+ </Image>
22
+ </View>
23
+ );
24
+ }
@@ -0,0 +1 @@
1
+ export { BackgroundImage } from "./BackgroundImage";
@@ -22,6 +22,7 @@ type Props = {
22
22
  onFocus?: FocusManager.FocusEventCB;
23
23
  onBlur?: FocusManager.FocusEventCB;
24
24
  selected?: boolean;
25
+ skipFocusManagerRegistration?: boolean;
25
26
  };
26
27
 
27
28
  export class BaseFocusable<
@@ -61,10 +62,14 @@ export class BaseFocusable<
61
62
  }
62
63
 
63
64
  componentDidMount() {
64
- const { id } = this.props;
65
+ const { id, skipFocusManagerRegistration } = this.props;
65
66
  const component = this;
66
67
  this.node = this.ref.current;
67
68
 
69
+ if (skipFocusManagerRegistration) {
70
+ return;
71
+ }
72
+
68
73
  focusManager.register({
69
74
  id,
70
75
  component: component,
@@ -118,7 +123,12 @@ export class BaseFocusable<
118
123
 
119
124
  componentWillUnmount() {
120
125
  this._isMounted = false;
121
- const { id } = this.props;
126
+ const { id, skipFocusManagerRegistration } = this.props;
127
+
128
+ if (skipFocusManagerRegistration) {
129
+ return;
130
+ }
131
+
122
132
  focusManager.unregister(id, { group: this.isGroup || false });
123
133
  }
124
134
 
@@ -10,6 +10,7 @@ type Props = {
10
10
  children: (focused: boolean) => React.ReactNode;
11
11
  onFocus: (arg1: any, index?: number) => void;
12
12
  onBlur: Callback;
13
+ skipFocusManagerRegistration?: boolean;
13
14
  };
14
15
 
15
16
  export const FocusableWrapper = ({
@@ -20,6 +21,7 @@ export const FocusableWrapper = ({
20
21
  applyWrapper,
21
22
  onFocus,
22
23
  onBlur,
24
+ skipFocusManagerRegistration,
23
25
  }: Props) => {
24
26
  if (applyWrapper) {
25
27
  return (
@@ -34,6 +36,7 @@ export const FocusableWrapper = ({
34
36
  // @ts-ignore
35
37
  offsetUpdater={noop}
36
38
  isFocusable
39
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
37
40
  >
38
41
  {(focused) => children(focused)}
39
42
  </Focusable>
@@ -80,6 +80,7 @@ type Props = {
80
80
  componentsMapOffset: number;
81
81
  applyFocusableWrapper: boolean;
82
82
  hasFocusableInside: boolean;
83
+ skipFocusManagerRegistration?: boolean;
83
84
  };
84
85
 
85
86
  type State = {
@@ -194,7 +195,6 @@ class TvOSCell extends React.Component<Props, State> {
194
195
  groupId,
195
196
  component,
196
197
  index,
197
- componentsMapOffset,
198
198
  } = this.props;
199
199
 
200
200
  this.setScreenLayout(componentAnchorPointY, screenLayout);
@@ -221,8 +221,7 @@ class TvOSCell extends React.Component<Props, State> {
221
221
  const totalOffset =
222
222
  headerOffset +
223
223
  toNumberWithDefaultZero(componentAnchorPointY) +
224
- extraAnchorPointYOffset -
225
- toNumberWithDefaultZero(componentsMapOffset) +
224
+ extraAnchorPointYOffset +
226
225
  componentMarginTop +
227
226
  componentPaddingTop;
228
227
 
@@ -266,6 +265,7 @@ class TvOSCell extends React.Component<Props, State> {
266
265
  behavior,
267
266
  applyFocusableWrapper,
268
267
  hasFocusableInside,
268
+ skipFocusManagerRegistration,
269
269
  } = this.props;
270
270
 
271
271
  const { id } = item;
@@ -291,6 +291,7 @@ class TvOSCell extends React.Component<Props, State> {
291
291
  onFocus={handleFocus}
292
292
  onBlur={onBlur || this.onBlur}
293
293
  applyWrapper={applyFocusableWrapper}
294
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
294
295
  >
295
296
  {(focused) => (
296
297
  <CellWithFocusable
@@ -305,6 +306,7 @@ class TvOSCell extends React.Component<Props, State> {
305
306
  focused={focused || this.props.focused}
306
307
  behavior={behavior}
307
308
  isFocusable={isFocusable}
309
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
308
310
  />
309
311
  )}
310
312
  </FocusableWrapper>
@@ -327,6 +329,7 @@ class TvOSCell extends React.Component<Props, State> {
327
329
  offsetUpdater={offsetUpdater}
328
330
  style={baseCellStyles}
329
331
  isFocusable={isFocusable}
332
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
330
333
  >
331
334
  {(focused) => (
332
335
  <FocusableCell
@@ -8,6 +8,8 @@ import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withF
8
8
  import { StyleSheet, ViewStyle } from "react-native";
9
9
  import { AccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager";
10
10
 
11
+ import { isSearchInputId } from "@applicaster/zapp-react-native-utils/searchUtils";
12
+
11
13
  type Props = {
12
14
  initialFocus?: boolean;
13
15
  id: string;
@@ -106,7 +108,7 @@ class Focusable extends BaseFocusable<Props> {
106
108
  onMouseEnter() {
107
109
  const { id } = this.props;
108
110
 
109
- if (id !== "search_input_group_id") {
111
+ if (!isSearchInputId(id)) {
110
112
  this.mouse = true;
111
113
  this.props?.handleFocus?.({ mouse: true });
112
114
 
@@ -120,7 +122,7 @@ class Focusable extends BaseFocusable<Props> {
120
122
  onMouseLeave() {
121
123
  const { id } = this.props;
122
124
 
123
- if (id !== "search_input_group_id") {
125
+ if (!isSearchInputId(id)) {
124
126
  this.mouse = false;
125
127
  this.blur(null);
126
128
  }
@@ -10,8 +10,12 @@ import {
10
10
  forceFocusableFocus,
11
11
  } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
12
12
  import { findNodeHandle, ViewStyle } from "react-native";
13
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
13
14
 
14
- function noop() {}
15
+ import {
16
+ emitFocused,
17
+ emitNativeRegistered,
18
+ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
15
19
 
16
20
  type Props = {
17
21
  id: string;
@@ -39,6 +43,7 @@ type Props = {
39
43
  hasReceivedFocus: () => void;
40
44
  offsetUpdater: (arg1: string, arg2: number) => number;
41
45
  style: ViewStyle;
46
+ skipFocusManagerRegistration?: boolean;
42
47
  };
43
48
 
44
49
  export class Focusable extends BaseFocusable<Props> {
@@ -53,6 +58,7 @@ export class Focusable extends BaseFocusable<Props> {
53
58
  this.nextFocusableReactTags = {};
54
59
  this.preferredFocus = this.preferredFocus.bind(this);
55
60
  this.measureView = this.measureView.bind(this);
61
+ this.onRegistered = this.onRegistered.bind(this);
56
62
  }
57
63
 
58
64
  /**
@@ -84,6 +90,9 @@ export class Focusable extends BaseFocusable<Props> {
84
90
  });
85
91
  }
86
92
 
93
+ const id: string = nativeEvent.itemID;
94
+ emitFocused(id);
95
+
87
96
  onFocus(nativeEvent);
88
97
  }
89
98
 
@@ -169,6 +178,13 @@ export class Focusable extends BaseFocusable<Props> {
169
178
  });
170
179
  }
171
180
 
181
+ onRegistered({ nativeEvent }) {
182
+ const groupId = nativeEvent?.groupId;
183
+ const id = nativeEvent?.itemId;
184
+
185
+ emitNativeRegistered({ id, groupId, isGroup: false });
186
+ }
187
+
172
188
  render() {
173
189
  const {
174
190
  children,
@@ -203,6 +219,7 @@ export class Focusable extends BaseFocusable<Props> {
203
219
  focusable={isFocusable}
204
220
  {...this.nextFocusableReactTags}
205
221
  {...otherProps}
222
+ onRegistered={this.onRegistered}
206
223
  >
207
224
  {typeof children === "function" ? children(focused) : children}
208
225
  </FocusableItemNative>
@@ -5,6 +5,7 @@ exports[`FocusableTvOS should render correctly 1`] = `
5
5
  groupId={null}
6
6
  itemId={null}
7
7
  onLayout={[Function]}
8
+ onRegistered={[Function]}
8
9
  onViewBlur={[Function]}
9
10
  onViewFocus={[Function]}
10
11
  onViewPress={[Function]}
@@ -1,12 +1,18 @@
1
1
  import * as React from "react";
2
2
  import { FocusableGroupNative } from "@applicaster/zapp-react-native-ui-components/Components/NativeFocusables";
3
3
  import { BaseFocusable } from "@applicaster/zapp-react-native-ui-components/Components/BaseFocusable";
4
- import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
4
+ // TODO: Enable when will be feature flags
5
+ // import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
6
+ import { LayoutContext } from "@applicaster/zapp-react-native-tvos-app/Context/LayoutContext";
7
+ import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
8
+ import { isScreenPlayable } from "@applicaster/zapp-react-native-utils/navigationUtils/itemTypes";
9
+ import { emitNativeRegistered } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
5
10
 
6
- const { log_verbose } = createLogger({
7
- subsystem: "General",
8
- category: "FocusableGroup",
9
- });
11
+ // TODO: Enable when will be feature flags
12
+ // const { log_verbose } = createLogger({
13
+ // subsystem: "General",
14
+ // category: "FocusableGroup",
15
+ // });
10
16
 
11
17
  type FocusableGroupNativeEvent = {
12
18
  nativeEvent: {
@@ -33,9 +39,16 @@ type Props = {
33
39
  screenData: { screenId: string; parentScreenId: string };
34
40
  };
35
41
 
36
- export class FocusableGroup extends BaseFocusable<Props> {
42
+ class FocusableGroupComponent extends BaseFocusable<Props> {
37
43
  public readonly isGroup: boolean = true;
38
44
 
45
+ onRegistered = ({ nativeEvent }) => {
46
+ const groupId = nativeEvent?.groupId;
47
+ const id = nativeEvent?.itemId;
48
+
49
+ emitNativeRegistered({ id, groupId, isGroup: true });
50
+ };
51
+
39
52
  render() {
40
53
  const {
41
54
  children,
@@ -48,12 +61,14 @@ export class FocusableGroup extends BaseFocusable<Props> {
48
61
  } = this.props;
49
62
 
50
63
  const onGroupFocus = ({ nativeEvent }: FocusableGroupNativeEvent) => {
51
- log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
64
+ // TODO: Enable when will be feature flags
65
+ // log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
52
66
  this.onFocus(this.ref, nativeEvent.focusHeading);
53
67
  };
54
68
 
55
69
  const onGroupBlur = ({ nativeEvent }: FocusableGroupNativeEvent) => {
56
- log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
70
+ // TODO: Enable when will be feature flags
71
+ // log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
57
72
  this.onBlur(this.ref, nativeEvent.focusHeading);
58
73
  };
59
74
 
@@ -68,9 +83,27 @@ export class FocusableGroup extends BaseFocusable<Props> {
68
83
  onGroupBlur={onGroupBlur}
69
84
  style={style}
70
85
  {...otherProps}
86
+ onRegistered={this.onRegistered}
71
87
  >
72
88
  {children}
73
89
  </FocusableGroupNative>
74
90
  );
75
91
  }
76
92
  }
93
+
94
+ export const withFocusDisabled = (Component) => {
95
+ return function WithFocusDisabled(props) {
96
+ // @ts-ignore
97
+ const { screenFocusBlocked } = React.useContext(LayoutContext.ReactContext);
98
+
99
+ const { pathname } = useRoute();
100
+
101
+ const isPlayerPresented = isScreenPlayable(pathname);
102
+
103
+ const blockScreenFocus = isPlayerPresented === false && screenFocusBlocked;
104
+
105
+ return <Component {...props} isFocusDisabled={blockScreenFocus} />;
106
+ };
107
+ };
108
+
109
+ export const FocusableGroup = withFocusDisabled(FocusableGroupComponent);
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook } from "@testing-library/react-hooks";
2
+ import { renderHook } from "@testing-library/react-native";
3
3
 
4
4
  import {
5
5
  getTransformedPreset,
@@ -1,6 +1,13 @@
1
1
  import * as React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
2
+ import {
3
+ useAppData,
4
+ useContentTypes,
5
+ usePlugins,
6
+ } from "@applicaster/zapp-react-native-redux/hooks";
7
+ import {
8
+ useNavigation,
9
+ useRivers,
10
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
4
11
 
5
12
  import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
6
13
  import { PlayerContainer } from "../PlayerContainer";
@@ -28,12 +35,10 @@ export function HandlePlayable({
28
35
  mode,
29
36
  groupId,
30
37
  }: Props): React.ReactElement | null {
31
- const { plugins, contentTypes, rivers, appData } = usePickFromState([
32
- "plugins",
33
- "contentTypes",
34
- "rivers",
35
- "appData",
36
- ]);
38
+ const plugins = usePlugins();
39
+ const contentTypes = useContentTypes();
40
+ const rivers = useRivers();
41
+ const appData = useAppData();
37
42
 
38
43
  const { closeVideoModal } = useNavigation();
39
44
 
@@ -15,12 +15,6 @@ const styles = StyleSheet.create({
15
15
  flex: 1,
16
16
  width: "100%",
17
17
  },
18
- themeStyles: {
19
- // limits the height of the focusable container of the TopMenuBarTV component
20
- // to prevent it from being overlapped by the screen content,
21
- // as it makes TopMenuBarTV unfocusable on tvOS
22
- maxHeight: 1,
23
- },
24
18
  });
25
19
 
26
20
  export const NavBarContainer = ({ children, isVisible, onReady }: Props) => {
@@ -31,10 +25,7 @@ export const NavBarContainer = ({ children, isVisible, onReady }: Props) => {
31
25
  }, [onReady]);
32
26
 
33
27
  return isVisible ? (
34
- <View
35
- testID="nav-bar-container"
36
- style={[styles.container, styles.themeStyles]}
37
- >
28
+ <View testID="nav-bar-container" style={styles.container}>
38
29
  {children}
39
30
  </View>
40
31
  ) : null;
@@ -18,7 +18,7 @@ import {
18
18
  routeIsPlayerScreen,
19
19
  } from "@applicaster/zapp-react-native-utils/navigationUtils";
20
20
  import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
21
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
21
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
22
22
  import { NavBarContainer } from "./NavBarContainer";
23
23
 
24
24
  type ComponentsExtraProps = {
@@ -111,11 +111,7 @@ export const ScreenContainer = React.memo(function ScreenContainer({
111
111
  const { activeRiver } = navigator;
112
112
  const { title, visible } = useNavbarState();
113
113
 
114
- const { plugins = [] } = usePickFromState([
115
- "appState",
116
- "remoteConfigurations",
117
- "plugins",
118
- ]);
114
+ const plugins = usePlugins();
119
115
 
120
116
  const navigationProps = getNavigationProps({
121
117
  navigator,
@@ -3,18 +3,13 @@
3
3
  exports[`NavBarContainer renders 1`] = `
4
4
  <View
5
5
  style={
6
- [
7
- {
8
- "flex": 1,
9
- "position": "absolute",
10
- "top": 0,
11
- "width": "100%",
12
- "zIndex": 10,
13
- },
14
- {
15
- "maxHeight": 1,
16
- },
17
- ]
6
+ {
7
+ "flex": 1,
8
+ "position": "absolute",
9
+ "top": 0,
10
+ "width": "100%",
11
+ "zIndex": 10,
12
+ }
18
13
  }
19
14
  testID="nav-bar-container"
20
15
  >
@@ -14,18 +14,13 @@ exports[`ScreenContainer renders 1`] = `
14
14
  >
15
15
  <View
16
16
  style={
17
- [
18
- {
19
- "flex": 1,
20
- "position": "absolute",
21
- "top": 0,
22
- "width": "100%",
23
- "zIndex": 10,
24
- },
25
- {
26
- "maxHeight": 1,
27
- },
28
- ]
17
+ {
18
+ "flex": 1,
19
+ "position": "absolute",
20
+ "top": 0,
21
+ "width": "100%",
22
+ "zIndex": 10,
23
+ }
29
24
  }
30
25
  testID="nav-bar-container"
31
26
  >
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports[`Layout TV renders 1`] = `
4
4
  <View
5
- backgroundColor="#000000"
6
5
  testID="background-component"
7
6
  >
8
7
  <View
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { selectAppReady } from "@applicaster/zapp-react-native-redux";
4
5
 
5
6
  import { LayoutContainer } from "./LayoutContainer";
6
7
  import { ScreenContainer } from "./ScreenContainer";
@@ -9,7 +10,6 @@ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
9
10
  import { PathnameContext } from "../../../Contexts/PathnameContext";
10
11
  import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
11
12
  import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
12
- import { LayoutBackground } from "./LayoutBackground";
13
13
 
14
14
  type Components = {
15
15
  NavBar: React.ComponentType<any>;
@@ -29,9 +29,7 @@ type Props = {
29
29
  const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
30
30
  const navigator = useNavigation();
31
31
 
32
- const { appState: { appReady = false } = {} } = usePickFromState([
33
- "appState",
34
- ]);
32
+ const appReady = useAppSelector(selectAppReady);
35
33
 
36
34
  if (!appReady) {
37
35
  return null;
@@ -40,7 +38,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
40
38
  return (
41
39
  <LayoutContainer>
42
40
  <ScreenLayoutContextProvider>
43
- <LayoutBackground Background={Components.Background}>
41
+ <Components.Background>
44
42
  <ScreenDataContext.Provider value={navigator.data}>
45
43
  <PathnameContext.Provider value={navigator.currentRoute}>
46
44
  <ScreenContextProvider pathname={navigator.currentRoute}>
@@ -53,7 +51,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
53
51
  </ScreenContextProvider>
54
52
  </PathnameContext.Provider>
55
53
  </ScreenDataContext.Provider>
56
- </LayoutBackground>
54
+ </Components.Background>
57
55
  </ScreenLayoutContextProvider>
58
56
  </LayoutContainer>
59
57
  );
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
- import { pathOr } from "ramda";
3
2
 
4
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
5
4
 
6
5
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
7
6
  import { StackNavigator } from "../../Navigator";
8
- import { LayoutBackground } from "./LayoutBackground";
7
+ import { selectAppReady } from "@applicaster/zapp-react-native-redux";
9
8
 
10
9
  type Components = {
11
10
  NavBar: React.ComponentType<any>;
@@ -17,8 +16,7 @@ type Props = {
17
16
  };
18
17
 
19
18
  const Layout = ({ Components }: Props) => {
20
- const { appState } = usePickFromState(["appState"]);
21
- const appReady = pathOr(false, ["appReady"], appState);
19
+ const appReady = useAppSelector(selectAppReady);
22
20
 
23
21
  if (!appReady) {
24
22
  return null;
@@ -26,9 +24,9 @@ const Layout = ({ Components }: Props) => {
26
24
 
27
25
  return (
28
26
  <ScreenLayoutContextProvider>
29
- <LayoutBackground Background={Components.Background}>
27
+ <Components.Background>
30
28
  <StackNavigator Components={Components} />
31
- </LayoutBackground>
29
+ </Components.Background>
32
30
  </ScreenLayoutContextProvider>
33
31
  );
34
32
  };
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
5
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
6
6
  import {
7
7
  inflateString,
8
8
  objectToReadableString,
@@ -40,7 +40,7 @@ export async function inflateUrl(url) {
40
40
 
41
41
  export function LinkHandler(props: Props) {
42
42
  const screenData = props?.screenData;
43
- const { plugins } = usePickFromState(["rivers", "plugins"]);
43
+ const plugins = usePlugins();
44
44
 
45
45
  const ScreenPlugin = findPluginByIdentifier(
46
46
  WEBVIEW_SCREEN_IDENTIFIER,