@applicaster/zapp-react-native-ui-components 13.0.0-alpha.6523249552 → 13.0.0-alpha.6651373134
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/AudioPlayer/AudioPlayer.tsx +7 -0
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/BaseFocusable/index.tsx +1 -2
- package/Components/Cell/Cell.tsx +4 -13
- package/Components/Cell/CellWithFocusable.tsx +48 -59
- package/Components/Cell/CellWrapper.ts +5 -0
- package/Components/Cell/TvOSCellComponent.tsx +20 -22
- 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 +46 -48
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +14 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/FocusableTvOS.tsx +5 -1
- 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 -9
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -27
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/ScreenContainer.tsx +8 -1
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +4 -3
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- 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/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +8 -134
- package/Components/ModalComponent/Button/assets.ts +1 -1
- package/Components/ModalComponent/Button/index.tsx +6 -6
- 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/utils/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +17 -13
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/componentsMap.test.js +3 -4
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +8 -6
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -43
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +5 -3
- package/Components/TextInputTv/index.tsx +2 -1
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +1 -1
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -68
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +7 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +44 -30
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +24 -11
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
- package/Components/VideoModal/PlayerDetails.tsx +9 -6
- package/Components/VideoModal/PlayerWrapper.tsx +28 -5
- package/Components/VideoModal/VideoModal.tsx +2 -2
- 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/__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 +3 -16
- 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/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +3 -10
- 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/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +4 -30
- package/package.json +7 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- 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/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -1,89 +1,27 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`When River has a general_content type
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<RiverWithData
|
|
8
|
-
appData={
|
|
9
|
-
{
|
|
10
|
-
"layoutVersion": "v1",
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
dispatch={[Function]}
|
|
14
|
-
rivers={
|
|
15
|
-
{
|
|
16
|
-
"A1234": {
|
|
17
|
-
"home": true,
|
|
18
|
-
"id": "A1234",
|
|
19
|
-
"name": "foo",
|
|
20
|
-
"type": "general_content",
|
|
21
|
-
"ui_components": [
|
|
22
|
-
{
|
|
23
|
-
"component_type": "hero",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"component_type": "grid",
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
"B4567": {
|
|
31
|
-
"id": "B4567",
|
|
32
|
-
},
|
|
33
|
-
"C0987": {
|
|
34
|
-
"home": false,
|
|
35
|
-
"id": "C0987",
|
|
36
|
-
"name": "Some-Screen-Plugin",
|
|
37
|
-
"type": "some-screen-plugin",
|
|
38
|
-
"ui_components": [],
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
screenId="A1234"
|
|
43
|
-
store={
|
|
44
|
-
{
|
|
45
|
-
"clearActions": [Function],
|
|
46
|
-
"dispatch": [Function],
|
|
47
|
-
"getActions": [Function],
|
|
48
|
-
"getState": [Function],
|
|
49
|
-
"replaceReducer": [Function],
|
|
50
|
-
"subscribe": [Function],
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/>
|
|
54
|
-
</ContextProvider>
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
exports[`When River has a general_content type <RiverComponent /> renders correctly 1`] = `
|
|
58
|
-
<GeneralContentScreen
|
|
59
|
-
groupId="ZF-C4"
|
|
60
|
-
screenId="A1234"
|
|
61
|
-
/>
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
exports[`When River has any other type other than general_content <RiverComponent /> renders correctly 1`] = `
|
|
65
|
-
<WithProvider
|
|
66
|
-
screenData={
|
|
3
|
+
exports[`When River has a general_content type renders River component correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
onLayout={[Function]}
|
|
6
|
+
style={
|
|
67
7
|
{
|
|
68
|
-
"
|
|
69
|
-
"home": false,
|
|
70
|
-
"id": "C0987",
|
|
71
|
-
"name": "Some-Screen-Plugin",
|
|
72
|
-
"type": "some-screen-plugin",
|
|
73
|
-
"ui_components": [],
|
|
8
|
+
"flex": 1,
|
|
74
9
|
}
|
|
75
10
|
}
|
|
76
|
-
|
|
77
|
-
screenType="some-screen-plugin"
|
|
78
|
-
/>
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
exports[`When River has feed url <RiverComponent /> renders correctly 1`] = `
|
|
82
|
-
<Connect(FeedLoaderComponent)
|
|
83
|
-
feedUrl="https://some-feed-url.net"
|
|
84
|
-
refreshCallback={[Function]}
|
|
85
|
-
refreshing={false}
|
|
11
|
+
testID="on-layout-view"
|
|
86
12
|
>
|
|
87
|
-
<
|
|
88
|
-
|
|
13
|
+
<View
|
|
14
|
+
style={
|
|
15
|
+
{
|
|
16
|
+
"display": "none",
|
|
17
|
+
"flex": 1,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
>
|
|
21
|
+
<View
|
|
22
|
+
screenId="A1234"
|
|
23
|
+
testID="general-content-screen"
|
|
24
|
+
/>
|
|
25
|
+
</View>
|
|
26
|
+
</View>
|
|
89
27
|
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { cleanup } from "@testing-library/react-native";
|
|
2
|
+
import { cleanup, render } from "@testing-library/react-native";
|
|
4
3
|
import { Provider } from "react-redux";
|
|
5
4
|
import configureStore from "redux-mock-store";
|
|
6
5
|
|
|
@@ -183,12 +182,12 @@ describe("componentsMap", () => {
|
|
|
183
182
|
.spyOn(themeUtils, "useTheme")
|
|
184
183
|
.mockImplementation(() => () => theme);
|
|
185
184
|
|
|
186
|
-
const
|
|
185
|
+
const { toJSON } = render(
|
|
187
186
|
<Provider store={store}>
|
|
188
187
|
<ComponentsMap {...props} />
|
|
189
188
|
</Provider>
|
|
190
189
|
);
|
|
191
190
|
|
|
192
|
-
expect(
|
|
191
|
+
expect(toJSON()).toMatchSnapshot();
|
|
193
192
|
});
|
|
194
193
|
});
|
|
@@ -1,13 +1,50 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
2
|
+
import { render, screen } from "@testing-library/react-native";
|
|
4
3
|
import configureStore from "redux-mock-store";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
|
+
import { Provider } from "react-redux";
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
-
import { FeedLoader } from "../../FeedLoader";
|
|
8
|
-
import { River } from "../index";
|
|
9
|
-
import { RiverComponent } from "../River";
|
|
7
|
+
import { River } from "../";
|
|
10
8
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
9
|
+
import { RiverComponent } from "../River";
|
|
10
|
+
|
|
11
|
+
jest.mock(
|
|
12
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
13
|
+
() => ({
|
|
14
|
+
useIsScreenActive: jest.fn(() => true),
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock(
|
|
19
|
+
"@applicaster/zapp-react-native-ui-components/Components/GeneralContentScreen",
|
|
20
|
+
() => {
|
|
21
|
+
const { View } = jest.requireActual("react-native");
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
GeneralContentScreen: (props) => (
|
|
25
|
+
<View testID="general-content-screen" {...props} />
|
|
26
|
+
),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
jest.mock(
|
|
32
|
+
"@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
|
|
33
|
+
() => ({
|
|
34
|
+
useScreenAnalytics: jest.fn(),
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
jest.mock(
|
|
39
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
40
|
+
() => ({
|
|
41
|
+
useNavigation: jest.fn(() => ({
|
|
42
|
+
videoModalState: {
|
|
43
|
+
mode: "test",
|
|
44
|
+
},
|
|
45
|
+
})),
|
|
46
|
+
})
|
|
47
|
+
);
|
|
11
48
|
|
|
12
49
|
const river = {
|
|
13
50
|
home: true,
|
|
@@ -55,24 +92,24 @@ const appData = { layoutVersion: "v1" };
|
|
|
55
92
|
const store = configureStore()({ rivers, appData });
|
|
56
93
|
|
|
57
94
|
describe("When River has a general_content type", () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(wrapper.find(GeneralContentScreen).length).toBe(1);
|
|
67
|
-
});
|
|
95
|
+
it("renders GeneralContentScreen correctly", () => {
|
|
96
|
+
const { getByTestId } = render(
|
|
97
|
+
<Provider store={store}>
|
|
98
|
+
<RiverComponent {...riverProps} />
|
|
99
|
+
</Provider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(getByTestId("general-content-screen")).toBeTruthy();
|
|
68
103
|
});
|
|
69
104
|
|
|
70
|
-
|
|
71
|
-
const wrapper =
|
|
105
|
+
it("renders River component correctly", () => {
|
|
106
|
+
const wrapper = render(
|
|
107
|
+
<Provider store={store}>
|
|
108
|
+
<River screenId="A1234" />
|
|
109
|
+
</Provider>
|
|
110
|
+
);
|
|
72
111
|
|
|
73
|
-
|
|
74
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
75
|
-
});
|
|
112
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
76
113
|
});
|
|
77
114
|
});
|
|
78
115
|
|
|
@@ -83,16 +120,10 @@ describe("When River has any other type other than general_content", () => {
|
|
|
83
120
|
appData,
|
|
84
121
|
};
|
|
85
122
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
describe("<RiverComponent />", () => {
|
|
89
|
-
it("renders correctly", () => {
|
|
90
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
91
|
-
});
|
|
123
|
+
it("renders ScreenResolver correctly", () => {
|
|
124
|
+
renderWithProviders(<RiverComponent {...riverPropsWithScreenPlugin} />);
|
|
92
125
|
|
|
93
|
-
|
|
94
|
-
expect(wrapper.find(ScreenResolver).length).toBe(1);
|
|
95
|
-
});
|
|
126
|
+
expect(screen.UNSAFE_getByType(ScreenResolver)).toBeDefined();
|
|
96
127
|
});
|
|
97
128
|
});
|
|
98
129
|
|
|
@@ -104,15 +135,19 @@ describe("When River has feed url", () => {
|
|
|
104
135
|
appData: { layoutVersion: "v1" },
|
|
105
136
|
};
|
|
106
137
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
it("renders FeedLoader when layout is v1", () => {
|
|
139
|
+
const wrapper = renderWithProviders(
|
|
140
|
+
<RiverComponent {...riverPropsWithFeedUrl} />,
|
|
141
|
+
{
|
|
142
|
+
zappPipes: {
|
|
143
|
+
"https://some-feed-url.net": {
|
|
144
|
+
loading: false,
|
|
145
|
+
data: { entry: [] },
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
expect(wrapper.getByTestId("general-content-screen")).toBeDefined();
|
|
117
152
|
});
|
|
118
153
|
});
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<RouteManager /> renders correctly 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
4
|
+
<View
|
|
5
|
+
accessibilityLabel="A1234"
|
|
6
|
+
style={
|
|
7
|
+
{
|
|
8
|
+
"flex": 1,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
testID="A1234"
|
|
6
12
|
>
|
|
7
|
-
<
|
|
13
|
+
<View
|
|
8
14
|
pathname="/river/A1234"
|
|
9
15
|
screenData={
|
|
10
16
|
{
|
|
@@ -13,6 +19,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
|
|
|
13
19
|
}
|
|
14
20
|
screenId="A1234"
|
|
15
21
|
screenType="river"
|
|
22
|
+
testID="screen-resolver"
|
|
16
23
|
/>
|
|
17
|
-
</
|
|
24
|
+
</View>
|
|
18
25
|
`;
|
|
@@ -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,16 @@ 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
|
-
|
|
28
|
-
expect(wrapper.
|
|
26
|
+
expect(wrapper.getByTestId(screenId)).toBeTruthy();
|
|
27
|
+
|
|
28
|
+
expect(wrapper.getByTestId(screenId).props.accessibilityLabel).toEqual(
|
|
29
|
+
screenId
|
|
30
|
+
);
|
|
29
31
|
});
|
|
30
32
|
});
|
|
@@ -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
|
|
@@ -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,15 +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
|
-
updateForInactiveScreens: false,
|
|
59
|
-
fullDimensions: true,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
49
|
const { screenData, pathname } = useRoute();
|
|
63
50
|
|
|
64
51
|
const currentRiver = useScreenData(
|
|
@@ -67,13 +54,6 @@ export function Screen(_props: Props) {
|
|
|
67
54
|
|
|
68
55
|
const { title } = useNavbarState();
|
|
69
56
|
|
|
70
|
-
const isTablet = deviceInfo?.isTablet;
|
|
71
|
-
|
|
72
|
-
const { appData } = usePickFromState(["appData"]);
|
|
73
|
-
const isTabletPortrait = appData?.isTabletPortrait;
|
|
74
|
-
|
|
75
|
-
const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
|
|
76
|
-
|
|
77
57
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
78
58
|
|
|
79
59
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
@@ -109,30 +89,23 @@ export function Screen(_props: Props) {
|
|
|
109
89
|
[theme.app_background_color, backgroundColor]
|
|
110
90
|
);
|
|
111
91
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const orientation = useGetScreenOrientation(targetScreenData);
|
|
92
|
+
// Set ready state when screen is rotated to desired orientation
|
|
93
|
+
const isReady = useWaitForValidOrientation();
|
|
116
94
|
|
|
117
95
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
118
96
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
119
|
-
if (
|
|
120
|
-
!isOrientationCompatible({
|
|
121
|
-
orientation,
|
|
122
|
-
layoutData,
|
|
123
|
-
})
|
|
124
|
-
) {
|
|
125
|
-
return <View style={style} />;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
97
|
return (
|
|
129
98
|
<View style={style}>
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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}
|
|
136
109
|
</View>
|
|
137
110
|
);
|
|
138
111
|
}
|