@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 15.0.0-alpha.1351496011
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/AnimatedInOut/index.tsx +5 -3
- package/Components/AudioPlayer/index.tsx +15 -0
- package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
- package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
- package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
- package/Components/AudioPlayer/mobile/index.tsx +18 -0
- package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
- package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
- package/Components/AudioPlayer/tv/Layout.tsx +168 -0
- package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
- package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
- package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
- package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
- package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
- package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
- package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
- package/Components/AudioPlayer/types.ts +40 -0
- package/Components/BaseFocusable/index.tsx +23 -12
- package/Components/Cell/Cell.tsx +91 -64
- package/Components/Cell/CellWithFocusable.tsx +3 -0
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
- package/Components/Cell/index.js +7 -3
- package/Components/ComponentResolver/index.ts +1 -1
- package/Components/FeedLoader/FeedLoader.tsx +7 -16
- package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
- package/Components/FeedLoader/index.js +2 -8
- package/Components/Focusable/Focusable.tsx +12 -3
- package/Components/Focusable/FocusableTvOS.tsx +5 -5
- package/Components/Focusable/FocusableiOS.tsx +2 -2
- package/Components/Focusable/Touchable.tsx +5 -3
- package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
- package/Components/Focusable/index.android.tsx +19 -11
- package/Components/Focusable/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
- package/Components/FocusableList/FocusableItem.tsx +4 -3
- package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
- package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
- package/Components/FocusableList/index.tsx +20 -9
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -21
- package/Components/HandlePlayable/HandlePlayable.tsx +25 -9
- package/Components/HookRenderer/HookRenderer.tsx +5 -1
- package/Components/Layout/TV/LayoutBackground.tsx +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
- package/Components/MasterCell/elementMapper.tsx +1 -2
- package/Components/MasterCell/index.tsx +1 -1
- package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
- package/Components/MasterCell/utils/index.ts +11 -5
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
- package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +46 -33
- package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
- package/Components/PlayerContainer/index.ts +1 -1
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -43
- package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
- package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
- package/Components/River/RefreshControl.tsx +11 -17
- package/Components/River/RiverItem.tsx +3 -0
- package/Components/River/TV/River.tsx +2 -17
- package/Components/River/TV/index.tsx +3 -1
- package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
- package/Components/River/TV/withRiverDataLoader.tsx +17 -0
- package/Components/River/TV/withTVEventHandler.tsx +1 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/River/__tests__/river.test.js +12 -26
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/TV/hooks/useInitialFocus.ts +16 -4
- package/Components/Screen/__tests__/Screen.test.tsx +28 -29
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
- package/Components/Screen/index.tsx +22 -5
- package/Components/Screen/navigationHandler.ts +20 -2
- package/Components/ScreenResolver/index.tsx +22 -1
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
- package/Components/ScreenRevealManager/index.ts +1 -0
- package/Components/ScreenRevealManager/utils/index.ts +25 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +91 -0
- package/Components/Tabs/TV/Tabs.android.tsx +1 -3
- package/Components/Tabs/Tabs.tsx +2 -3
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
- package/Components/TextInputTv/index.tsx +11 -0
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
- package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
- package/Components/VideoLive/animationUtils.ts +3 -3
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +6 -10
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +73 -29
- package/Components/VideoModal/PlayerDetails.tsx +29 -7
- package/Components/VideoModal/PlayerWrapper.tsx +26 -142
- package/Components/VideoModal/VideoModal.tsx +3 -17
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
- package/Components/VideoModal/hooks/index.ts +0 -2
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
- package/Components/VideoModal/hooks/useModalSize.ts +18 -2
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
- package/Components/VideoModal/hooks/utils/index.ts +4 -0
- package/Components/VideoModal/utils.ts +6 -0
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
- package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
- package/Contexts/CellFocusedStateContext/index.tsx +27 -0
- package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
- package/Contexts/ScreenContext/index.tsx +46 -6
- package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
- package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
- package/Decorators/RiverFeedLoader/index.tsx +22 -4
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
- package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
- package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
- package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
- package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
- package/Decorators/ZappPipesDataConnector/types.ts +29 -0
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
- package/events/index.ts +3 -0
- package/package.json +5 -10
- package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
- package/Components/AudioPlayer/index.ts +0 -1
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
- package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +0 -0
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import configureStore from "redux-mock-store";
|
|
2
|
+
import { screen } from "@testing-library/react-native";
|
|
4
3
|
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
|
-
import { Provider } from "react-redux";
|
|
6
4
|
|
|
7
|
-
import { River } from "../";
|
|
8
5
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
9
6
|
import { RiverComponent } from "../River";
|
|
10
7
|
|
|
11
|
-
jest.mock(
|
|
12
|
-
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
13
|
-
() => ({
|
|
14
|
-
useIsScreenActive: jest.fn(() => true),
|
|
15
|
-
})
|
|
16
|
-
);
|
|
17
|
-
|
|
18
8
|
jest.mock(
|
|
19
9
|
"@applicaster/zapp-react-native-ui-components/Components/GeneralContentScreen",
|
|
20
10
|
() => {
|
|
@@ -46,6 +36,13 @@ jest.mock(
|
|
|
46
36
|
})
|
|
47
37
|
);
|
|
48
38
|
|
|
39
|
+
jest.mock(
|
|
40
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
41
|
+
() => ({
|
|
42
|
+
useIsScreenActive: jest.fn(() => true),
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
|
|
49
46
|
const river = {
|
|
50
47
|
home: true,
|
|
51
48
|
id: "A1234",
|
|
@@ -89,28 +86,17 @@ const riverProps = {
|
|
|
89
86
|
|
|
90
87
|
const appData = { layoutVersion: "v1" };
|
|
91
88
|
|
|
92
|
-
const store =
|
|
89
|
+
const store = { rivers, appData };
|
|
93
90
|
|
|
94
91
|
describe("When River has a general_content type", () => {
|
|
95
92
|
it("renders GeneralContentScreen correctly", () => {
|
|
96
|
-
const { getByTestId } =
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
</Provider>
|
|
93
|
+
const { getByTestId } = renderWithProviders(
|
|
94
|
+
<RiverComponent {...riverProps} />,
|
|
95
|
+
store
|
|
100
96
|
);
|
|
101
97
|
|
|
102
98
|
expect(getByTestId("general-content-screen")).toBeTruthy();
|
|
103
99
|
});
|
|
104
|
-
|
|
105
|
-
it("renders River component correctly", () => {
|
|
106
|
-
const wrapper = render(
|
|
107
|
-
<Provider store={store}>
|
|
108
|
-
<River screenId="A1234" />
|
|
109
|
-
</Provider>
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
113
|
-
});
|
|
114
100
|
});
|
|
115
101
|
|
|
116
102
|
describe("When River has any other type other than general_content", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
2
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
3
3
|
|
|
4
4
|
import { withRiver } from "../../Decorators/RiverResolver";
|
|
5
5
|
import { withNavigator } from "../../Decorators/Navigator";
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
setFocusOnMenu,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
|
|
12
12
|
|
|
13
|
+
import { waitUntilScreenRevealManagerIsReady } from "@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils";
|
|
14
|
+
|
|
13
15
|
type Return =
|
|
14
16
|
| {
|
|
15
17
|
onContent: true;
|
|
@@ -57,14 +59,24 @@ export const useInitialFocus = (): void => {
|
|
|
57
59
|
React.useEffect(() => {
|
|
58
60
|
const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
console.log("debug_2", "useInitialFocus - effect", { initialFocus });
|
|
63
|
+
|
|
64
|
+
if (initialFocus.onMenu) {
|
|
65
|
+
setFocusOnMenu(currentRoute);
|
|
62
66
|
|
|
63
67
|
return;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
if (initialFocus.
|
|
67
|
-
|
|
70
|
+
if (initialFocus.onContent) {
|
|
71
|
+
const subscription = waitUntilScreenRevealManagerIsReady().subscribe(
|
|
72
|
+
() => {
|
|
73
|
+
setFocusOnContent(currentRoute);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return () => {
|
|
78
|
+
subscription.unsubscribe();
|
|
79
|
+
};
|
|
68
80
|
}
|
|
69
81
|
}, []);
|
|
70
82
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
|
|
5
5
|
const Mocked_RouteManager = jest.fn((props) => (
|
|
6
6
|
<View testID="routeManager" {...props} />
|
|
@@ -68,12 +68,33 @@ jest.mock(
|
|
|
68
68
|
})
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
+
jest.mock(
|
|
72
|
+
"@applicaster/zapp-react-native-utils/reactHooks/state/useRivers",
|
|
73
|
+
() => ({
|
|
74
|
+
useRivers: jest.fn(() => ({
|
|
75
|
+
rivers: [{ id: "testId", name: "Test River" }],
|
|
76
|
+
})),
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
|
|
71
80
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
72
81
|
isNavBarVisible: mockIsNavBarVisible,
|
|
73
82
|
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
83
|
+
useNavigation: jest.fn(() => ({
|
|
84
|
+
canGoBack: () => false,
|
|
85
|
+
currentRoute: "/river/testId",
|
|
86
|
+
activeRiver: { id: "testId" },
|
|
87
|
+
screenData: { id: "testId" },
|
|
88
|
+
data: { screen: { id: "testId" } },
|
|
89
|
+
})),
|
|
90
|
+
useRoute: jest.fn(() => ({
|
|
91
|
+
pathname: "/river/testId",
|
|
92
|
+
screenData: { id: "testId" },
|
|
93
|
+
})),
|
|
74
94
|
}));
|
|
75
95
|
|
|
76
96
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
97
|
+
...jest.requireActual("@applicaster/zapp-react-native-utils/reactHooks"),
|
|
77
98
|
useCurrentScreenData: jest.fn(() => ({
|
|
78
99
|
id: "testId",
|
|
79
100
|
})),
|
|
@@ -84,17 +105,6 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
|
84
105
|
id: "testId",
|
|
85
106
|
navigations: [{ id: "testId", category: "nav_bar" }],
|
|
86
107
|
})),
|
|
87
|
-
useNavigation: jest.fn(() => ({
|
|
88
|
-
canGoBack: () => false,
|
|
89
|
-
currentRoute: "/river/testId",
|
|
90
|
-
activeRiver: { id: "testId" },
|
|
91
|
-
screenData: { id: "testId" },
|
|
92
|
-
data: { screen: { id: "testId" } },
|
|
93
|
-
})),
|
|
94
|
-
useRoute: jest.fn(() => ({
|
|
95
|
-
pathname: "/river/testId",
|
|
96
|
-
screenData: { id: "testId" },
|
|
97
|
-
})),
|
|
98
108
|
useDimensions: jest.fn(() => ({
|
|
99
109
|
width: 1920,
|
|
100
110
|
height: 1080,
|
|
@@ -102,10 +112,11 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
|
102
112
|
useIsTablet: jest.fn(() => false),
|
|
103
113
|
}));
|
|
104
114
|
|
|
105
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks
|
|
115
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => {
|
|
106
116
|
const View = jest.requireActual("react-native").View;
|
|
107
117
|
|
|
108
118
|
return {
|
|
119
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
|
|
109
120
|
usePickFromState: () => ({
|
|
110
121
|
plugins: [
|
|
111
122
|
{
|
|
@@ -141,8 +152,6 @@ const screenProps = {
|
|
|
141
152
|
const { Screen } = require("..");
|
|
142
153
|
|
|
143
154
|
describe("<Screen Component />", () => {
|
|
144
|
-
let wrapper;
|
|
145
|
-
|
|
146
155
|
beforeEach(() => {
|
|
147
156
|
allowedOrientationsForScreen.mockClear();
|
|
148
157
|
getOrientation.mockClear();
|
|
@@ -150,26 +159,16 @@ describe("<Screen Component />", () => {
|
|
|
150
159
|
});
|
|
151
160
|
|
|
152
161
|
describe("when the navbar should show", () => {
|
|
153
|
-
act(() => {
|
|
154
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
162
|
it("renders correctly", () => {
|
|
158
|
-
|
|
163
|
+
const { toJSON } = render(<Screen {...screenProps} />);
|
|
164
|
+
expect(toJSON()).toMatchSnapshot();
|
|
159
165
|
});
|
|
160
166
|
});
|
|
161
167
|
|
|
162
168
|
describe("when the navbar should be hidden", () => {
|
|
163
|
-
beforeEach(() => {
|
|
164
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
169
|
it("renders correctly", () => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
170
|
+
const { toJSON } = render(<Screen {...screenProps} />);
|
|
171
|
+
expect(toJSON()).toMatchSnapshot();
|
|
173
172
|
});
|
|
174
173
|
});
|
|
175
174
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
importantForAccessibility="yes"
|
|
5
6
|
style={
|
|
6
7
|
{
|
|
7
8
|
"backgroundColor": "blue",
|
|
@@ -34,6 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
34
35
|
|
|
35
36
|
exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
|
|
36
37
|
<View
|
|
38
|
+
importantForAccessibility="yes"
|
|
37
39
|
style={
|
|
38
40
|
{
|
|
39
41
|
"backgroundColor": "blue",
|
|
@@ -3,61 +3,172 @@ import { isMenuVisible } from "../navigationHandler";
|
|
|
3
3
|
describe("NavigationHandler", () => {
|
|
4
4
|
describe("isMenuVisible", () => {
|
|
5
5
|
it("returns false when the route is a player route", () => {
|
|
6
|
-
const menuVisible = isMenuVisible("/playable/some_vod_item", {}
|
|
6
|
+
const menuVisible = isMenuVisible("/playable/some_vod_item", {}, [
|
|
7
|
+
{
|
|
8
|
+
identifier: "quick-brick-bottom-tabs",
|
|
9
|
+
category: "menu",
|
|
10
|
+
name: "Bottom Tabs",
|
|
11
|
+
},
|
|
12
|
+
]);
|
|
13
|
+
|
|
7
14
|
expect(menuVisible).toBe(false);
|
|
8
15
|
});
|
|
9
16
|
|
|
10
17
|
describe("when screen is a hook", () => {
|
|
11
18
|
it("returns true if the `showNavBar` flag is set to true", () => {
|
|
12
|
-
const menuVisible = isMenuVisible(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
const menuVisible = isMenuVisible(
|
|
20
|
+
"",
|
|
21
|
+
{
|
|
22
|
+
hookPlugin: {
|
|
23
|
+
module: {
|
|
24
|
+
showNavBar: true,
|
|
25
|
+
},
|
|
16
26
|
},
|
|
27
|
+
navigations: [
|
|
28
|
+
{
|
|
29
|
+
navigation_type: "quick-brick-bottom-tabs",
|
|
30
|
+
identifier: "quick-brick-bottom-tabs",
|
|
31
|
+
category: "menu",
|
|
32
|
+
name: "Bottom Tabs",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
17
35
|
},
|
|
18
|
-
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
identifier: "quick-brick-bottom-tabs",
|
|
39
|
+
category: "menu",
|
|
40
|
+
name: "Bottom Tabs",
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
);
|
|
19
44
|
|
|
20
45
|
expect(menuVisible).toBe(true);
|
|
21
46
|
});
|
|
22
47
|
|
|
23
48
|
it("returns true if presentFullScreen flag is set to false", () => {
|
|
24
|
-
const menuVisible = isMenuVisible(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
const menuVisible = isMenuVisible(
|
|
50
|
+
"",
|
|
51
|
+
{
|
|
52
|
+
hookPlugin: {
|
|
53
|
+
module: {
|
|
54
|
+
presentFullScreen: false,
|
|
55
|
+
},
|
|
28
56
|
},
|
|
57
|
+
navigations: [
|
|
58
|
+
{
|
|
59
|
+
navigation_type: "quick-brick-bottom-tabs",
|
|
60
|
+
identifier: "quick-brick-bottom-tabs",
|
|
61
|
+
category: "menu",
|
|
62
|
+
name: "Bottom Tabs",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
29
65
|
},
|
|
30
|
-
|
|
66
|
+
[
|
|
67
|
+
{
|
|
68
|
+
identifier: "quick-brick-bottom-tabs",
|
|
69
|
+
category: "menu",
|
|
70
|
+
name: "Bottom Tabs",
|
|
71
|
+
},
|
|
72
|
+
]
|
|
73
|
+
);
|
|
31
74
|
|
|
32
75
|
expect(menuVisible).toBe(true);
|
|
33
76
|
});
|
|
34
77
|
|
|
35
78
|
it("returns false if presentFullScreen flag is set to true", () => {
|
|
36
|
-
const menuVisible = isMenuVisible(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
79
|
+
const menuVisible = isMenuVisible(
|
|
80
|
+
"",
|
|
81
|
+
{
|
|
82
|
+
hookPlugin: {
|
|
83
|
+
module: {
|
|
84
|
+
presentFullScreen: true,
|
|
85
|
+
},
|
|
40
86
|
},
|
|
87
|
+
navigations: [
|
|
88
|
+
{
|
|
89
|
+
navigation_type: "quick-brick-bottom-tabs",
|
|
90
|
+
identifier: "quick-brick-bottom-tabs",
|
|
91
|
+
category: "menu",
|
|
92
|
+
name: "Bottom Tabs",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
41
95
|
},
|
|
42
|
-
|
|
96
|
+
[
|
|
97
|
+
{
|
|
98
|
+
identifier: "quick-brick-bottom-tabs",
|
|
99
|
+
category: "menu",
|
|
100
|
+
name: "Bottom Tabs",
|
|
101
|
+
},
|
|
102
|
+
]
|
|
103
|
+
);
|
|
43
104
|
|
|
44
105
|
expect(menuVisible).toBe(false);
|
|
45
106
|
});
|
|
46
107
|
});
|
|
47
108
|
|
|
48
109
|
it("returns false if the screen's general settings allow screen presentation", () => {
|
|
49
|
-
const menuVisible = isMenuVisible(
|
|
50
|
-
|
|
51
|
-
|
|
110
|
+
const menuVisible = isMenuVisible(
|
|
111
|
+
"",
|
|
112
|
+
{
|
|
113
|
+
general: {
|
|
114
|
+
allow_screen_plugin_presentation: true,
|
|
115
|
+
},
|
|
116
|
+
navigations: [
|
|
117
|
+
{
|
|
118
|
+
navigation_type: "quick-brick-bottom-tabs",
|
|
119
|
+
identifier: "quick-brick-bottom-tabs",
|
|
120
|
+
category: "menu",
|
|
121
|
+
name: "Bottom Tabs",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
52
124
|
},
|
|
53
|
-
|
|
125
|
+
[
|
|
126
|
+
{
|
|
127
|
+
identifier: "quick-brick-bottom-tabs",
|
|
128
|
+
category: "menu",
|
|
129
|
+
name: "Bottom Tabs",
|
|
130
|
+
},
|
|
131
|
+
]
|
|
132
|
+
);
|
|
54
133
|
|
|
55
134
|
expect(menuVisible).toBe(false);
|
|
56
135
|
});
|
|
57
136
|
|
|
58
|
-
it("returns
|
|
59
|
-
const menuVisible = isMenuVisible(
|
|
137
|
+
it("returns false otherwise", () => {
|
|
138
|
+
const menuVisible = isMenuVisible(
|
|
139
|
+
"any",
|
|
140
|
+
{
|
|
141
|
+
navigations: [
|
|
142
|
+
{
|
|
143
|
+
navigation_type: "quick-brick-bottom-tabs",
|
|
144
|
+
identifier: "quick-brick-bottom-tabs",
|
|
145
|
+
category: "menu",
|
|
146
|
+
name: "Bottom Tabs",
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
[
|
|
151
|
+
{
|
|
152
|
+
identifier: "quick-brick-bottom-tabs",
|
|
153
|
+
category: "menu",
|
|
154
|
+
name: "Bottom Tabs",
|
|
155
|
+
},
|
|
156
|
+
]
|
|
157
|
+
);
|
|
158
|
+
|
|
60
159
|
expect(menuVisible).toBe(true);
|
|
61
160
|
});
|
|
161
|
+
|
|
162
|
+
it("returns false otherwise", () => {
|
|
163
|
+
const menuVisible = isMenuVisible("", {}, [
|
|
164
|
+
{
|
|
165
|
+
identifier: "quick-brick-bottom-tabs",
|
|
166
|
+
category: "menu",
|
|
167
|
+
name: "Bottom Tabs",
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
expect(menuVisible).toBe(false);
|
|
172
|
+
});
|
|
62
173
|
});
|
|
63
174
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { View } from "react-native";
|
|
3
|
+
import { AccessibilityInfo, findNodeHandle, View } from "react-native";
|
|
4
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
5
|
|
|
6
6
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
13
13
|
import {
|
|
14
14
|
useCurrentScreenData,
|
|
15
|
+
useIsScreenActive,
|
|
15
16
|
useNavbarState,
|
|
16
17
|
useNavigation,
|
|
17
18
|
useRoute,
|
|
@@ -57,8 +58,8 @@ export function Screen(_props: Props) {
|
|
|
57
58
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
58
59
|
|
|
59
60
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
60
|
-
getNavBarProps(currentRiver, pathname, title),
|
|
61
|
-
[currentRiver, pathname]
|
|
61
|
+
() => getNavBarProps(currentRiver, pathname, title),
|
|
62
|
+
[currentRiver, pathname, title]
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
const NavBar = React.useMemo(
|
|
@@ -89,13 +90,29 @@ export function Screen(_props: Props) {
|
|
|
89
90
|
[theme.app_background_color, backgroundColor]
|
|
90
91
|
);
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
const isActive = useIsScreenActive();
|
|
94
|
+
|
|
95
|
+
const ref = React.useRef(null);
|
|
93
96
|
const isReady = useWaitForValidOrientation();
|
|
94
97
|
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (ref.current && isActive && isReady) {
|
|
100
|
+
const nodeHandle = findNodeHandle(ref.current);
|
|
101
|
+
|
|
102
|
+
if (nodeHandle != null) {
|
|
103
|
+
AccessibilityInfo.setAccessibilityFocus(nodeHandle);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [isActive, isReady]);
|
|
107
|
+
|
|
95
108
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
96
109
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
97
110
|
return (
|
|
98
|
-
<View
|
|
111
|
+
<View
|
|
112
|
+
ref={ref}
|
|
113
|
+
style={style}
|
|
114
|
+
importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
|
|
115
|
+
>
|
|
99
116
|
{isReady ? (
|
|
100
117
|
<>
|
|
101
118
|
{navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveNavigationPlugin } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* This function helps to decide wether the menu should be presented on the screen
|
|
3
5
|
* based on route and / or screen Data
|
|
@@ -14,12 +16,28 @@
|
|
|
14
16
|
* @param {Object} screenData payload associated with the currently presented screen
|
|
15
17
|
* @returns {Boolean}
|
|
16
18
|
*/
|
|
17
|
-
export function isMenuVisible(route, screenData) {
|
|
19
|
+
export function isMenuVisible(route, screenData, plugins) {
|
|
20
|
+
const plugin = resolveNavigationPlugin({
|
|
21
|
+
category: "menu",
|
|
22
|
+
navigations:
|
|
23
|
+
screenData?.navigations || screenData?.targetScreen?.navigations,
|
|
24
|
+
plugins,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const isBottomTabsPlugin = plugin?.identifier === "quick-brick-bottom-tabs";
|
|
28
|
+
|
|
29
|
+
if (!isBottomTabsPlugin) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
if (route.includes("playable")) {
|
|
19
34
|
return false;
|
|
20
35
|
}
|
|
21
36
|
|
|
22
|
-
if (
|
|
37
|
+
if (
|
|
38
|
+
screenData.type === "qb_search_screen" ||
|
|
39
|
+
screenData?.targetScreen?.type === "qb_search_screen"
|
|
40
|
+
) {
|
|
23
41
|
return false;
|
|
24
42
|
}
|
|
25
43
|
|
|
@@ -15,6 +15,9 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
15
15
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
16
16
|
import { useScreenAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
|
|
17
17
|
|
|
18
|
+
import { useCallbackActions } from "@applicaster/zapp-react-native-utils/zappFrameworkUtils/HookCallback/useCallbackActions";
|
|
19
|
+
import { ScreenResultCallback } from "@applicaster/zapp-react-native-utils/zappFrameworkUtils/HookCallback/callbackNavigationAction";
|
|
20
|
+
|
|
18
21
|
const logger = componentsLogger.addSubsystem("ScreenResolver");
|
|
19
22
|
|
|
20
23
|
type Props = {
|
|
@@ -24,6 +27,7 @@ type Props = {
|
|
|
24
27
|
feedId?: string;
|
|
25
28
|
feedTitle?: string;
|
|
26
29
|
focused?: boolean;
|
|
30
|
+
resultCallback?: ScreenResultCallback;
|
|
27
31
|
parentFocus?: {
|
|
28
32
|
nextFocusDown?: React.Ref<any>;
|
|
29
33
|
nextFocusRight?: React.Ref<any>;
|
|
@@ -33,6 +37,11 @@ type Props = {
|
|
|
33
37
|
groupId?: string;
|
|
34
38
|
};
|
|
35
39
|
|
|
40
|
+
export enum PresentationType {
|
|
41
|
+
Standalone = "Standalone",
|
|
42
|
+
Hook = "Hook",
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
export function ScreenResolverComponent(props: Props) {
|
|
37
46
|
useScreenAnalytics(props);
|
|
38
47
|
|
|
@@ -54,7 +63,16 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
54
63
|
|
|
55
64
|
React.useEffect(() => {
|
|
56
65
|
setScreenContext(rivers[screenId]);
|
|
57
|
-
}, [screenId]);
|
|
66
|
+
}, [rivers, screenId, setScreenContext]);
|
|
67
|
+
|
|
68
|
+
const parentCallback = props.resultCallback;
|
|
69
|
+
|
|
70
|
+
const screenAction = useCallbackActions(
|
|
71
|
+
hookPlugin || screenData,
|
|
72
|
+
screenData.callback
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const callbackAction = parentCallback || screenAction;
|
|
58
76
|
|
|
59
77
|
const ScreenPlugin =
|
|
60
78
|
findPluginByType(screenType, plugins, { skipWarning: true }) ||
|
|
@@ -86,6 +104,7 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
86
104
|
return (
|
|
87
105
|
screenData && (
|
|
88
106
|
<HookRenderer
|
|
107
|
+
callback={callbackAction}
|
|
89
108
|
screenData={screenData}
|
|
90
109
|
focused={props.focused}
|
|
91
110
|
parentFocus={props.parentFocus as ParentFocus}
|
|
@@ -108,9 +127,11 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
108
127
|
return (
|
|
109
128
|
<ScreenComponent
|
|
110
129
|
{...props}
|
|
130
|
+
callback={callbackAction}
|
|
111
131
|
screenId={screenId}
|
|
112
132
|
screenData={screenData}
|
|
113
133
|
configuration={configuration}
|
|
134
|
+
presentationType={PresentationType.Standalone}
|
|
114
135
|
/>
|
|
115
136
|
);
|
|
116
137
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { makeListOf } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
2
|
+
import { isFirstComponentGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
3
|
+
import { once } from "ramda";
|
|
4
|
+
|
|
5
|
+
const INITIAL_NUMBER_TO_LOAD = 3;
|
|
6
|
+
|
|
7
|
+
// Infer the values of COMPONENT_LOADING_STATE as a type
|
|
8
|
+
type ComponentLoadingState =
|
|
9
|
+
(typeof COMPONENT_LOADING_STATE)[keyof typeof COMPONENT_LOADING_STATE];
|
|
10
|
+
|
|
11
|
+
export const COMPONENT_LOADING_STATE = {
|
|
12
|
+
UNKNOWN: "UNKNOWN",
|
|
13
|
+
LOADED_WITH_SUCCESS: "LOADED_WITH_SUCCESS",
|
|
14
|
+
LOADED_WITH_FAILURE: "LOADED_WITH_FAILURE",
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
// Function to get the number of loaded components
|
|
18
|
+
const getNumberOfLoaded = (states: ComponentLoadingState[]): number => {
|
|
19
|
+
return states.filter((value) => value !== COMPONENT_LOADING_STATE.UNKNOWN)
|
|
20
|
+
.length;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getNumberOfComponentsWaitToLoadBeforePresent = (
|
|
24
|
+
componentsToRender: ZappUIComponent[]
|
|
25
|
+
): number => {
|
|
26
|
+
// when Gallery is the first component, no need to wait the others
|
|
27
|
+
if (isFirstComponentGallery(componentsToRender)) {
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return Math.min(INITIAL_NUMBER_TO_LOAD, componentsToRender.length);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export class ScreenRevealManager {
|
|
35
|
+
public numberOfComponentsWaitToLoadBeforePresent: number;
|
|
36
|
+
private renderingState: Array<ComponentLoadingState>;
|
|
37
|
+
private callback: Callback;
|
|
38
|
+
|
|
39
|
+
constructor(componentsToRender: ZappUIComponent[], callback: Callback) {
|
|
40
|
+
this.numberOfComponentsWaitToLoadBeforePresent =
|
|
41
|
+
getNumberOfComponentsWaitToLoadBeforePresent(componentsToRender);
|
|
42
|
+
|
|
43
|
+
this.renderingState = makeListOf<ComponentLoadingState>(
|
|
44
|
+
COMPONENT_LOADING_STATE.UNKNOWN,
|
|
45
|
+
this.numberOfComponentsWaitToLoadBeforePresent
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
this.callback = once(callback);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onLoadFinished = (index: number): void => {
|
|
52
|
+
this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_SUCCESS;
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
getNumberOfLoaded(this.renderingState) >=
|
|
56
|
+
this.numberOfComponentsWaitToLoadBeforePresent
|
|
57
|
+
) {
|
|
58
|
+
this.setIsReadyToShow();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
onLoadFailed = (index: number): void => {
|
|
63
|
+
this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_FAILURE;
|
|
64
|
+
|
|
65
|
+
if (
|
|
66
|
+
getNumberOfLoaded(this.renderingState) >=
|
|
67
|
+
this.numberOfComponentsWaitToLoadBeforePresent
|
|
68
|
+
) {
|
|
69
|
+
this.setIsReadyToShow();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
setIsReadyToShow = (): void => {
|
|
74
|
+
this.callback();
|
|
75
|
+
};
|
|
76
|
+
}
|