@applicaster/zapp-react-native-ui-components 12.0.0-rc.14 → 12.0.0-rc.141
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.
- package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/BaseFocusable/index.tsx +3 -3
- package/Components/Cell/Cell.tsx +40 -12
- package/Components/Cell/CellWithFocusable.tsx +40 -19
- package/Components/Cell/TvOSCellComponent.tsx +5 -9
- package/Components/ErrorScreen/index.tsx +1 -1
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/Focusable/__tests__/index.android.test.tsx +72 -0
- package/Components/Focusable/index.android.tsx +15 -9
- package/Components/FocusableCell/index.tsx +7 -7
- package/Components/FocusableGroup/index.tsx +11 -2
- package/Components/FocusableList/FocusableChild.ts +26 -16
- package/Components/FocusableList/FocusableItem.tsx +1 -1
- package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
- package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
- package/Components/FocusableList/index.tsx +37 -37
- package/Components/FocusableScrollView/index.tsx +1 -1
- package/Components/FreezeWithCallback/Freeze.tsx +31 -0
- package/Components/FreezeWithCallback/LICENSE +21 -0
- package/Components/FreezeWithCallback/Suspender.tsx +17 -0
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
- package/Components/FreezeWithCallback/index.tsx +3 -0
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
- package/Components/HookRenderer/index.tsx +1 -6
- package/Components/Image/Image.android.tsx +4 -26
- package/Components/Image/Image.tsx +18 -2
- package/Components/Image/utils/index.ts +39 -0
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +20 -108
- package/Components/Layout/TV/index.tsx +15 -84
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +14 -7
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -117
- package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +27 -9
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +37 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
- package/Components/MasterCell/dataAdapter.ts +21 -7
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/index.tsx +5 -3
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +31 -34
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
- package/Components/ModalComponent/Button/Item.tsx +82 -0
- package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
- package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
- package/Components/ModalComponent/Button/assets.ts +4 -0
- package/Components/ModalComponent/Button/index.tsx +111 -0
- package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
- package/Components/ModalComponent/Header/Title.tsx +70 -0
- package/Components/ModalComponent/Header/assets.ts +4 -0
- package/Components/ModalComponent/Header/index.tsx +71 -0
- package/Components/ModalComponent/Header/utils.ts +79 -0
- package/Components/ModalComponent/index.tsx +38 -0
- package/Components/ModalComponent/utils.ts +126 -0
- package/Components/Navigator/StackNavigator.tsx +57 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +80 -39
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
- package/Components/PlayerImageBackground/index.tsx +34 -8
- package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +2 -25
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
- package/Components/River/__tests__/componentsMap.test.js +7 -0
- package/Components/River/useScreenConfiguration.ts +2 -2
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
- package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
- package/Components/RouteManager/index.tsx +4 -2
- package/Components/Screen/TV/hooks/index.ts +1 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/index.web.tsx +178 -0
- package/Components/Screen/__tests__/Screen.test.tsx +43 -75
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
- package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
- package/Components/Screen/index.tsx +104 -65
- package/Components/Screen/navigationHandler.ts +6 -85
- package/Components/Screen/orientationHandler.ts +18 -7
- package/Components/Screen/utils.ts +16 -0
- package/Components/ScreenResolver/index.tsx +10 -13
- package/Components/Tabs/TV/styles.ts +1 -1
- package/Components/TrackedView/index.tsx +6 -3
- package/Components/Transitioner/Scene.tsx +39 -26
- package/Components/Transitioner/Transitioner.tsx +56 -48
- package/Components/Transitioner/__tests__/Scene.test.js +7 -0
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -0
- package/Components/VideoLive/LiveImageManager.ts +65 -11
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +132 -95
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +24 -27
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +60 -0
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +401 -0
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +172 -0
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +475 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +182 -0
- package/Components/VideoModal/ModalAnimation/index.ts +15 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +302 -0
- package/Components/VideoModal/PlayerDetails.tsx +21 -4
- package/Components/VideoModal/PlayerWrapper.tsx +115 -55
- package/Components/VideoModal/VideoModal.tsx +32 -43
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +6 -1
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +358 -166
- package/Components/VideoModal/hooks/useModalSize.ts +10 -12
- package/Components/VideoModal/utils.ts +8 -5
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
- package/Components/Viewport/ViewportTracker/index.tsx +1 -0
- package/Components/Viewport/utils.js +1 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +7 -3
- package/Components/ZappFrameworkComponents/BarView/Buttons/BackButton.tsx +7 -2
- package/Components/ZappFrameworkComponents/BarView/Buttons/CloseButton.tsx +7 -2
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +87 -0
- package/Components/ZappFrameworkComponents/Buttons/ActionButton.tsx +9 -4
- package/Components/ZappUIComponent/index.tsx +22 -12
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
- package/Components/index.js +2 -0
- package/Contexts/CachedDimensionsContext/index.ts +13 -9
- package/Contexts/ConfirmDialogState/index.ts +1 -1
- package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
- package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
- package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
- package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
- package/Contexts/FocusableGroupContext/index.ts +7 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
- package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
- package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
- package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
- package/Contexts/ScreenContext/index.tsx +101 -30
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
- package/const.ts +6 -0
- package/events/index.ts +1 -0
- package/index.js +3 -0
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
- package/Components/VideoModal/hooks/usePosition.ts +0 -50
- /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
- /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
- /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(
|
|
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 @@
|
|
|
1
|
+
export { useInitialFocus } from "./useInitialFocus";
|
|
@@ -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,178 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { last } from "ramda";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import {
|
|
5
|
+
findMenuPlugin,
|
|
6
|
+
getNavigationProps,
|
|
7
|
+
getPathAttributes,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
9
|
+
import {
|
|
10
|
+
useIsScreenActive,
|
|
11
|
+
useNavigation,
|
|
12
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
13
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
14
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
15
|
+
import {
|
|
16
|
+
useNavbarState,
|
|
17
|
+
useScreenBackgroundColor,
|
|
18
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
19
|
+
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
20
|
+
|
|
21
|
+
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
22
|
+
import { ScreenResolver } from "../../ScreenResolver";
|
|
23
|
+
import { useInitialFocus } from "./hooks";
|
|
24
|
+
import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
25
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
26
|
+
import { FreezeWithCallback } from "../../FreezeWithCallback";
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
container: {
|
|
30
|
+
position: "absolute",
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
bottom: 0,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
type Components = {
|
|
39
|
+
NavBar: React.ComponentType<any>;
|
|
40
|
+
Background: React.ComponentType<any>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type Props = {
|
|
44
|
+
route: string;
|
|
45
|
+
Components: Components;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getActiveRiver = ({
|
|
49
|
+
screenId,
|
|
50
|
+
screenType,
|
|
51
|
+
routeState,
|
|
52
|
+
rivers,
|
|
53
|
+
fallbackActiveRiver,
|
|
54
|
+
}) => {
|
|
55
|
+
if (rivers[screenId]) {
|
|
56
|
+
if (screenType === "hooks") {
|
|
57
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
58
|
+
|
|
59
|
+
if (navigations) {
|
|
60
|
+
return routeState.state.entry.payload;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return routeState?.state?.screen;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// screenId is not presented into rivers, use fallback instead
|
|
68
|
+
return fallbackActiveRiver;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getNavigations = ({
|
|
72
|
+
screenId,
|
|
73
|
+
screenType,
|
|
74
|
+
routeState,
|
|
75
|
+
rivers,
|
|
76
|
+
fallbackNavigations,
|
|
77
|
+
}) => {
|
|
78
|
+
if (rivers[screenId]) {
|
|
79
|
+
// river presents
|
|
80
|
+
if (screenType === "hooks") {
|
|
81
|
+
const navigations = routeState?.state?.entry?.payload?.navigations;
|
|
82
|
+
|
|
83
|
+
if (navigations) {
|
|
84
|
+
return navigations;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return routeState?.state?.screen?.navigations;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// screenId is not presented into rivers, use fallback instead
|
|
92
|
+
return fallbackNavigations;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const Screen = ({ route, Components }: Props) => {
|
|
96
|
+
if (isNilOrEmpty(route)) {
|
|
97
|
+
throw Error("Required props: route is missing");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const navigator = useNavigation();
|
|
101
|
+
const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
|
|
102
|
+
|
|
103
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
104
|
+
const routeState = navigator.getStackForPathname(route);
|
|
105
|
+
|
|
106
|
+
const { screenType, screenId } = last(pathAttributes);
|
|
107
|
+
|
|
108
|
+
const backgroundColor = useScreenBackgroundColor(screenId);
|
|
109
|
+
|
|
110
|
+
useInitialFocus();
|
|
111
|
+
|
|
112
|
+
const activeRiver = getActiveRiver({
|
|
113
|
+
screenId,
|
|
114
|
+
screenType,
|
|
115
|
+
routeState,
|
|
116
|
+
rivers,
|
|
117
|
+
fallbackActiveRiver: navigator.activeRiver,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const navigationProps = getNavigationProps({
|
|
121
|
+
navigator: {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
activeRiver,
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
screenTitle: routeState.state.entry?.title || routeState.screen?.name,
|
|
126
|
+
},
|
|
127
|
+
category: "menu",
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const navigations = getNavigations({
|
|
131
|
+
screenId,
|
|
132
|
+
screenType,
|
|
133
|
+
routeState,
|
|
134
|
+
rivers,
|
|
135
|
+
fallbackNavigations: navigator.activeRiver.navigations,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const menuPlugin = findMenuPlugin(navigations, plugins);
|
|
139
|
+
|
|
140
|
+
const NavBar = (Components.NavBar ||
|
|
141
|
+
menuPlugin.module) as React.ComponentType<any>;
|
|
142
|
+
|
|
143
|
+
const isPlayer = isPlayerPlugin(routeState);
|
|
144
|
+
|
|
145
|
+
const { visible: isNavBarVisible } = useNavbarState();
|
|
146
|
+
|
|
147
|
+
const screenData =
|
|
148
|
+
screenType === "hooks" || isPlayer
|
|
149
|
+
? routeState?.state?.entry
|
|
150
|
+
: routeState?.state?.screen;
|
|
151
|
+
|
|
152
|
+
const isScreenActive = useIsScreenActive();
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<FreezeWithCallback
|
|
156
|
+
freeze={!isScreenActive}
|
|
157
|
+
onRelease={() => {
|
|
158
|
+
focusManager.setInitialFocus();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
162
|
+
<NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
|
|
163
|
+
<NavBar
|
|
164
|
+
isVisible={isNavBarVisible}
|
|
165
|
+
menuPlugin={menuPlugin}
|
|
166
|
+
navigationProps={navigationProps}
|
|
167
|
+
/>
|
|
168
|
+
</NavBarContainer>
|
|
169
|
+
<ScreenResolver
|
|
170
|
+
screenType={screenType}
|
|
171
|
+
screenId={screenId}
|
|
172
|
+
screenData={screenData}
|
|
173
|
+
groupId={route}
|
|
174
|
+
/>
|
|
175
|
+
</View>
|
|
176
|
+
</FreezeWithCallback>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { act, create } from "react-test-renderer";
|
|
4
4
|
|
|
5
5
|
const Mocked_RouteManager = jest.fn((props) => (
|
|
6
6
|
<View testID="routeManager" {...props} />
|
|
7
7
|
));
|
|
8
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
|
+
|
|
9
19
|
jest.mock("../../RouteManager", () => ({
|
|
10
20
|
RouteManager: Mocked_RouteManager,
|
|
11
21
|
}));
|
|
@@ -13,6 +23,7 @@ jest.mock("../../RouteManager", () => ({
|
|
|
13
23
|
jest.mock(
|
|
14
24
|
"@applicaster/zapp-react-native-utils/appUtils/orientationHelper",
|
|
15
25
|
() => ({
|
|
26
|
+
isOrientationCompatible: mockIsOrientationCompatible,
|
|
16
27
|
allowedOrientationsForScreen: jest.fn(),
|
|
17
28
|
getOrientation: jest.fn(),
|
|
18
29
|
getScreenOrientation: jest.fn(),
|
|
@@ -23,59 +34,54 @@ jest.mock(
|
|
|
23
34
|
})
|
|
24
35
|
);
|
|
25
36
|
|
|
26
|
-
let mock_navBarVisibleFlag = true;
|
|
27
|
-
|
|
28
|
-
jest.mock("../navigationHandler.ts", () => ({
|
|
29
|
-
isNavBarVisible: jest.fn(() => mock_navBarVisibleFlag),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
37
|
jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
|
|
33
38
|
useAnalytics: jest.fn(() => ({
|
|
34
39
|
sendScreenEvent: jest.fn(),
|
|
35
40
|
})),
|
|
36
41
|
}));
|
|
37
42
|
|
|
38
|
-
const {
|
|
39
|
-
allowedOrientationsForScreen,
|
|
40
|
-
getOrientation,
|
|
41
|
-
useGetScreenOrientation,
|
|
42
|
-
} = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
|
|
43
|
-
|
|
44
43
|
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
45
44
|
useTheme: jest.fn(() => ({
|
|
46
45
|
app_background_color: "blue",
|
|
47
46
|
})),
|
|
48
47
|
}));
|
|
49
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
|
+
|
|
50
58
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
51
|
-
|
|
59
|
+
...(jest.requireActual(
|
|
60
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen"
|
|
61
|
+
) as any),
|
|
62
|
+
useScreenData: jest.fn(() => ({
|
|
52
63
|
id: "testId",
|
|
64
|
+
navigations: [{ id: "testId", category: "nav_bar" }],
|
|
53
65
|
})),
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
useCurrentScreenData: jest.fn(() => ({
|
|
67
|
+
id: "testId",
|
|
56
68
|
})),
|
|
57
69
|
}));
|
|
58
70
|
|
|
59
|
-
const {
|
|
60
|
-
useCurrentScreenData,
|
|
61
|
-
} = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
62
|
-
|
|
63
|
-
const { isNavBarVisible } = require("../navigationHandler");
|
|
64
|
-
|
|
65
|
-
const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
|
|
66
|
-
const navigator = {};
|
|
67
|
-
const navBarProps = { nav_items: [] };
|
|
68
|
-
const screenData = {};
|
|
69
|
-
|
|
70
71
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
72
|
+
isNavBarVisible: mockIsNavBarVisible,
|
|
71
73
|
useRoute: jest.fn(() => ({
|
|
72
74
|
pathname: "/river/testId",
|
|
75
|
+
screenData: { id: "testId" },
|
|
73
76
|
})),
|
|
74
77
|
useNavigation: jest.fn(() => ({
|
|
75
78
|
canGoBack: () => false,
|
|
76
79
|
currentRoute: "/river/testId",
|
|
80
|
+
activeRiver: { id: "testId" },
|
|
81
|
+
screenData: { id: "testId" },
|
|
77
82
|
data: { screen: { id: "testId" } },
|
|
78
83
|
})),
|
|
84
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
79
85
|
}));
|
|
80
86
|
|
|
81
87
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
@@ -93,9 +99,18 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
|
93
99
|
}),
|
|
94
100
|
}));
|
|
95
101
|
|
|
102
|
+
const {
|
|
103
|
+
allowedOrientationsForScreen,
|
|
104
|
+
getOrientation,
|
|
105
|
+
useGetScreenOrientation,
|
|
106
|
+
} = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
|
|
107
|
+
|
|
108
|
+
const navigator = {};
|
|
109
|
+
const navBarProps = { nav_items: [] };
|
|
110
|
+
const screenData = {};
|
|
111
|
+
|
|
96
112
|
const screenProps = {
|
|
97
113
|
pathname: "/foo/path",
|
|
98
|
-
NavBar,
|
|
99
114
|
navigator,
|
|
100
115
|
navBarProps,
|
|
101
116
|
screenData,
|
|
@@ -109,7 +124,6 @@ describe("<Screen Component />", () => {
|
|
|
109
124
|
beforeEach(() => {
|
|
110
125
|
allowedOrientationsForScreen.mockClear();
|
|
111
126
|
getOrientation.mockClear();
|
|
112
|
-
isNavBarVisible.mockClear();
|
|
113
127
|
useGetScreenOrientation.mockClear();
|
|
114
128
|
});
|
|
115
129
|
|
|
@@ -125,14 +139,9 @@ describe("<Screen Component />", () => {
|
|
|
125
139
|
|
|
126
140
|
describe("when the navbar should be hidden", () => {
|
|
127
141
|
beforeEach(() => {
|
|
128
|
-
mock_navBarVisibleFlag = false;
|
|
129
142
|
wrapper = create(<Screen {...screenProps} />);
|
|
130
143
|
});
|
|
131
144
|
|
|
132
|
-
afterEach(() => {
|
|
133
|
-
mock_navBarVisibleFlag = true;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
145
|
it("renders correctly", () => {
|
|
137
146
|
act(() => {
|
|
138
147
|
wrapper = create(<Screen {...screenProps} />);
|
|
@@ -141,45 +150,4 @@ describe("<Screen Component />", () => {
|
|
|
141
150
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
142
151
|
});
|
|
143
152
|
});
|
|
144
|
-
|
|
145
|
-
// it("invokes the orientation hook when the route changes", () => {
|
|
146
|
-
// act(() => {
|
|
147
|
-
// wrapper = create(<Screen {...screenProps} />);
|
|
148
|
-
// });
|
|
149
|
-
|
|
150
|
-
// // @ts-ignore
|
|
151
|
-
// useCurrentScreenData.mockReturnValue({
|
|
152
|
-
// id: "player-testId",
|
|
153
|
-
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
154
|
-
// plugin_type: "player",
|
|
155
|
-
// });
|
|
156
|
-
|
|
157
|
-
// act(() => {
|
|
158
|
-
// wrapper.update(
|
|
159
|
-
// <Screen
|
|
160
|
-
// {...screenProps}
|
|
161
|
-
// pathname="/playable"
|
|
162
|
-
// screenData={{
|
|
163
|
-
// id: "player-testId",
|
|
164
|
-
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
165
|
-
// plugin_type: "player",
|
|
166
|
-
// }}
|
|
167
|
-
// />
|
|
168
|
-
// );
|
|
169
|
-
// });
|
|
170
|
-
|
|
171
|
-
// useCurrentScreenData.mockReturnValue({
|
|
172
|
-
// id: "player-testId",
|
|
173
|
-
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
174
|
-
// });
|
|
175
|
-
|
|
176
|
-
// act(() => {
|
|
177
|
-
// wrapper.update(<Screen {...screenProps} />);
|
|
178
|
-
// });
|
|
179
|
-
|
|
180
|
-
// expect(allowedOrientationsForScreen).toHaveBeenNthCalledWith(
|
|
181
|
-
// 1,
|
|
182
|
-
// ORIENTATIONS.landscapeSensor
|
|
183
|
-
// );
|
|
184
|
-
// });
|
|
185
153
|
});
|
|
@@ -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
|
-
|
|
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="/
|
|
19
|
-
screenData={
|
|
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
|
-
|
|
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="/
|
|
42
|
-
screenData={
|
|
55
|
+
pathname="/river/testId"
|
|
56
|
+
screenData={
|
|
57
|
+
Object {
|
|
58
|
+
"id": "testId",
|
|
59
|
+
}
|
|
60
|
+
}
|
|
43
61
|
testID="routeManager"
|
|
44
62
|
/>
|
|
45
63
|
</View>
|