@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5208030571 → 12.0.0-alpha.5230293331

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 (98) hide show
  1. package/Components/BaseFocusable/index.tsx +3 -3
  2. package/Components/Cell/Cell.tsx +30 -13
  3. package/Components/Cell/CellWithFocusable.tsx +6 -4
  4. package/Components/Cell/TvOSCellComponent.tsx +3 -7
  5. package/Components/Focusable/Focusable.tsx +6 -1
  6. package/Components/FocusableGroup/index.tsx +10 -2
  7. package/Components/FreezeWithCallback/Freeze.tsx +31 -0
  8. package/Components/FreezeWithCallback/LICENSE +21 -0
  9. package/Components/FreezeWithCallback/Suspender.tsx +17 -0
  10. package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
  11. package/Components/FreezeWithCallback/index.tsx +3 -0
  12. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  13. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  14. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  15. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  16. package/Components/Layout/TV/__tests__/index.test.tsx +20 -75
  17. package/Components/Layout/TV/index.tsx +29 -181
  18. package/Components/Layout/TV/index.web.tsx +33 -0
  19. package/Components/Layout/index.tsx +15 -11
  20. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
  21. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -116
  22. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  23. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +17 -1
  24. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
  25. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  26. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
  27. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  28. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  29. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  30. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  31. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
  32. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  33. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
  34. package/Components/MasterCell/dataAdapter.ts +21 -7
  35. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  36. package/Components/MasterCell/index.tsx +5 -3
  37. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  38. package/Components/MasterCell/utils/index.ts +17 -30
  39. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  40. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  41. package/Components/Navigator/StackNavigator.tsx +57 -0
  42. package/Components/Navigator/index.ts +1 -0
  43. package/Components/PlayerContainer/PlayerContainer.tsx +14 -3
  44. package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
  45. package/Components/River/RefreshControl.tsx +55 -1
  46. package/Components/River/TV/River.tsx +0 -22
  47. package/Components/RouteManager/index.tsx +2 -2
  48. package/Components/Screen/TV/hooks/index.ts +1 -0
  49. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  50. package/Components/Screen/TV/index.web.tsx +85 -58
  51. package/Components/Screen/__tests__/Screen.test.tsx +3 -49
  52. package/Components/Screen/index.tsx +55 -76
  53. package/Components/Screen/navigationHandler.ts +6 -3
  54. package/Components/Screen/orientationHandler.ts +18 -7
  55. package/Components/Screen/utils.ts +16 -0
  56. package/Components/ScreenResolver/index.tsx +6 -11
  57. package/Components/Transitioner/Scene.tsx +39 -26
  58. package/Components/Transitioner/Transitioner.tsx +56 -48
  59. package/Components/Transitioner/__tests__/Scene.test.js +7 -0
  60. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
  61. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -0
  62. package/Components/VideoLive/LiveImageManager.ts +28 -1
  63. package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
  64. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
  65. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
  66. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +81 -46
  67. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +47 -33
  68. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +129 -86
  69. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +44 -5
  70. package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
  71. package/Components/VideoModal/PlayerDetails.tsx +19 -5
  72. package/Components/VideoModal/PlayerWrapper.tsx +104 -67
  73. package/Components/VideoModal/VideoModal.tsx +27 -21
  74. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +7 -0
  75. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
  76. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
  77. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +134 -22
  78. package/Components/VideoModal/hooks/useModalSize.ts +10 -12
  79. package/Components/VideoModal/utils.ts +5 -2
  80. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  81. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
  82. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
  83. package/Contexts/ConfirmDialogState/index.ts +1 -1
  84. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  85. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  86. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  87. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  88. package/Contexts/FocusableGroupContext/index.ts +7 -0
  89. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  90. package/Contexts/ScreenContext/index.tsx +2 -2
  91. package/Contexts/ScreenDataContext/index.tsx +20 -0
  92. package/const.ts +6 -0
  93. package/events/index.ts +1 -0
  94. package/index.js +3 -0
  95. package/package.json +5 -5
  96. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  97. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  98. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
@@ -1,14 +1,27 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { render } from "@testing-library/react-native";
3
+ import { render, waitFor } from "@testing-library/react-native";
4
+ import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
5
 
5
6
  import { ScreenLayoutContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenLayoutContext";
6
7
 
7
8
  const navigator_mock = {
8
9
  currentRoute: "/river/A1234",
9
10
  screenData: {},
11
+ activeRiver: {
12
+ navigations: {},
13
+ id: "A1234",
14
+ home: false,
15
+ },
10
16
  };
11
17
 
18
+ jest.mock("@applicaster/zapp-react-native-utils/navigationUtils", () => ({
19
+ ...jest.requireActual<any>(
20
+ "@applicaster/zapp-react-native-utils/navigationUtils"
21
+ ),
22
+ findMenuPlugin: () => ({}),
23
+ }));
24
+
12
25
  jest.mock("@applicaster/quick-brick-core/App/ActionSetters", () => ({
13
26
  useRiverInitialState: () => ({}),
14
27
  }));
@@ -17,13 +30,13 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
17
30
  useNavigation: () => navigator_mock,
18
31
  }));
19
32
 
20
- jest.mock("../../../River/useScreenConfiguration.ts", () => ({
33
+ jest.mock("../../../River/useScreenConfiguration", () => ({
21
34
  useScreenConfiguration: () => ({}),
22
35
  }));
23
36
 
24
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
25
- useCurrentScreenData: jest.fn(() => ({})),
26
- }));
37
+ jest.mock(
38
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData"
39
+ );
27
40
 
28
41
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
29
42
  useTheme: () => ({}),
@@ -44,42 +57,39 @@ describe("ScreenContainer", () => {
44
57
  const setScreenLayout = () => {};
45
58
 
46
59
  const wrapper = ({ children }) => (
47
- <ScreenLayoutContext.Provider value={{ ...screenLayout, setScreenLayout }}>
48
- {children}
49
- </ScreenLayoutContext.Provider>
60
+ <WrappedWithProviders>
61
+ <ScreenLayoutContext.Provider
62
+ value={{ ...screenLayout, setScreenLayout }}
63
+ >
64
+ <ScreenContainer NavBar={View}>{children}</ScreenContainer>
65
+ </ScreenLayoutContext.Provider>
66
+ </WrappedWithProviders>
50
67
  );
51
68
 
52
69
  const TestComp = () => <View testID="test-component" />;
53
70
 
54
71
  it("renders", () => {
55
- const { toJSON } = render(
56
- <ScreenContainer>
57
- <TestComp />
58
- </ScreenContainer>,
59
- { wrapper }
60
- );
72
+ const { toJSON } = render(<TestComp />, { wrapper });
61
73
 
62
74
  expect(toJSON()).toMatchSnapshot();
63
75
  });
64
76
 
65
- it("renders passed component", () => {
66
- const { getByTestId } = render(
67
- <ScreenContainer>
68
- <TestComp />
69
- </ScreenContainer>,
70
- { wrapper }
71
- );
77
+ it("renders passed component", async () => {
78
+ const { getByTestId } = render(<TestComp />, { wrapper });
79
+
80
+ await waitFor(() => {
81
+ return expect(getByTestId("screen-container")).toBeDefined();
82
+ });
72
83
 
73
84
  expect(getByTestId("test-component")).toBeDefined();
74
85
  });
75
86
 
76
- it("sets margins provided by the theme", () => {
77
- const { getByTestId } = render(
78
- <ScreenContainer>
79
- <TestComp />
80
- </ScreenContainer>,
81
- { wrapper }
82
- );
87
+ it("sets margins provided by the theme", async () => {
88
+ const { getByTestId } = render(<TestComp />, { wrapper });
89
+
90
+ await waitFor(() => {
91
+ return expect(getByTestId("screen-container")).toBeDefined();
92
+ });
83
93
 
84
94
  const screen = getByTestId("screen-container");
85
95
  expect(screen.props.style).toMatchSnapshot();
@@ -1,28 +1,40 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`ScreenContainer renders 1`] = `
4
- <View
4
+ <RNCSafeAreaProvider
5
+ onInsetsChange={[Function]}
5
6
  style={
6
7
  Array [
7
8
  Object {
8
9
  "flex": 1,
9
- "height": "100%",
10
- "width": "100%",
11
- },
12
- Object {
13
- "backgroundColor": "transparent",
14
- "marginBottom": 10,
15
- "paddingBottom": 0,
16
- "paddingTop": 0,
17
10
  },
11
+ undefined,
18
12
  ]
19
13
  }
20
- testID="screen-container"
21
14
  >
22
15
  <View
23
- testID="test-component"
24
- />
25
- </View>
16
+ style={
17
+ Array [
18
+ Object {
19
+ "position": "absolute",
20
+ "top": 0,
21
+ "width": 1920,
22
+ "zIndex": 10,
23
+ },
24
+ Object {
25
+ "maxHeight": 10,
26
+ },
27
+ ]
28
+ }
29
+ testID="nav-bar-container"
30
+ >
31
+ <View
32
+ isVisible={true}
33
+ menuPlugin={Object {}}
34
+ navigationProps={null}
35
+ />
36
+ </View>
37
+ </RNCSafeAreaProvider>
26
38
  `;
27
39
 
28
40
  exports[`ScreenContainer sets margins provided by the theme 1`] = `
@@ -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,79 +1,49 @@
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: () => ({}),
11
+ jest.mock("../../../Screen/TV/index.web", () => ({
12
+ Screen: View,
13
13
  }));
14
14
 
15
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen");
15
+ const Layout = require("../index.web").default;
16
16
 
17
- const Layout = require("..").default;
18
-
19
- const ResolvedMenuPlug = () => <View testID="resolved-menu-plug" />;
20
-
21
- const plugins = [
22
- {
23
- module: ResolvedMenuPlug,
24
- type: "menu",
25
- name: "resolved-menu-plug",
26
- },
27
- ];
28
-
29
- const bgImage = "http://applicaster.com";
30
- const isNavBarVisible = true;
31
-
32
- const store = createStore(() => ({
17
+ const mockStore = configureStore()({
33
18
  appState: { appReady: true },
34
- remoteConfigurations: { sdkAssets: { bgImage } },
35
- plugins,
36
- }));
19
+ });
37
20
 
38
21
  describe("Layout TV", () => {
39
- const themes = {
40
- myTheme: { screen_margin_top: 10, screen_margin_bottom: 10 },
41
- };
42
-
43
- const selectedThemeId = "myTheme";
44
-
45
22
  const navigator = {
46
- activeRiver: {
47
- navigations: [{ category: "menu", navigation_type: "menu" }],
48
- },
49
- canGoBack: () => false,
50
23
  currentRoute: "/river/A1234",
51
- screenData: {
52
- navigations: [{ category: "menu", navigation_type: "menu" }],
53
- },
54
- isNavBarVisible: isNavBarVisible,
24
+ canGoBack: jest.fn(),
25
+ mainStack: [
26
+ {
27
+ route: "/river/A1234",
28
+ state: { screen: {} },
29
+ },
30
+ ],
55
31
  };
56
32
 
57
33
  const wrapper = ({ children }) => (
58
- <Provider store={store}>
34
+ <Provider store={mockStore}>
59
35
  <NavigationContext.Provider value={navigator}>
60
- <ThemeContext.Provider value={{ themes, selectedThemeId }}>
61
- {children}
62
- </ThemeContext.Provider>
36
+ {children}
63
37
  </NavigationContext.Provider>
64
38
  </Provider>
65
39
  );
66
40
 
67
- const Screen = (props) => (
68
- <View testID="screen-component" {...R.omit(["children"])(props)} />
69
- );
70
-
71
41
  const NavBar = (props) => (
72
- <View testID="nav-bar-component" {...R.omit(["children"])(props)} />
42
+ <View testID="nav-bar-component" {...withoutChildren(props)} />
73
43
  );
74
44
 
75
45
  const Background = (props: Record<any, any>) => (
76
- <View testID="background-component" {...R.omit(["children"])(props)}>
46
+ <View testID="background-component" {...withoutChildren(props)}>
77
47
  {props.children}
78
48
  </View>
79
49
  );
@@ -84,33 +54,8 @@ describe("Layout TV", () => {
84
54
  };
85
55
 
86
56
  it("renders", () => {
87
- const { toJSON } = render(
88
- <Layout Components={Components}>
89
- <Screen />
90
- </Layout>,
91
- { wrapper }
92
- );
57
+ const { toJSON } = render(<Layout Components={Components} />, { wrapper });
93
58
 
94
59
  expect(toJSON()).toMatchSnapshot();
95
60
  });
96
-
97
- describe("props passed to background component", () => {
98
- it("passes correct props", () => {
99
- const { getByTestId } = render(
100
- <Layout
101
- Components={Components}
102
- ComponentsExtraProps={{
103
- Background: { testProp: true },
104
- }}
105
- >
106
- <Screen />
107
- </Layout>,
108
- { wrapper }
109
- );
110
-
111
- const bgComponent = getByTestId("background-component");
112
- expect(bgComponent.props.backgroundImageUrl).toBe(bgImage);
113
- expect(bgComponent.props.testProp).toBe(true);
114
- });
115
- });
116
61
  });
@@ -1,45 +1,17 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { View, StyleSheet } from "react-native";
4
3
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
6
5
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
- import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
8
- import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
9
-
10
- import {
11
- getNavigationProps,
12
- getPathAttributes,
13
- resolveNavigationPlugin,
14
- routeIsPlayerScreen,
15
- } from "@applicaster/zapp-react-native-utils/navigationUtils";
16
6
 
17
7
  import { getBackgroundImageUrl } from "../utils";
18
8
  import { LayoutContainer } from "./LayoutContainer";
19
- import { NavBarContainer } from "./NavBarContainer";
20
9
  import { ScreenContainer } from "./ScreenContainer";
21
- import { TransitionOverlay } from "./TransitionOverlay";
22
10
 
23
11
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
24
12
  import { PathnameContext } from "../../../Contexts/PathnameContext";
25
-
26
- import { FocusableGroup } from "../../FocusableGroup";
27
- import { Screen } from "../../Screen/TV/index.web";
28
-
29
- export const ScreenDataContext = React.createContext(null);
30
-
31
- const styles = StyleSheet.create({
32
- container: {
33
- position: "absolute",
34
- width: 1920,
35
- height: 1080,
36
- backgroundColor: "black",
37
- // opacity: 0.5,
38
-
39
- borderWidth: 4,
40
- borderColor: "magenta",
41
- },
42
- });
13
+ import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
14
+ import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
43
15
 
44
16
  type Components = {
45
17
  NavBar: React.ComponentType<any>;
@@ -47,90 +19,22 @@ type Components = {
47
19
  };
48
20
 
49
21
  type ComponentsExtraProps = {
50
- NavBar?: Record<string, any>;
51
22
  Background?: Record<string, any>;
23
+ NavBar?: Record<string, any>;
52
24
  };
53
25
 
54
26
  type Props = {
55
27
  Components: Components;
56
- componentsExtraProps?: ComponentsExtraProps;
57
- };
58
-
59
- const StackNavigator = ({ Components }: Props) => {
60
- // @ts-ignore
61
- const { mainStack, currentRoute } = useNavigation();
62
-
63
- // console.log("debug_2", "DEBUG", { mainStack });
64
-
65
- const renderScreen = ({ route, action, key, state }, index) => {
66
- const pathAttributes = getPathAttributes({ pathname: route });
67
-
68
- if (R.isEmpty(pathAttributes)) {
69
- return null;
70
- }
71
-
72
- // console.log("debug_2", "StackNavigator - renderScreen", {
73
- // index,
74
- // route,
75
- // state,
76
- // key,
77
- // action,
78
- // });
79
-
80
- const id = `${route}`;
81
-
82
- return (
83
- <FocusableGroup
84
- id={id}
85
- preferredFocus={route === currentRoute}
86
- excludeFromFocusSearching
87
- key={id}
88
- >
89
- <View style={styles.container}>
90
- <ScreenDataContext.Provider value={state}>
91
- <PathnameContext.Provider value={route}>
92
- <Screen route={route} Components={Components} />
93
- </PathnameContext.Provider>
94
- </ScreenDataContext.Provider>
95
- </View>
96
- </FocusableGroup>
97
- );
98
- };
99
-
100
- return mainStack.map(renderScreen);
101
- };
102
-
103
- const TransitionerTV = ({ componentsExtraProps, Components }: Props) => {
104
- return (
105
- <>
106
- <ScreenLayoutContextProvider>
107
- <StackNavigator
108
- componentsExtraProps={componentsExtraProps}
109
- Components={Components}
110
- />
111
- </ScreenLayoutContextProvider>
112
- </>
113
- );
28
+ ComponentsExtraProps?: ComponentsExtraProps;
29
+ children: React.ReactNode;
114
30
  };
115
31
 
116
- // @ts-ignore
117
32
  const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
118
33
  const navigator = useNavigation();
119
34
  const theme = useTheme();
120
- const { title, visible } = useNavbarState();
121
- const { activeRiver, currentRoute } = navigator;
122
-
123
- const {
124
- appState: { appReady = false } = {},
125
- remoteConfigurations,
126
- plugins = [],
127
- } = usePickFromState(["appState", "remoteConfigurations", "plugins"]);
128
35
 
129
- const navigationProps = getNavigationProps({
130
- navigator,
131
- title,
132
- category: "menu",
133
- });
36
+ const { appState: { appReady = false } = {}, remoteConfigurations } =
37
+ usePickFromState(["appState", "remoteConfigurations", "plugins"]);
134
38
 
135
39
  const backgroundColor = React.useMemo(() => theme.app_background_color, []);
136
40
 
@@ -139,90 +43,34 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
139
43
  [remoteConfigurations]
140
44
  );
141
45
 
142
- const menuPlugin = React.useMemo(
143
- () =>
144
- resolveNavigationPlugin({
145
- category: "menu",
146
- navigations: activeRiver?.navigations,
147
- plugins,
148
- }) as QuickBrickPlugin,
149
- []
150
- );
151
-
152
- const NavBar = React.useMemo(
153
- () => Components.NavBar || (menuPlugin.module as React.ComponentType<any>),
154
- []
155
- );
156
-
157
- const [navBarReady, setNavBarReady] = React.useState(false);
158
-
159
- const navBarContainer = (
160
- <NavBarContainer isVisible={visible} onReady={setNavBarReady}>
161
- <NavBar
162
- ref={ComponentsExtraProps?.NavBar?.ref}
163
- isVisible={visible && !routeIsPlayerScreen(currentRoute)}
164
- menuPlugin={menuPlugin}
165
- navigationProps={navigationProps}
166
- {...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
167
- />
168
- </NavBarContainer>
169
- );
170
-
171
- const isTVOS = isApplePlatform();
172
-
173
46
  if (!appReady) {
174
47
  return null;
175
48
  }
176
49
 
177
50
  return (
178
- // @ts-ignore
179
- <TransitionerTV
180
- componentsExtraProps={ComponentsExtraProps}
181
- Components={Components}
182
- >
183
- <LayoutContainer>
184
- <ScreenLayoutContextProvider>
185
- <Components.Background
186
- backgroundColor={backgroundColor}
187
- backgroundImageUrl={backgroundImageUrl}
188
- {...R.omit(["ref"])(ComponentsExtraProps?.Background)}
189
- >
190
- {!isTVOS ? navBarContainer : null}
191
- {navBarReady ? (
192
- /**
193
- Need to re-mount this component on each navigation event
194
- It's a hack to work around the fact that we don't support
195
- correct screen rendering in our navigator (shared currentRoute state)
196
- **/
197
- <PathnameContext.Provider value={navigator.currentRoute}>
198
- <ScreenContainer>{children}</ScreenContainer>
199
- </PathnameContext.Provider>
200
- ) : null}
201
- {/** Render NavBarContainer over ScreenContainer to let tvOS native
202
- focus manager works correctly to focus nav bar items first **/}
203
- {isTVOS ? navBarContainer : null}
204
- <TransitionOverlay />
205
- </Components.Background>
206
- </ScreenLayoutContextProvider>
207
- </LayoutContainer>
208
- </TransitionerTV>
51
+ <LayoutContainer>
52
+ <ScreenLayoutContextProvider>
53
+ <Components.Background
54
+ backgroundColor={backgroundColor}
55
+ backgroundImageUrl={backgroundImageUrl}
56
+ {...R.omit(["ref"])(ComponentsExtraProps?.Background)}
57
+ >
58
+ <ScreenDataContext.Provider value={navigator.data}>
59
+ <PathnameContext.Provider value={navigator.currentRoute}>
60
+ <ScreenContextProvider pathname={navigator.currentRoute}>
61
+ <ScreenContainer
62
+ ComponentsExtraProps={ComponentsExtraProps}
63
+ NavBar={Components.NavBar}
64
+ >
65
+ {children}
66
+ </ScreenContainer>
67
+ </ScreenContextProvider>
68
+ </PathnameContext.Provider>
69
+ </ScreenDataContext.Provider>
70
+ </Components.Background>
71
+ </ScreenLayoutContextProvider>
72
+ </LayoutContainer>
209
73
  );
210
74
  };
211
75
 
212
76
  export default Layout;
213
-
214
- /// Transitioner:
215
- /*
216
- Component: Transitioner
217
- Responsibilities:
218
- - Transitione between screens.
219
- Tehere is no transition on Tv so no need for transitioner.
220
-
221
- Component: StackNavigator
222
- Responsibilities:
223
- - Render the screens in the stack.
224
- - Render the NavBar? I guess navbar should be part of the screen
225
- - Render the screen.
226
-
227
- Q
228
- */
@@ -0,0 +1,33 @@
1
+ import * as React from "react";
2
+ import { pathOr } from "ramda";
3
+
4
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
+
6
+ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
7
+ import { StackNavigator } from "../../Navigator";
8
+
9
+ type Components = {
10
+ NavBar: React.ComponentType<any>;
11
+ Background: React.ComponentType<any>;
12
+ };
13
+
14
+ type Props = {
15
+ Components: Components;
16
+ };
17
+
18
+ const Layout = ({ Components }: Props) => {
19
+ const { appState } = usePickFromState(["appState"]);
20
+ const appReady = pathOr(false, ["appReady"], appState);
21
+
22
+ if (!appReady) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <ScreenLayoutContextProvider>
28
+ <StackNavigator Components={Components} />
29
+ </ScreenLayoutContextProvider>
30
+ );
31
+ };
32
+
33
+ export default Layout;
@@ -1,20 +1,24 @@
1
1
  import * as React from "react";
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";
2
+ import {
3
+ isTV,
4
+ platformSelect,
5
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
5
6
 
6
7
  import Mobile from "./Mobile";
7
- import TV from "./TV";
8
8
 
9
- export default function Layout(props) {
10
- const { currentRoute: pathname } = useNavigation();
9
+ import TVWeb from "./TV/index.web";
10
+ import TVDefault from "./TV/index";
11
+
12
+ const TV = platformSelect({
13
+ samsung_tv: TVWeb,
14
+ lg_tv: TVWeb,
15
+ web: TVWeb,
16
+ default: TVDefault,
17
+ });
11
18
 
19
+ export default function Layout(props) {
12
20
  if (isTV()) {
13
- return (
14
- <ScreenContextProvider pathname={pathname}>
15
- <TV {...props} />
16
- </ScreenContextProvider>
17
- );
21
+ return <TV {...props} />;
18
22
  } else {
19
23
  return <Mobile {...props} />;
20
24
  }