@applicaster/zapp-react-native-ui-components 12.0.0-rc.7 → 12.0.0-rc.70

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 (134) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  3. package/Components/AudioPlayer/helpers.tsx +1 -0
  4. package/Components/BaseFocusable/index.tsx +1 -1
  5. package/Components/Cell/Cell.tsx +7 -7
  6. package/Components/Cell/CellWithFocusable.tsx +38 -19
  7. package/Components/Cell/TvOSCellComponent.tsx +2 -2
  8. package/Components/ErrorScreen/index.tsx +1 -1
  9. package/Components/FocusableCell/index.tsx +7 -7
  10. package/Components/FocusableGroup/index.tsx +1 -0
  11. package/Components/FocusableList/FocusableChild.ts +24 -14
  12. package/Components/FocusableList/FocusableItem.tsx +1 -1
  13. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  14. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  15. package/Components/FocusableList/index.tsx +26 -25
  16. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  17. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  18. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  19. package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
  20. package/Components/HookRenderer/index.tsx +1 -6
  21. package/Components/Image/Image.android.tsx +3 -26
  22. package/Components/Image/Image.tsx +18 -2
  23. package/Components/Image/utils/index.ts +39 -0
  24. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  25. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  26. package/Components/Layout/TV/__tests__/index.test.tsx +18 -107
  27. package/Components/Layout/TV/index.tsx +9 -121
  28. package/Components/Layout/index.tsx +1 -9
  29. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  30. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -110
  31. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  32. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  33. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  34. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  35. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  36. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  37. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
  38. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  39. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  40. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  41. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  42. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  43. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  44. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  45. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  46. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  47. package/Components/MasterCell/utils/index.ts +16 -5
  48. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  49. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  50. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  51. package/Components/ModalComponent/Button/Item.tsx +82 -0
  52. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  53. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  54. package/Components/ModalComponent/Button/assets.ts +4 -0
  55. package/Components/ModalComponent/Button/index.tsx +111 -0
  56. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  57. package/Components/ModalComponent/Header/Title.tsx +70 -0
  58. package/Components/ModalComponent/Header/assets.ts +4 -0
  59. package/Components/ModalComponent/Header/index.tsx +71 -0
  60. package/Components/ModalComponent/Header/utils.ts +79 -0
  61. package/Components/ModalComponent/index.tsx +38 -0
  62. package/Components/ModalComponent/utils.ts +126 -0
  63. package/Components/Navigator/StackNavigator.tsx +48 -0
  64. package/Components/Navigator/index.ts +1 -0
  65. package/Components/PlayerContainer/PlayerContainer.tsx +64 -31
  66. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  67. package/Components/PlayerImageBackground/index.tsx +34 -8
  68. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  69. package/Components/River/RefreshControl.tsx +55 -1
  70. package/Components/River/River.tsx +8 -5
  71. package/Components/River/TV/River.tsx +2 -25
  72. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  73. package/Components/River/__tests__/componentsMap.test.js +7 -0
  74. package/Components/River/useScreenConfiguration.ts +5 -6
  75. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  76. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  77. package/Components/RouteManager/index.tsx +4 -2
  78. package/Components/Screen/TV/hooks/index.ts +3 -0
  79. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  80. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  81. package/Components/Screen/TV/index.web.tsx +179 -0
  82. package/Components/Screen/__tests__/Screen.test.tsx +48 -36
  83. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  84. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  85. package/Components/Screen/index.tsx +103 -44
  86. package/Components/Screen/navigationHandler.ts +0 -82
  87. package/Components/Screen/orientationHandler.ts +1 -1
  88. package/Components/ScreenResolver/index.tsx +4 -2
  89. package/Components/Tabs/TV/styles.ts +1 -1
  90. package/Components/TrackedView/index.tsx +6 -3
  91. package/Components/Transitioner/Scene.tsx +24 -19
  92. package/Components/Transitioner/Transitioner.tsx +9 -2
  93. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  94. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  95. package/Components/VideoLive/LiveImageManager.ts +60 -14
  96. package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
  97. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  98. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
  99. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  100. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  101. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  102. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  103. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  104. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  105. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  106. package/Components/VideoModal/PlayerDetails.tsx +6 -3
  107. package/Components/VideoModal/PlayerWrapper.tsx +82 -50
  108. package/Components/VideoModal/VideoModal.tsx +23 -40
  109. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  110. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
  111. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +246 -166
  112. package/Components/VideoModal/hooks/useModalSize.ts +13 -4
  113. package/Components/VideoModal/utils.ts +3 -3
  114. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  115. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  116. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  117. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  118. package/Components/Viewport/utils.js +1 -1
  119. package/Components/ZappUIComponent/index.tsx +22 -12
  120. package/Components/index.js +2 -0
  121. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  122. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  123. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  124. package/Contexts/ScreenContext/index.tsx +95 -29
  125. package/Contexts/ScreenDataContext/index.ts +3 -0
  126. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  127. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  128. package/Decorators/RiverResolver/index.tsx +0 -4
  129. package/Decorators/index.tsx +0 -4
  130. package/events/index.ts +1 -0
  131. package/package.json +5 -6
  132. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  133. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  134. /package/Contexts/{index.js → index.ts} +0 -0
@@ -41,7 +41,7 @@ export const getTransformedPreset = (
41
41
  }
42
42
 
43
43
  const updatedPresetComponent = produce(presetComponent, (draft) => {
44
- draft.id = `${componentId}${index}`;
44
+ draft.id = `${componentId}-${preset?.feed_url}-${index}`;
45
45
  draft.data.source = preset?.feed_url;
46
46
 
47
47
  if (draft.ui_components) {
@@ -19,6 +19,7 @@ type Props = {
19
19
  modalHeight?: number;
20
20
  modalWidth?: number;
21
21
  mode: VideoModalMode;
22
+ groupId?: string;
22
23
  };
23
24
 
24
25
  const YOUTUBE_PLUGIN_ID = "youtube-player-qb";
@@ -93,6 +94,7 @@ export function HandlePlayable({
93
94
  modalHeight,
94
95
  modalWidth,
95
96
  mode,
97
+ groupId,
96
98
  }: Props): React.ReactElement | null {
97
99
  const state = usePickFromState();
98
100
 
@@ -104,7 +106,7 @@ export function HandlePlayable({
104
106
  const [Player, playerModuleProperties] = getPlayer(item, state);
105
107
 
106
108
  const { module: CastPlugin } =
107
- findPluginByIdentifier(CHROMECAST_PLUGIN_ID, state.plugins) || {};
109
+ findPluginByIdentifier(CHROMECAST_PLUGIN_ID, state.plugins, true) || {};
108
110
 
109
111
  const [playable, setPlayable] =
110
112
  React.useState<Nullable<PlayableComponent>>(null);
@@ -167,6 +169,7 @@ export function HandlePlayable({
167
169
  isModal={isModal}
168
170
  mode={mode}
169
171
  disableCastAction={playerModuleProperties?.disableCastAction}
172
+ groupId={groupId}
170
173
  />
171
174
  );
172
175
  }
@@ -1,6 +1 @@
1
- import * as R from "ramda";
2
-
3
- import { withNavigator } from "@applicaster/zapp-react-native-ui-components/Decorators/Navigator/";
4
- import { HookRenderer as HookRendererComponent } from "./HookRenderer";
5
-
6
- export const HookRenderer = R.compose(withNavigator)(HookRendererComponent);
1
+ export { HookRenderer } from "./HookRenderer";
@@ -1,35 +1,12 @@
1
1
  import React from "react";
2
-
3
2
  import FastImage, {
4
3
  FastImageProps,
5
4
  } from "@applicaster/react-native-fast-image";
6
5
 
7
- export const QBImage = (props: FastImageProps) => {
8
- const source = React.useMemo(() => {
9
- if (typeof props.source === "number") {
10
- return props.source;
11
- }
6
+ import { useImageSource } from "./utils";
12
7
 
13
- return {
14
- uri: props.source.uri,
15
- headers: props.source.headers,
16
- priority: props.source.priority,
17
- cache: props.source.cache,
18
- maxWidth: props.source.maxWidth,
19
- maxHeight: props.source.maxHeight,
20
- };
21
- }, [
22
- ...(typeof props.source === "object"
23
- ? [
24
- props.source?.uri,
25
- props.source?.priority,
26
- props.source?.cache,
27
- props.source?.headers,
28
- props.source?.maxWidth,
29
- props.source?.maxHeight,
30
- ]
31
- : []),
32
- ]);
8
+ export const QBImage = (props: FastImageProps) => {
9
+ const source = useImageSource(props.source);
33
10
 
34
11
  return <FastImage {...props} source={source} />;
35
12
  };
@@ -1,8 +1,24 @@
1
- import { Image, ImageProps, ImageStyle, StyleProp } from "react-native";
1
+ import React from "react";
2
+ import {
3
+ Image,
4
+ ImageBackground,
5
+ ImageProps,
6
+ ImageStyle,
7
+ StyleProp,
8
+ } from "react-native";
2
9
 
3
10
  export interface Props extends ImageProps {
4
11
  style?: StyleProp<ImageStyle> | undefined;
5
12
  }
6
13
 
7
14
  // TODO - React.FC<Props> QBImage should process incoming url and apply any transformations if needed
8
- export const QBImage = Image;
15
+ export const QBImage = ({
16
+ children,
17
+ ...props
18
+ }: Props & { children?: React.ReactNode }) => {
19
+ if (children) {
20
+ return <ImageBackground {...props}>{children}</ImageBackground>;
21
+ }
22
+
23
+ return <Image {...props} />;
24
+ };
@@ -0,0 +1,39 @@
1
+ import FastImage, { Source } from "@applicaster/react-native-fast-image";
2
+ import { useMemo } from "react";
3
+ import { ImageRequireSource } from "react-native";
4
+
5
+ function getSourceCache(cache: Source["cache"]) {
6
+ return cache || FastImage.cacheControl.web;
7
+ }
8
+
9
+ export const useImageSource = (source?: Source | ImageRequireSource) => {
10
+ return useMemo(() => {
11
+ if (source) {
12
+ if (typeof source === "number") {
13
+ return source;
14
+ }
15
+
16
+ return {
17
+ uri: source.uri,
18
+ headers: source.headers,
19
+ priority: source.priority,
20
+ cache: getSourceCache(source?.cache),
21
+ maxWidth: source.maxWidth,
22
+ maxHeight: source.maxHeight,
23
+ };
24
+ }
25
+
26
+ return undefined;
27
+ }, [
28
+ ...(typeof source === "object"
29
+ ? [
30
+ source?.uri,
31
+ source?.priority,
32
+ source?.cache,
33
+ source?.headers,
34
+ source?.maxWidth,
35
+ source?.maxHeight,
36
+ ]
37
+ : []),
38
+ ]);
39
+ };
@@ -60,7 +60,7 @@ export function ScreenLayoutContextProvider(props: {
60
60
  initialState
61
61
  );
62
62
 
63
- const screeenLayoutValue = React.useMemo(
63
+ const screenLayoutValue = React.useMemo(
64
64
  () => ({
65
65
  ...screenLayout,
66
66
  setScreenLayout,
@@ -69,7 +69,7 @@ export function ScreenLayoutContextProvider(props: {
69
69
  );
70
70
 
71
71
  return (
72
- <ScreenLayoutContext.Provider value={screeenLayoutValue}>
72
+ <ScreenLayoutContext.Provider value={screenLayoutValue}>
73
73
  {props.children}
74
74
  </ScreenLayoutContext.Provider>
75
75
  );
@@ -2,58 +2,18 @@
2
2
 
3
3
  exports[`Layout TV renders 1`] = `
4
4
  <View
5
- style={
6
- Object {
7
- "flex": 1,
8
- "height": 1080,
9
- "width": 1920,
10
- }
11
- }
12
- testID="layout-container"
5
+ excludeFromFocusSearching={true}
6
+ id="/river/A1234"
7
+ preferredFocus={true}
13
8
  >
14
9
  <View
15
- backgroundImageUrl="http://applicaster.com"
16
- testID="background-component"
17
- >
18
- <View
19
- style={
20
- Array [
21
- Object {
22
- "position": "absolute",
23
- "top": 0,
24
- "width": 1920,
25
- "zIndex": 10,
26
- },
27
- Object {
28
- "maxHeight": 10,
29
- },
30
- ]
10
+ Components={
11
+ Object {
12
+ "Background": [Function],
13
+ "NavBar": [Function],
31
14
  }
32
- testID="nav-bar-container"
33
- >
34
- <View
35
- isVisible={true}
36
- menuPlugin={
37
- Object {
38
- "module": [Function],
39
- "name": "resolved-menu-plug",
40
- "type": "menu",
41
- }
42
- }
43
- navigationProps={
44
- Object {
45
- "assets": undefined,
46
- "home": undefined,
47
- "nav_items": undefined,
48
- "rules": undefined,
49
- "selected": undefined,
50
- "styles": undefined,
51
- "title": "",
52
- }
53
- }
54
- testID="nav-bar-component"
55
- />
56
- </View>
57
- </View>
15
+ }
16
+ route="/river/A1234"
17
+ />
58
18
  </View>
59
19
  `;
@@ -1,91 +1,48 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
2
+ import { omit } from "ramda";
3
3
  import { View } from "react-native";
4
4
  import { render } from "@testing-library/react-native";
5
5
  import { Provider } from "react-redux";
6
- import { createStore } from "redux";
7
6
  import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
7
+ import configureStore from "redux-mock-store";
8
8
 
9
- import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
9
+ const withoutChildren = omit(["children"]);
10
10
 
11
- jest.mock("@applicaster/quick-brick-core/App/ActionSetters", () => ({
12
- useRiverInitialState: () => ({}),
13
- }));
14
-
15
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
16
- useCurrentScreenData: jest.fn(() => ({
17
- navigations: [
18
- {
19
- category: "menu",
20
- navigation_type: "menu",
21
- styles: {
22
- hide_secondary_level_menu: false,
23
- },
24
- },
25
- ],
26
- })),
11
+ jest.mock("../../../Screen/TV/index.web", () => ({
12
+ Screen: View,
27
13
  }));
28
14
 
29
15
  const Layout = require("..").default;
30
16
 
31
- const ResolvedMenuPlug = () => <View testID="resolved-menu-plug" />;
32
-
33
- const plugins = [
34
- {
35
- module: ResolvedMenuPlug,
36
- type: "menu",
37
- name: "resolved-menu-plug",
38
- },
39
- ];
40
-
41
- const bgImage = "http://applicaster.com";
42
- const isNavBarVisible = true;
43
-
44
- const store = createStore(() => ({
17
+ const mockStore = configureStore()({
45
18
  appState: { appReady: true },
46
- remoteConfigurations: { sdkAssets: { bgImage } },
47
- plugins,
48
- }));
19
+ });
49
20
 
50
21
  describe("Layout TV", () => {
51
- const themes = {
52
- myTheme: { screen_margin_top: 10, screen_margin_bottom: 10 },
53
- };
54
-
55
- const selectedThemeId = "myTheme";
56
-
57
22
  const navigator = {
58
- activeRiver: {
59
- navigations: [{ category: "menu", navigation_type: "menu" }],
60
- },
61
- canGoBack: () => false,
62
23
  currentRoute: "/river/A1234",
63
- screenData: {
64
- navigations: [{ category: "menu", navigation_type: "menu" }],
65
- },
66
- isNavBarVisible: isNavBarVisible,
24
+ mainStack: [
25
+ {
26
+ route: "/river/A1234",
27
+ state: "state",
28
+ },
29
+ ],
67
30
  };
68
31
 
69
32
  const wrapper = ({ children }) => (
70
- <Provider store={store}>
33
+ <Provider store={mockStore}>
71
34
  <NavigationContext.Provider value={navigator}>
72
- <ThemeContext.Provider value={{ themes, selectedThemeId }}>
73
- {children}
74
- </ThemeContext.Provider>
35
+ {children}
75
36
  </NavigationContext.Provider>
76
37
  </Provider>
77
38
  );
78
39
 
79
- const Screen = (props) => (
80
- <View testID="screen-component" {...R.omit(["children"])(props)} />
81
- );
82
-
83
40
  const NavBar = (props) => (
84
- <View testID="nav-bar-component" {...R.omit(["children"])(props)} />
41
+ <View testID="nav-bar-component" {...withoutChildren(props)} />
85
42
  );
86
43
 
87
44
  const Background = (props: Record<any, any>) => (
88
- <View testID="background-component" {...R.omit(["children"])(props)}>
45
+ <View testID="background-component" {...withoutChildren(props)}>
89
46
  {props.children}
90
47
  </View>
91
48
  );
@@ -96,54 +53,8 @@ describe("Layout TV", () => {
96
53
  };
97
54
 
98
55
  it("renders", () => {
99
- const { toJSON } = render(
100
- <Layout Components={Components}>
101
- <Screen />
102
- </Layout>,
103
- { wrapper }
104
- );
56
+ const { toJSON } = render(<Layout Components={Components} />, { wrapper });
105
57
 
106
58
  expect(toJSON()).toMatchSnapshot();
107
59
  });
108
-
109
- describe("props passed to background component", () => {
110
- it("passes correct props", () => {
111
- const { getByTestId } = render(
112
- <Layout
113
- Components={Components}
114
- ComponentsExtraProps={{
115
- Background: { testProp: true },
116
- }}
117
- >
118
- <Screen />
119
- </Layout>,
120
- { wrapper }
121
- );
122
-
123
- const bgComponent = getByTestId("background-component");
124
- expect(bgComponent.props.backgroundImageUrl).toBe(bgImage);
125
- expect(bgComponent.props.testProp).toBe(true);
126
- });
127
- });
128
-
129
- describe("props passed to navbar component", () => {
130
- it("passes correct props", () => {
131
- const { getByTestId } = render(
132
- <Layout
133
- Components={Components}
134
- ComponentsExtraProps={{
135
- NavBar: { testProp: true },
136
- }}
137
- >
138
- <Screen />
139
- </Layout>,
140
- { wrapper }
141
- );
142
-
143
- const navbarComponent = getByTestId("nav-bar-component");
144
- expect(navbarComponent.props.isVisible).toBe(isNavBarVisible);
145
- expect(navbarComponent.props.menuPlugin).toBe(plugins[0]);
146
- expect(navbarComponent.props.testProp).toBe(true);
147
- });
148
- });
149
60
  });
@@ -1,144 +1,32 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
3
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
4
- import {
5
- useIsNavBarVisible,
6
- useNavigation,
7
- } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
8
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
-
10
- import {
11
- getNavigationProps,
12
- resolveNavigationPlugin,
13
- routeIsPlayerScreen,
14
- } from "@applicaster/zapp-react-native-utils/navigationUtils";
2
+ import { pathOr } from "ramda";
15
3
 
16
- import { getBackgroundImageUrl } from "../utils";
17
- import { LayoutContainer } from "./LayoutContainer";
18
- import { NavBarContainer } from "./NavBarContainer";
19
- import { ScreenContainer } from "./ScreenContainer";
20
- import { TransitionOverlay } from "./TransitionOverlay";
4
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
21
5
 
22
6
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
23
- import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
24
- import { PathnameContext } from "../../../Contexts/PathnameContext";
25
- import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
7
+ import { StackNavigator } from "../../Navigator";
26
8
 
27
9
  type Components = {
28
10
  NavBar: React.ComponentType<any>;
29
11
  Background: React.ComponentType<any>;
30
12
  };
31
13
 
32
- type ComponentsExtraProps = {
33
- Background?: Record<string, any>;
34
- NavBar?: Record<string, any>;
35
- };
36
-
37
14
  type Props = {
38
15
  Components: Components;
39
- ComponentsExtraProps?: ComponentsExtraProps;
40
- children: React.ReactNode;
41
16
  };
42
17
 
43
- const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
44
- const navigator = useNavigation();
45
- const theme = useTheme();
46
- const { title } = useNavbarState();
47
- const { activeRiver, currentRoute } = navigator;
48
-
49
- const {
50
- appState: { appReady = false } = {},
51
- remoteConfigurations,
52
- plugins = [],
53
- } = usePickFromState(["appState", "remoteConfigurations", "plugins"]);
54
-
55
- const navigationProps = getNavigationProps({
56
- navigator,
57
- title,
58
- category: "menu",
59
- });
60
-
61
- const backgroundColor = React.useMemo(() => theme.app_background_color, []);
62
-
63
- const backgroundImageUrl = React.useMemo(
64
- () => getBackgroundImageUrl(remoteConfigurations),
65
- [remoteConfigurations]
66
- );
67
-
68
- const menuPlugin = React.useMemo(
69
- () =>
70
- resolveNavigationPlugin({
71
- category: "menu",
72
- navigations: activeRiver?.navigations,
73
- plugins,
74
- }) as QuickBrickPlugin,
75
- []
76
- );
77
-
78
- const NavBar = React.useMemo(
79
- () => Components.NavBar || (menuPlugin.module as React.ComponentType<any>),
80
- []
81
- );
82
-
83
- const navBarVisible = useIsNavBarVisible();
84
-
85
- const [navBarReady, setNavBarReady] = React.useState(false);
18
+ const Layout = ({ Components }: Props) => {
19
+ const { appState } = usePickFromState(["appState"]);
20
+ const appReady = pathOr(false, ["appReady"], appState);
86
21
 
87
22
  if (!appReady) {
88
23
  return null;
89
24
  }
90
25
 
91
26
  return (
92
- <LayoutContainer>
93
- <ScreenLayoutContextProvider>
94
- <Components.Background
95
- backgroundColor={backgroundColor}
96
- backgroundImageUrl={backgroundImageUrl}
97
- {...R.omit(["ref"])(ComponentsExtraProps?.Background)}
98
- >
99
- {!isApplePlatform() ? (
100
- <NavBarContainer isVisible={navBarVisible} onReady={setNavBarReady}>
101
- <NavBar
102
- ref={ComponentsExtraProps?.NavBar?.ref}
103
- isVisible={navBarVisible && !routeIsPlayerScreen(currentRoute)}
104
- menuPlugin={menuPlugin}
105
- navigationProps={navigationProps}
106
- {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
107
- />
108
- </NavBarContainer>
109
- ) : null}
110
-
111
- {navBarReady ? (
112
- /**
113
- Need to re-mount this component on each navigation event
114
- It's a hack to work around the fact that we don't support
115
- correct screen rendering in our navigator (shared currentRoute state)
116
- **/
117
- <PathnameContext.Provider value={navigator.currentRoute}>
118
- <ScreenContainer>{children}</ScreenContainer>
119
- </PathnameContext.Provider>
120
- ) : null}
121
-
122
- {isApplePlatform() ? (
123
- /**
124
- Render NavBarContainer over ScreenContainer to let tvOS native
125
- focus manager works correctly to focus nav bar items first
126
- **/
127
- <NavBarContainer isVisible={navBarVisible} onReady={setNavBarReady}>
128
- <NavBar
129
- ref={ComponentsExtraProps?.NavBar?.ref}
130
- isVisible={navBarVisible && !routeIsPlayerScreen(currentRoute)}
131
- menuPlugin={menuPlugin}
132
- navigationProps={navigationProps}
133
- {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
134
- />
135
- </NavBarContainer>
136
- ) : null}
137
-
138
- <TransitionOverlay />
139
- </Components.Background>
140
- </ScreenLayoutContextProvider>
141
- </LayoutContainer>
27
+ <ScreenLayoutContextProvider>
28
+ <StackNavigator Components={Components} />
29
+ </ScreenLayoutContextProvider>
142
30
  );
143
31
  };
144
32
 
@@ -1,20 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
- import { ScreenContextProvider } from "../../Contexts/ScreenContext";
5
3
 
6
4
  import Mobile from "./Mobile";
7
5
  import TV from "./TV";
8
6
 
9
7
  export default function Layout(props) {
10
- const { currentRoute: pathname } = useNavigation();
11
-
12
8
  if (isTV()) {
13
- return (
14
- <ScreenContextProvider pathname={pathname}>
15
- <TV {...props} />
16
- </ScreenContextProvider>
17
- );
9
+ return <TV {...props} />;
18
10
  } else {
19
11
  return <Mobile {...props} />;
20
12
  }
@@ -25,6 +25,7 @@ type Props = {
25
25
  testID?: string;
26
26
  accessibilityLabel?: string;
27
27
  cellUUID?: string;
28
+ extraProps?: Record<string, any>;
28
29
  };
29
30
 
30
31
  function isStringAsset(asset) {
@@ -108,6 +109,7 @@ export function ActionButton(props: Props) {
108
109
  flavour={flavour}
109
110
  asset={getAssetValue(asset, flavour)}
110
111
  cellUUID={cellUUID}
112
+ {...(props?.extraProps ?? {})}
111
113
  />
112
114
  )}
113
115
  </TouchableOpacity>