@applicaster/zapp-react-native-ui-components 13.0.0-rc.14 → 13.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/AppContainer/__tests__/AppContainer.test.js +4 -6
- package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
- package/Components/AudioPlayer/index.tsx +15 -0
- package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
- package/Components/AudioPlayer/mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap +66 -0
- package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
- package/Components/AudioPlayer/mobile/index.tsx +18 -0
- package/Components/AudioPlayer/tv/Artwork.tsx +40 -0
- package/Components/AudioPlayer/{AudioPlayerLayout.tsx → tv/Layout.tsx} +37 -79
- package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +2 -1
- package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +12 -9
- package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +12 -9
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +5 -8
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +6 -6
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +11 -6
- package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +170 -0
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/channel.test.js.snap +3 -3
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +3 -3
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +3 -3
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +3 -5
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +9 -7
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +3 -5
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +3 -5
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +3 -5
- package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +3 -5
- package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +14 -63
- package/Components/AudioPlayer/types.ts +40 -0
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +67 -31
- package/Components/Cell/Cell.tsx +14 -14
- package/Components/Cell/CellWithFocusable.tsx +50 -59
- package/Components/Cell/CellWrapper.tsx +18 -0
- package/Components/Cell/TvOSCellComponent.tsx +20 -26
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/Cell/index.js +3 -1
- package/Components/Cell/styles.ts +17 -0
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +50 -50
- package/Components/CellRendererResolver/index.ts +2 -1
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +26 -30
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
- package/Components/ErrorScreen/index.tsx +14 -6
- package/Components/Focusable/Focusable.tsx +1 -54
- package/Components/Focusable/FocusableTvOS.tsx +6 -2
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableCell/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
- package/Components/FocusableGroup/index.tsx +0 -3
- package/Components/FocusableList/index.tsx +26 -10
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +5 -3
- package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
- package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
- package/Components/Layout/TV/LayoutBackground.tsx +28 -0
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/ScreenContainer.tsx +8 -2
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +3 -1
- package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +6 -5
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +12 -11
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
- package/Components/Layout/TV/__tests__/index.test.tsx +14 -4
- package/Components/Layout/TV/index.tsx +6 -20
- package/Components/Layout/TV/index.web.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +10 -15
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +11 -19
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +6 -235
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +9 -135
- package/Components/ModalComponent/BottomSheetModalContent.tsx +66 -54
- package/Components/ModalComponent/Button/Item.tsx +6 -5
- package/Components/ModalComponent/Button/assets.ts +1 -1
- package/Components/ModalComponent/Button/index.tsx +45 -62
- package/Components/ModalComponent/Header/index.tsx +12 -11
- package/Components/ModalComponent/utils.ts +55 -7
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
- package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
- package/Components/OfflineHandler/utils/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +76 -66
- package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +2 -2
- package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -68
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RefreshControl.tsx +1 -1
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +44 -4
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +115 -46
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +21 -83
- package/Components/River/__tests__/componentsMap.test.js +64 -17
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/TestId.tsx +1 -5
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -5
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +4 -6
- package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/__tests__/Screen.test.tsx +53 -31
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +6 -6
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -42
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +95 -70
- package/Components/Tabs/Tab.tsx +12 -9
- package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
- package/Components/TextInputTv/index.tsx +6 -5
- package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +53 -24
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +10 -50
- package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +6 -10
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +51 -31
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +8 -4
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +48 -23
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +16 -15
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
- package/Components/VideoModal/ModalAnimation/const.ts +5 -0
- package/Components/VideoModal/ModalAnimation/index.ts +4 -1
- package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +32 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerDetails.tsx +18 -10
- package/Components/VideoModal/PlayerWrapper.tsx +51 -57
- package/Components/VideoModal/VideoModal.tsx +17 -11
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +74 -104
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +51 -0
- package/Components/VideoModal/hooks/index.ts +7 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +38 -0
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
- package/Components/VideoModal/hooks/utils/index.ts +33 -0
- package/Components/VideoModal/utils.ts +6 -9
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +4 -17
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
- package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +6 -12
- package/Contexts/ScreenLayoutContext/index.tsx +5 -3
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
- package/Decorators/RiverFeedLoader/index.tsx +1 -1
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
- package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
- package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +27 -27
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +7 -3
- package/package.json +13 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/AudioPlayer/Artwork.tsx +0 -35
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +0 -123
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -50
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -27
- package/Components/AudioPlayer/index.ts +0 -1
- package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
- package/Components/Cell/CellStyles/Hero/index.js +0 -111
- package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
- package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
- package/Components/Cell/CellStyles/colors.js +0 -40
- package/Components/Cell/CellStyles/index.js +0 -15
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/RiverFeedLoader/utils.ts +0 -100
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
- /package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +0 -0
|
@@ -1,31 +1,46 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { RouteManager } from "../";
|
|
5
|
+
|
|
6
|
+
const mockPathname = "/river/A1234";
|
|
7
|
+
const mockScreenData = { id: "A1234" };
|
|
7
8
|
|
|
8
9
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
9
|
-
useRoute: jest.fn(() => ({
|
|
10
|
+
useRoute: jest.fn(() => ({
|
|
11
|
+
pathname: mockPathname,
|
|
12
|
+
screenData: mockScreenData,
|
|
13
|
+
})),
|
|
10
14
|
}));
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
ScreenResolver,
|
|
14
|
-
|
|
16
|
+
jest.mock(
|
|
17
|
+
"@applicaster/zapp-react-native-ui-components/Components/ScreenResolver",
|
|
18
|
+
() => {
|
|
19
|
+
const { View } = jest.requireActual("react-native");
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
return {
|
|
22
|
+
ScreenResolver: (props) => <View testID="screen-resolver" {...props} />,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
);
|
|
17
26
|
|
|
18
27
|
describe("<RouteManager />", () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
28
|
+
let wrapper;
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
jest.clearAllMocks();
|
|
32
|
+
|
|
33
|
+
wrapper = render(
|
|
34
|
+
<RouteManager pathname={mockPathname} screenData={mockScreenData} />
|
|
35
|
+
);
|
|
36
|
+
});
|
|
22
37
|
|
|
23
38
|
it("renders correctly", () => {
|
|
24
|
-
expect(
|
|
39
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
25
40
|
});
|
|
26
41
|
|
|
27
42
|
it("passes the correct props to ScreenResolver", () => {
|
|
28
|
-
expect(wrapper.
|
|
43
|
+
expect(wrapper.getByTestId("screen-resolver").props).toMatchObject({
|
|
29
44
|
pathname: "/river/A1234",
|
|
30
45
|
screenType: "river",
|
|
31
46
|
screenId: "A1234",
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/* eslint-disable react/prop-types */
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { View, Text } from "react-native";
|
|
5
|
-
|
|
6
|
-
import {
|
|
5
|
+
|
|
6
|
+
import { render } from "@testing-library/react-native";
|
|
7
7
|
|
|
8
8
|
import { TestId } from "../TestId";
|
|
9
9
|
|
|
@@ -17,14 +17,12 @@ const screenId = "A1234";
|
|
|
17
17
|
|
|
18
18
|
describe("TestId", () => {
|
|
19
19
|
it("renders correctly and assigns the testID to a wrapping view", () => {
|
|
20
|
-
const wrapper =
|
|
20
|
+
const wrapper = render(
|
|
21
21
|
<TestId screenId={screenId}>
|
|
22
22
|
<TestComponent name="dev test" />
|
|
23
23
|
</TestId>
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
expect(
|
|
27
|
-
expect(wrapper.find(View).prop("testID")).toEqual(screenId);
|
|
28
|
-
expect(wrapper.find(View).prop("accessibilityLabel")).toEqual(screenId);
|
|
26
|
+
expect(wrapper.getByTestId(screenId)).toBeTruthy();
|
|
29
27
|
});
|
|
30
28
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const {
|
|
2
|
+
useScreenBackgroundColor,
|
|
3
|
+
} = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
4
|
+
|
|
5
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
6
|
+
useScreenBackgroundColor: jest.fn(),
|
|
7
|
+
useNavbarState: jest.fn().mockReturnValue({ visible: true }),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe("TV Screen Component", () => {
|
|
11
|
+
it("uses the useScreenBackgroundColor hook with the correct screen ID", () => {
|
|
12
|
+
useScreenBackgroundColor.mockReturnValue("#FF0000");
|
|
13
|
+
|
|
14
|
+
expect(useScreenBackgroundColor("test-screen-id")).toBe("#FF0000");
|
|
15
|
+
|
|
16
|
+
// Verify the hook was called with the correct screen ID
|
|
17
|
+
expect(useScreenBackgroundColor).toHaveBeenCalledWith("test-screen-id");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("returns 'transparent' when the screen background color is not defined", () => {
|
|
21
|
+
useScreenBackgroundColor.mockReturnValue("transparent");
|
|
22
|
+
|
|
23
|
+
// Verify the hook returns 'transparent'
|
|
24
|
+
expect(useScreenBackgroundColor("test-screen-id")).toBe("transparent");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -92,6 +92,10 @@ const getNavigations = ({
|
|
|
92
92
|
return fallbackNavigations;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
+
const onRelease = () => {
|
|
96
|
+
focusManager.setInitialFocus();
|
|
97
|
+
};
|
|
98
|
+
|
|
95
99
|
export const Screen = ({ route, Components }: Props) => {
|
|
96
100
|
if (isNilOrEmpty(route)) {
|
|
97
101
|
throw Error("Required props: route is missing");
|
|
@@ -152,12 +156,7 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
152
156
|
const isScreenActive = useIsScreenActive();
|
|
153
157
|
|
|
154
158
|
return (
|
|
155
|
-
<FreezeWithCallback
|
|
156
|
-
freeze={!isScreenActive}
|
|
157
|
-
onRelease={() => {
|
|
158
|
-
focusManager.setInitialFocus();
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
159
|
+
<FreezeWithCallback freeze={!isScreenActive} onRelease={onRelease}>
|
|
161
160
|
<View style={[styles.container, { backgroundColor }]}>
|
|
162
161
|
<NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
|
|
163
162
|
<NavBar
|
|
@@ -46,33 +46,43 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
|
46
46
|
})),
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const mockNavBar = jest.fn((props) => {
|
|
50
|
+
const View = jest.requireActual("react-native").View;
|
|
51
|
+
|
|
52
|
+
return <View testID="navBar" {...props} />;
|
|
53
|
+
});
|
|
50
54
|
|
|
51
55
|
jest.mock(
|
|
52
56
|
"@applicaster/zapp-react-native-app/App/Layout/layoutHelpers",
|
|
53
57
|
() => ({
|
|
54
|
-
getNavigationPluginModule: () =>
|
|
58
|
+
getNavigationPluginModule: () => mockNavBar,
|
|
55
59
|
})
|
|
56
60
|
);
|
|
57
61
|
|
|
58
|
-
jest.mock(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
useCurrentScreenData: jest.fn(() => ({
|
|
67
|
-
id: "testId",
|
|
68
|
-
})),
|
|
69
|
-
}));
|
|
62
|
+
jest.mock(
|
|
63
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
|
|
64
|
+
() => ({
|
|
65
|
+
useCurrentScreenData: jest.fn(() => ({
|
|
66
|
+
id: "testId",
|
|
67
|
+
})),
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
70
|
|
|
71
71
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
72
72
|
isNavBarVisible: mockIsNavBarVisible,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
77
|
+
useCurrentScreenData: jest.fn(() => ({
|
|
78
|
+
id: "testId",
|
|
79
|
+
})),
|
|
80
|
+
useNavbarState: jest.fn(() => ({
|
|
81
|
+
title: "Test Title",
|
|
82
|
+
})),
|
|
83
|
+
useScreenData: jest.fn(() => ({
|
|
84
|
+
id: "testId",
|
|
85
|
+
navigations: [{ id: "testId", category: "nav_bar" }],
|
|
76
86
|
})),
|
|
77
87
|
useNavigation: jest.fn(() => ({
|
|
78
88
|
canGoBack: () => false,
|
|
@@ -81,23 +91,35 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
81
91
|
screenData: { id: "testId" },
|
|
82
92
|
data: { screen: { id: "testId" } },
|
|
83
93
|
})),
|
|
84
|
-
|
|
94
|
+
useRoute: jest.fn(() => ({
|
|
95
|
+
pathname: "/river/testId",
|
|
96
|
+
screenData: { id: "testId" },
|
|
97
|
+
})),
|
|
98
|
+
useDimensions: jest.fn(() => ({
|
|
99
|
+
width: 1920,
|
|
100
|
+
height: 1080,
|
|
101
|
+
})),
|
|
102
|
+
useIsTablet: jest.fn(() => false),
|
|
85
103
|
}));
|
|
86
104
|
|
|
87
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks", () =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks/usePickFromState", () => {
|
|
106
|
+
const View = jest.requireActual("react-native").View;
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
usePickFromState: () => ({
|
|
110
|
+
plugins: [
|
|
111
|
+
{
|
|
112
|
+
name: "Offline Plugin",
|
|
113
|
+
identifier: "offline-experience",
|
|
114
|
+
type: "general",
|
|
115
|
+
module: {
|
|
116
|
+
OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
|
|
117
|
+
},
|
|
96
118
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
})
|
|
119
|
+
],
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
});
|
|
101
123
|
|
|
102
124
|
const {
|
|
103
125
|
allowedOrientationsForScreen,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
|
-
|
|
6
|
+
{
|
|
7
7
|
"backgroundColor": "blue",
|
|
8
8
|
"flex": 1,
|
|
9
9
|
"paddingTop": 0,
|
|
@@ -16,13 +16,13 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
16
16
|
pathname="/river/testId"
|
|
17
17
|
selected="testId"
|
|
18
18
|
testID="navBar"
|
|
19
|
-
title=""
|
|
19
|
+
title="Test Title"
|
|
20
20
|
/>
|
|
21
21
|
<View>
|
|
22
22
|
<View
|
|
23
23
|
pathname="/river/testId"
|
|
24
24
|
screenData={
|
|
25
|
-
|
|
25
|
+
{
|
|
26
26
|
"id": "testId",
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -35,7 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
35
35
|
exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
|
|
36
36
|
<View
|
|
37
37
|
style={
|
|
38
|
-
|
|
38
|
+
{
|
|
39
39
|
"backgroundColor": "blue",
|
|
40
40
|
"flex": 1,
|
|
41
41
|
"paddingTop": 0,
|
|
@@ -48,13 +48,13 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
48
48
|
pathname="/river/testId"
|
|
49
49
|
selected="testId"
|
|
50
50
|
testID="navBar"
|
|
51
|
-
title=""
|
|
51
|
+
title="Test Title"
|
|
52
52
|
/>
|
|
53
53
|
<View>
|
|
54
54
|
<View
|
|
55
55
|
pathname="/river/testId"
|
|
56
56
|
screenData={
|
|
57
|
-
|
|
57
|
+
{
|
|
58
58
|
"id": "testId",
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
2
|
+
import {
|
|
3
|
+
useGetScreenOrientation,
|
|
4
|
+
isOrientationCompatible,
|
|
5
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
6
|
+
import {
|
|
7
|
+
useCurrentScreenData,
|
|
8
|
+
useDimensions,
|
|
9
|
+
useRoute,
|
|
10
|
+
useIsTablet,
|
|
11
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { useMemo, useEffect, useState } from "react";
|
|
13
|
+
|
|
14
|
+
export const useWaitForValidOrientation = () => {
|
|
15
|
+
const { width: screenWidth, height } = useDimensions("screen", {
|
|
16
|
+
fullDimensions: true,
|
|
17
|
+
updateForInactiveScreens: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const currentScreenData = useCurrentScreenData();
|
|
21
|
+
|
|
22
|
+
const { screenData } = useRoute();
|
|
23
|
+
|
|
24
|
+
const [readyState, setReadyState] = useState(false);
|
|
25
|
+
|
|
26
|
+
const isTablet = useIsTablet();
|
|
27
|
+
|
|
28
|
+
const { appData } = usePickFromState(["appData"]);
|
|
29
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
30
|
+
|
|
31
|
+
const layoutData = useMemo(
|
|
32
|
+
() => ({ isTablet, isTabletPortrait, width: screenWidth, height }),
|
|
33
|
+
[isTablet, isTabletPortrait, screenWidth, height]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const targetScreenData =
|
|
37
|
+
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
38
|
+
|
|
39
|
+
const orientation = useGetScreenOrientation(targetScreenData);
|
|
40
|
+
|
|
41
|
+
const isReadyForDisplay = isOrientationCompatible({
|
|
42
|
+
orientation,
|
|
43
|
+
layoutData,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (isReadyForDisplay && !readyState) {
|
|
48
|
+
setReadyState(true);
|
|
49
|
+
}
|
|
50
|
+
}, [readyState, orientation, layoutData]);
|
|
51
|
+
|
|
52
|
+
return readyState;
|
|
53
|
+
};
|
|
@@ -2,31 +2,27 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
|
-
import {
|
|
6
|
-
isOrientationCompatible,
|
|
7
|
-
useGetScreenOrientation,
|
|
8
|
-
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
9
5
|
|
|
10
6
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
11
7
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
12
8
|
import {
|
|
13
|
-
shouldNavBarDisplayMenu,
|
|
14
9
|
getNavBarProps,
|
|
15
10
|
getScreenId,
|
|
11
|
+
shouldNavBarDisplayMenu,
|
|
16
12
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
17
13
|
import {
|
|
18
|
-
useDimensions,
|
|
19
|
-
useRoute,
|
|
20
14
|
useCurrentScreenData,
|
|
21
15
|
useNavbarState,
|
|
22
|
-
useScreenData,
|
|
23
16
|
useNavigation,
|
|
17
|
+
useRoute,
|
|
18
|
+
useScreenData,
|
|
24
19
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
25
20
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
26
21
|
|
|
27
22
|
import { RouteManager } from "../RouteManager";
|
|
28
23
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
29
24
|
import { isValidColor } from "./utils";
|
|
25
|
+
import { useWaitForValidOrientation } from "./hooks";
|
|
30
26
|
|
|
31
27
|
const screenStyles = {
|
|
32
28
|
flex: 1,
|
|
@@ -50,14 +46,6 @@ export function Screen(_props: Props) {
|
|
|
50
46
|
const currentScreenData = useCurrentScreenData();
|
|
51
47
|
const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
|
|
52
48
|
|
|
53
|
-
const {
|
|
54
|
-
width: screenWidth,
|
|
55
|
-
height,
|
|
56
|
-
deviceInfo,
|
|
57
|
-
} = useDimensions("screen", {
|
|
58
|
-
fullDimensions: true,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
49
|
const { screenData, pathname } = useRoute();
|
|
62
50
|
|
|
63
51
|
const currentRiver = useScreenData(
|
|
@@ -66,13 +54,6 @@ export function Screen(_props: Props) {
|
|
|
66
54
|
|
|
67
55
|
const { title } = useNavbarState();
|
|
68
56
|
|
|
69
|
-
const isTablet = deviceInfo?.isTablet;
|
|
70
|
-
|
|
71
|
-
const { appData } = usePickFromState(["appData"]);
|
|
72
|
-
const isTabletPortrait = appData?.isTabletPortrait;
|
|
73
|
-
|
|
74
|
-
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
75
|
-
|
|
76
57
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
77
58
|
|
|
78
59
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
@@ -108,30 +89,23 @@ export function Screen(_props: Props) {
|
|
|
108
89
|
[theme.app_background_color, backgroundColor]
|
|
109
90
|
);
|
|
110
91
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const orientation = useGetScreenOrientation(targetScreenData);
|
|
92
|
+
// Set ready state when screen is rotated to desired orientation
|
|
93
|
+
const isReady = useWaitForValidOrientation();
|
|
115
94
|
|
|
116
95
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
117
96
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
118
|
-
if (
|
|
119
|
-
!isOrientationCompatible({
|
|
120
|
-
orientation,
|
|
121
|
-
layoutData,
|
|
122
|
-
})
|
|
123
|
-
) {
|
|
124
|
-
return <View style={style} />;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
97
|
return (
|
|
128
98
|
<View style={style}>
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
99
|
+
{isReady ? (
|
|
100
|
+
<>
|
|
101
|
+
{navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
|
|
102
|
+
|
|
103
|
+
<OfflineFallbackScreen>
|
|
104
|
+
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
105
|
+
<RouteManager pathname={pathname} screenData={screenData} />
|
|
106
|
+
</OfflineFallbackScreen>
|
|
107
|
+
</>
|
|
108
|
+
) : null}
|
|
135
109
|
</View>
|
|
136
110
|
);
|
|
137
111
|
}
|