@applicaster/zapp-react-native-ui-components 12.0.0-rc.8 → 12.0.0-rc.81

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 (135) 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 +19 -108
  27. package/Components/Layout/TV/index.tsx +28 -43
  28. package/Components/Layout/TV/index.web.tsx +33 -0
  29. package/Components/Layout/index.tsx +15 -11
  30. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  31. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -113
  32. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  33. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  34. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  35. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  36. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  37. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  38. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
  39. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  40. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  41. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  42. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  43. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  44. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  45. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  46. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  47. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  48. package/Components/MasterCell/utils/index.ts +33 -35
  49. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  50. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  51. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  52. package/Components/ModalComponent/Button/Item.tsx +82 -0
  53. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  54. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  55. package/Components/ModalComponent/Button/assets.ts +4 -0
  56. package/Components/ModalComponent/Button/index.tsx +111 -0
  57. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  58. package/Components/ModalComponent/Header/Title.tsx +70 -0
  59. package/Components/ModalComponent/Header/assets.ts +4 -0
  60. package/Components/ModalComponent/Header/index.tsx +71 -0
  61. package/Components/ModalComponent/Header/utils.ts +79 -0
  62. package/Components/ModalComponent/index.tsx +38 -0
  63. package/Components/ModalComponent/utils.ts +126 -0
  64. package/Components/Navigator/StackNavigator.tsx +48 -0
  65. package/Components/Navigator/index.ts +1 -0
  66. package/Components/PlayerContainer/PlayerContainer.tsx +69 -31
  67. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  68. package/Components/PlayerImageBackground/index.tsx +34 -8
  69. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  70. package/Components/River/RefreshControl.tsx +55 -1
  71. package/Components/River/River.tsx +8 -5
  72. package/Components/River/TV/River.tsx +2 -25
  73. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  74. package/Components/River/__tests__/componentsMap.test.js +7 -0
  75. package/Components/River/useScreenConfiguration.ts +5 -6
  76. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  77. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  78. package/Components/RouteManager/index.tsx +4 -2
  79. package/Components/Screen/TV/hooks/index.ts +3 -0
  80. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  81. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  82. package/Components/Screen/TV/index.web.tsx +179 -0
  83. package/Components/Screen/__tests__/Screen.test.tsx +51 -36
  84. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  85. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  86. package/Components/Screen/index.tsx +131 -44
  87. package/Components/Screen/navigationHandler.ts +0 -82
  88. package/Components/Screen/orientationHandler.ts +1 -1
  89. package/Components/ScreenResolver/index.tsx +4 -2
  90. package/Components/Tabs/TV/styles.ts +1 -1
  91. package/Components/TrackedView/index.tsx +6 -3
  92. package/Components/Transitioner/Scene.tsx +24 -19
  93. package/Components/Transitioner/Transitioner.tsx +21 -28
  94. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  95. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  96. package/Components/VideoLive/LiveImageManager.ts +60 -14
  97. package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
  98. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  99. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
  100. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  101. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +352 -0
  102. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +158 -0
  103. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +461 -0
  104. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  105. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  106. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  107. package/Components/VideoModal/PlayerDetails.tsx +6 -3
  108. package/Components/VideoModal/PlayerWrapper.tsx +82 -50
  109. package/Components/VideoModal/VideoModal.tsx +23 -40
  110. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  111. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
  112. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +246 -166
  113. package/Components/VideoModal/hooks/useModalSize.ts +13 -4
  114. package/Components/VideoModal/utils.ts +8 -5
  115. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  116. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  117. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  118. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  119. package/Components/Viewport/utils.js +1 -1
  120. package/Components/ZappUIComponent/index.tsx +22 -12
  121. package/Components/index.js +2 -0
  122. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  123. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  124. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  125. package/Contexts/ScreenContext/index.tsx +95 -29
  126. package/Contexts/ScreenDataContext/index.tsx +20 -0
  127. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  128. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  129. package/Decorators/RiverResolver/index.tsx +0 -4
  130. package/Decorators/index.tsx +0 -4
  131. package/events/index.ts +1 -0
  132. package/package.json +5 -6
  133. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  134. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  135. /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,21 @@
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
+ const mockIsOrientationCompatible = jest.fn(() => true);
14
+
15
+ jest.mock("react-native-safe-area-context", () => ({
16
+ useSafeAreaInsets: () => ({ top: 44 }),
17
+ }));
18
+
11
19
  jest.mock("../../RouteManager", () => ({
12
20
  RouteManager: Mocked_RouteManager,
13
21
  }));
@@ -15,6 +23,7 @@ jest.mock("../../RouteManager", () => ({
15
23
  jest.mock(
16
24
  "@applicaster/zapp-react-native-utils/appUtils/orientationHelper",
17
25
  () => ({
26
+ isOrientationCompatible: mockIsOrientationCompatible,
18
27
  allowedOrientationsForScreen: jest.fn(),
19
28
  getOrientation: jest.fn(),
20
29
  getScreenOrientation: jest.fn(),
@@ -25,59 +34,54 @@ jest.mock(
25
34
  })
26
35
  );
27
36
 
28
- let mock_navBarVisibleFlag = true;
29
-
30
- jest.mock("../navigationHandler.ts", () => ({
31
- isNavBarVisible: jest.fn(() => mock_navBarVisibleFlag),
32
- }));
33
-
34
37
  jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
35
38
  useAnalytics: jest.fn(() => ({
36
39
  sendScreenEvent: jest.fn(),
37
40
  })),
38
41
  }));
39
42
 
40
- const {
41
- allowedOrientationsForScreen,
42
- getOrientation,
43
- useGetScreenOrientation,
44
- } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
45
-
46
43
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
47
44
  useTheme: jest.fn(() => ({
48
45
  app_background_color: "blue",
49
46
  })),
50
47
  }));
51
48
 
49
+ const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
50
+
51
+ jest.mock(
52
+ "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers",
53
+ () => ({
54
+ getNavigationPluginModule: () => NavBar,
55
+ })
56
+ );
57
+
52
58
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
53
- useCurrentScreenData: jest.fn(() => ({
59
+ ...(jest.requireActual(
60
+ "@applicaster/zapp-react-native-utils/reactHooks/screen"
61
+ ) as any),
62
+ useScreenData: jest.fn(() => ({
54
63
  id: "testId",
64
+ navigations: [{ id: "testId", category: "nav_bar" }],
55
65
  })),
56
- useNavbarState: jest.fn(() => ({
57
- visible: jest.fn(() => mock_navBarVisibleFlag),
66
+ useCurrentScreenData: jest.fn(() => ({
67
+ id: "testId",
58
68
  })),
59
69
  }));
60
70
 
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
71
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
72
+ isNavBarVisible: mockIsNavBarVisible,
73
73
  useRoute: jest.fn(() => ({
74
74
  pathname: "/river/testId",
75
+ screenData: { id: "testId" },
75
76
  })),
76
77
  useNavigation: jest.fn(() => ({
77
78
  canGoBack: () => false,
78
79
  currentRoute: "/river/testId",
80
+ activeRiver: { id: "testId" },
81
+ screenData: { id: "testId" },
79
82
  data: { screen: { id: "testId" } },
80
83
  })),
84
+ useIsScreenActive: jest.fn().mockReturnValue(true),
81
85
  }));
82
86
 
83
87
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
@@ -95,9 +99,26 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
95
99
  }),
96
100
  }));
97
101
 
102
+ const {
103
+ ORIENTATIONS,
104
+ } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
105
+
106
+ const {
107
+ useCurrentScreenData,
108
+ } = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
109
+
110
+ const {
111
+ allowedOrientationsForScreen,
112
+ getOrientation,
113
+ useGetScreenOrientation,
114
+ } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
115
+
116
+ const navigator = {};
117
+ const navBarProps = { nav_items: [] };
118
+ const screenData = {};
119
+
98
120
  const screenProps = {
99
121
  pathname: "/foo/path",
100
- NavBar,
101
122
  navigator,
102
123
  navBarProps,
103
124
  screenData,
@@ -111,7 +132,6 @@ describe("<Screen Component />", () => {
111
132
  beforeEach(() => {
112
133
  allowedOrientationsForScreen.mockClear();
113
134
  getOrientation.mockClear();
114
- isNavBarVisible.mockClear();
115
135
  useGetScreenOrientation.mockClear();
116
136
  });
117
137
 
@@ -127,14 +147,9 @@ describe("<Screen Component />", () => {
127
147
 
128
148
  describe("when the navbar should be hidden", () => {
129
149
  beforeEach(() => {
130
- mock_navBarVisibleFlag = false;
131
150
  wrapper = create(<Screen {...screenProps} />);
132
151
  });
133
152
 
134
- afterEach(() => {
135
- mock_navBarVisibleFlag = true;
136
- });
137
-
138
153
  it("renders correctly", () => {
139
154
  act(() => {
140
155
  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>