@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
@@ -2,11 +2,17 @@ import React from "react";
2
2
  import { shallow } from "enzyme";
3
3
  import { shallowToJson } from "enzyme-to-json";
4
4
 
5
- import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
6
-
7
5
  const pathname = "/river/A1234";
8
6
  const screenData = { id: "A1234" };
9
7
 
8
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
9
+ useRoute: jest.fn(() => ({ pathname: pathname, screenData: screenData })),
10
+ }));
11
+
12
+ const {
13
+ ScreenResolver,
14
+ } = require("@applicaster/zapp-react-native-ui-components/Components/ScreenResolver");
15
+
10
16
  const { RouteManager } = require("../index");
11
17
 
12
18
  describe("<RouteManager />", () => {
@@ -20,6 +26,7 @@ describe("<RouteManager />", () => {
20
26
 
21
27
  it("passes the correct props to ScreenResolver", () => {
22
28
  expect(wrapper.find(ScreenResolver).props()).toEqual({
29
+ pathname: "/river/A1234",
23
30
  screenType: "river",
24
31
  screenId: "A1234",
25
32
  screenData: { id: "A1234" },
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
5
+ import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
5
6
  import { ScreenResolver } from "../ScreenResolver";
6
7
  import { TestId } from "./TestId";
7
8
 
@@ -12,7 +13,8 @@ type Props = { pathname: string; screenData: Record<string, any> };
12
13
  * and reconciles data returned from hook plugins if needed
13
14
  * @param {Props}: see props above
14
15
  */
15
- export function RouteManager({ pathname, screenData, ...otherProps }: Props) {
16
+ export function RouteManager(props: Props) {
17
+ const { pathname, screenData } = useRoute();
16
18
  const pathAttributes = getPathAttributes({ pathname });
17
19
 
18
20
  const { screenType, screenId } = R.last(pathAttributes);
@@ -22,8 +24,8 @@ export function RouteManager({ pathname, screenData, ...otherProps }: Props) {
22
24
  <ScreenResolver
23
25
  screenType={screenType}
24
26
  screenId={screenId}
27
+ {...props}
25
28
  screenData={screenData}
26
- {...otherProps}
27
29
  />
28
30
  </TestId>
29
31
  );
@@ -0,0 +1,3 @@
1
+ export { useInitialFocus } from "./useInitialFocus";
2
+
3
+ export { useRestoreFocus } from "./useRestoreFocus";
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import {
3
+ useNavigationPluginData,
4
+ useIsNavBarVisible,
5
+ useRoute,
6
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
7
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
+ import {
9
+ setFocusOnContent,
10
+ setFocusOnMenu,
11
+ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
12
+
13
+ type Return =
14
+ | {
15
+ onContent: true;
16
+ onMenu: false;
17
+ }
18
+ | {
19
+ onContent: false;
20
+ onMenu: true;
21
+ };
22
+
23
+ const getInitialFocus = (focusOnContent, isNavBarVisible): Return => {
24
+ if (focusOnContent) {
25
+ return {
26
+ onContent: true,
27
+ onMenu: false,
28
+ };
29
+ }
30
+
31
+ if (!focusOnContent && isNavBarVisible) {
32
+ // put focus on navbar
33
+ return {
34
+ onContent: false,
35
+ onMenu: true,
36
+ };
37
+ }
38
+
39
+ // we don't have navbar, put focus on content anyway
40
+ return {
41
+ onContent: true,
42
+ onMenu: false,
43
+ };
44
+ };
45
+
46
+ export const useInitialFocus = (): void => {
47
+ const navigationPluginData = useNavigationPluginData();
48
+
49
+ const focusOnContent = toBooleanWithDefaultFalse(
50
+ navigationPluginData?.rules?.focus_on_content
51
+ );
52
+
53
+ const isNavBarVisible = useIsNavBarVisible();
54
+
55
+ const { pathname: currentRoute } = useRoute();
56
+
57
+ React.useEffect(() => {
58
+ const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
59
+
60
+ if (initialFocus.onContent) {
61
+ setFocusOnContent(currentRoute);
62
+
63
+ return;
64
+ }
65
+
66
+ if (initialFocus.onMenu) {
67
+ setFocusOnMenu(currentRoute);
68
+ }
69
+ }, []);
70
+ };
@@ -0,0 +1,22 @@
1
+ import * as React from "react";
2
+ import { isNil } from "ramda";
3
+ import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
5
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
6
+
7
+ export const useRestoreFocus = (): void => {
8
+ const isScreenActive = useIsScreenActive();
9
+ const previousIsScreenActive = usePrevious(isScreenActive);
10
+
11
+ React.useEffect(() => {
12
+ if (isNil(previousIsScreenActive)) {
13
+ // it's initial mounting of the screen, do nothing here
14
+ return;
15
+ }
16
+
17
+ if (!previousIsScreenActive && isScreenActive) {
18
+ // restore focus when we go back from next screen
19
+ focusManager.setInitialFocus();
20
+ }
21
+ }, [previousIsScreenActive, isScreenActive]);
22
+ };
@@ -0,0 +1,179 @@
1
+ import * as React from "react";
2
+ import { last, pathOr } from "ramda";
3
+ import { View, StyleSheet } from "react-native";
4
+ import {
5
+ getNavigationProps,
6
+ getPathAttributes,
7
+ resolveNavigationPlugin,
8
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
9
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
10
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
11
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
12
+ import { useScreenBackgroundColor } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
13
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
+
15
+ import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
16
+ import { ScreenResolver } from "../../ScreenResolver";
17
+ import { useInitialFocus, useRestoreFocus } from "./hooks";
18
+
19
+ const styles = StyleSheet.create({
20
+ container: {
21
+ position: "absolute",
22
+ top: 0,
23
+ left: 0,
24
+ right: 0,
25
+ bottom: 0,
26
+ },
27
+ });
28
+
29
+ type Components = {
30
+ NavBar: React.ComponentType<any>;
31
+ Background: React.ComponentType<any>;
32
+ };
33
+
34
+ type Props = {
35
+ route: string;
36
+ Components: Components;
37
+ };
38
+
39
+ const getPluginType = pathOr("unknown_plugin_type", [
40
+ "state",
41
+ "screen",
42
+ "plugin_type",
43
+ ]);
44
+
45
+ const isPlayerPlugin = (routeState): boolean =>
46
+ getPluginType(routeState) === "player";
47
+
48
+ const isLoginPlugin = (routeState): boolean =>
49
+ getPluginType(routeState) === "login";
50
+
51
+ const getActiveRiver = ({
52
+ screenId,
53
+ screenType,
54
+ routeState,
55
+ rivers,
56
+ fallbackActiveRiver,
57
+ }) => {
58
+ if (rivers[screenId]) {
59
+ if (screenType === "hooks") {
60
+ const navigations = routeState?.state?.entry?.payload?.navigations;
61
+
62
+ if (navigations) {
63
+ return routeState.state.entry.payload;
64
+ }
65
+ }
66
+
67
+ return routeState?.state?.screen;
68
+ }
69
+
70
+ // screenId is not presented into rivers, use fallback instead
71
+ return fallbackActiveRiver;
72
+ };
73
+
74
+ const getNavigations = ({
75
+ screenId,
76
+ screenType,
77
+ routeState,
78
+ rivers,
79
+ fallbackNavigations,
80
+ }) => {
81
+ if (rivers[screenId]) {
82
+ // river presents
83
+ if (screenType === "hooks") {
84
+ const navigations = routeState?.state?.entry?.payload?.navigations;
85
+
86
+ if (navigations) {
87
+ return navigations;
88
+ }
89
+ }
90
+
91
+ return routeState?.state?.screen?.navigations;
92
+ }
93
+
94
+ // screenId is not presented into rivers, use fallback instead
95
+ return fallbackNavigations;
96
+ };
97
+
98
+ export const Screen = ({ route, Components }: Props) => {
99
+ if (isNilOrEmpty(route)) {
100
+ throw Error("Required props: route is missing");
101
+ }
102
+
103
+ const navigator = useNavigation();
104
+ const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
105
+
106
+ const pathAttributes = getPathAttributes({ pathname: route });
107
+ const routeState = navigator.getStackForPathname(route);
108
+
109
+ const { screenType, screenId } = last(pathAttributes);
110
+
111
+ const backgroundColor = useScreenBackgroundColor(screenId);
112
+
113
+ useInitialFocus();
114
+ useRestoreFocus();
115
+
116
+ const activeRiver = getActiveRiver({
117
+ screenId,
118
+ screenType,
119
+ routeState,
120
+ rivers,
121
+ fallbackActiveRiver: navigator.activeRiver,
122
+ });
123
+
124
+ const navigationProps = getNavigationProps({
125
+ navigator: {
126
+ // @ts-ignore
127
+ activeRiver,
128
+ // @ts-ignore
129
+ screenTitle: routeState.state.entry?.title || routeState.screen?.name,
130
+ },
131
+ category: "menu",
132
+ });
133
+
134
+ const navigations = getNavigations({
135
+ screenId,
136
+ screenType,
137
+ routeState,
138
+ rivers,
139
+ fallbackNavigations: navigator.activeRiver.navigations,
140
+ });
141
+
142
+ const menuPlugin = resolveNavigationPlugin({
143
+ category: "menu",
144
+ navigations,
145
+ plugins,
146
+ }) as QuickBrickPlugin;
147
+
148
+ const NavBar = (Components.NavBar ||
149
+ menuPlugin.module) as React.ComponentType<any>;
150
+
151
+ const isPlayer = isPlayerPlugin(routeState);
152
+ const isLogin = isLoginPlugin(routeState);
153
+
154
+ const isNavBarVisible = !isPlayer && !isLogin;
155
+
156
+ const screenData =
157
+ screenType === "hooks" || isPlayer
158
+ ? routeState?.state?.entry
159
+ : routeState?.state?.screen;
160
+
161
+ return (
162
+ <View style={[styles.container, { backgroundColor }]}>
163
+ <NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
164
+ <NavBar
165
+ groupId={route}
166
+ isVisible={isNavBarVisible}
167
+ menuPlugin={menuPlugin}
168
+ navigationProps={navigationProps}
169
+ />
170
+ </NavBarContainer>
171
+ <ScreenResolver
172
+ screenType={screenType}
173
+ screenId={screenId}
174
+ screenData={screenData}
175
+ groupId={route}
176
+ />
177
+ </View>
178
+ );
179
+ };
@@ -1,13 +1,19 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { create, act } from "react-test-renderer";
4
-
5
- import { ORIENTATIONS } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
3
+ import { act, create } from "react-test-renderer";
6
4
 
7
5
  const Mocked_RouteManager = jest.fn((props) => (
8
6
  <View testID="routeManager" {...props} />
9
7
  ));
10
8
 
9
+ const mock_navBarVisibleFlag = true;
10
+
11
+ const mockIsNavBarVisible = jest.fn(() => mock_navBarVisibleFlag);
12
+
13
+ jest.mock("react-native-safe-area-context", () => ({
14
+ useSafeAreaInsets: () => ({ top: 44 }),
15
+ }));
16
+
11
17
  jest.mock("../../RouteManager", () => ({
12
18
  RouteManager: Mocked_RouteManager,
13
19
  }));
@@ -25,59 +31,54 @@ jest.mock(
25
31
  })
26
32
  );
27
33
 
28
- let mock_navBarVisibleFlag = true;
29
-
30
- jest.mock("../navigationHandler.ts", () => ({
31
- isNavBarVisible: jest.fn(() => mock_navBarVisibleFlag),
32
- }));
33
-
34
34
  jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
35
35
  useAnalytics: jest.fn(() => ({
36
36
  sendScreenEvent: jest.fn(),
37
37
  })),
38
38
  }));
39
39
 
40
- const {
41
- allowedOrientationsForScreen,
42
- getOrientation,
43
- useGetScreenOrientation,
44
- } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
45
-
46
40
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
47
41
  useTheme: jest.fn(() => ({
48
42
  app_background_color: "blue",
49
43
  })),
50
44
  }));
51
45
 
46
+ const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
47
+
48
+ jest.mock(
49
+ "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers",
50
+ () => ({
51
+ getNavigationPluginModule: () => NavBar,
52
+ })
53
+ );
54
+
52
55
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
53
- useCurrentScreenData: jest.fn(() => ({
56
+ ...(jest.requireActual(
57
+ "@applicaster/zapp-react-native-utils/reactHooks/screen"
58
+ ) as any),
59
+ useScreenData: jest.fn(() => ({
54
60
  id: "testId",
61
+ navigations: [{ id: "testId", category: "nav_bar" }],
55
62
  })),
56
- useNavbarState: jest.fn(() => ({
57
- visible: jest.fn(() => mock_navBarVisibleFlag),
63
+ useCurrentScreenData: jest.fn(() => ({
64
+ id: "testId",
58
65
  })),
59
66
  }));
60
67
 
61
- const {
62
- useCurrentScreenData,
63
- } = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
64
-
65
- const { isNavBarVisible } = require("../navigationHandler");
66
-
67
- const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
68
- const navigator = {};
69
- const navBarProps = { nav_items: [] };
70
- const screenData = {};
71
-
72
68
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
69
+ isNavBarVisible: mockIsNavBarVisible,
73
70
  useRoute: jest.fn(() => ({
74
71
  pathname: "/river/testId",
72
+ screenData: { id: "testId" },
75
73
  })),
76
74
  useNavigation: jest.fn(() => ({
77
75
  canGoBack: () => false,
78
76
  currentRoute: "/river/testId",
77
+ activeRiver: { id: "testId" },
78
+ screenData: { id: "testId" },
79
79
  data: { screen: { id: "testId" } },
80
80
  })),
81
+ useIsScreenActive: jest.fn().mockReturnValue(true),
81
82
  }));
82
83
 
83
84
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
@@ -95,9 +96,26 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
95
96
  }),
96
97
  }));
97
98
 
99
+ const {
100
+ ORIENTATIONS,
101
+ } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
102
+
103
+ const {
104
+ useCurrentScreenData,
105
+ } = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
106
+
107
+ const {
108
+ allowedOrientationsForScreen,
109
+ getOrientation,
110
+ useGetScreenOrientation,
111
+ } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
112
+
113
+ const navigator = {};
114
+ const navBarProps = { nav_items: [] };
115
+ const screenData = {};
116
+
98
117
  const screenProps = {
99
118
  pathname: "/foo/path",
100
- NavBar,
101
119
  navigator,
102
120
  navBarProps,
103
121
  screenData,
@@ -111,7 +129,6 @@ describe("<Screen Component />", () => {
111
129
  beforeEach(() => {
112
130
  allowedOrientationsForScreen.mockClear();
113
131
  getOrientation.mockClear();
114
- isNavBarVisible.mockClear();
115
132
  useGetScreenOrientation.mockClear();
116
133
  });
117
134
 
@@ -127,14 +144,9 @@ describe("<Screen Component />", () => {
127
144
 
128
145
  describe("when the navbar should be hidden", () => {
129
146
  beforeEach(() => {
130
- mock_navBarVisibleFlag = false;
131
147
  wrapper = create(<Screen {...screenProps} />);
132
148
  });
133
149
 
134
- afterEach(() => {
135
- mock_navBarVisibleFlag = true;
136
- });
137
-
138
150
  it("renders correctly", () => {
139
151
  act(() => {
140
152
  wrapper = create(<Screen {...screenProps} />);
@@ -6,17 +6,26 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
6
6
  Object {
7
7
  "backgroundColor": "blue",
8
8
  "flex": 1,
9
+ "paddingTop": 0,
9
10
  }
10
11
  }
11
12
  >
12
13
  <View
13
- nav_items={Array []}
14
+ hasMenu={false}
15
+ id="/river/testId"
16
+ pathname="/river/testId"
17
+ selected="testId"
14
18
  testID="navBar"
19
+ title=""
15
20
  />
16
21
  <View>
17
22
  <View
18
- pathname="/foo/path"
19
- screenData={Object {}}
23
+ pathname="/river/testId"
24
+ screenData={
25
+ Object {
26
+ "id": "testId",
27
+ }
28
+ }
20
29
  testID="routeManager"
21
30
  />
22
31
  </View>
@@ -29,17 +38,26 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
29
38
  Object {
30
39
  "backgroundColor": "blue",
31
40
  "flex": 1,
41
+ "paddingTop": 0,
32
42
  }
33
43
  }
34
44
  >
35
45
  <View
36
- nav_items={Array []}
46
+ hasMenu={false}
47
+ id="/river/testId"
48
+ pathname="/river/testId"
49
+ selected="testId"
37
50
  testID="navBar"
51
+ title=""
38
52
  />
39
53
  <View>
40
54
  <View
41
- pathname="/foo/path"
42
- screenData={Object {}}
55
+ pathname="/river/testId"
56
+ screenData={
57
+ Object {
58
+ "id": "testId",
59
+ }
60
+ }
43
61
  testID="routeManager"
44
62
  />
45
63
  </View>