@applicaster/zapp-react-native-ui-components 12.0.5 → 13.0.0-alpha.1035032144
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__/__snapshots__/AppContainer.test.js.snap +1 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
- package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
- package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
- package/Components/Cell/Cell.tsx +4 -8
- package/Components/Cell/CellWithFocusable.tsx +60 -44
- package/Components/Cell/TvOSCellComponent.tsx +3 -8
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +6 -13
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
- package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
- package/Components/Focusable/FocusableTvOS.tsx +1 -1
- package/Components/FocusableList/index.tsx +0 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
- package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +7 -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 +5 -11
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
- package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
- package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
- package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
- 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 +37 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
- package/Components/River/__tests__/componentsMap.test.js +64 -17
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +41 -27
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
- package/Components/Screen/hooks.ts +56 -0
- package/Components/Screen/index.tsx +13 -39
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
- package/Components/Tabs/Tab.tsx +1 -0
- 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 +2 -2
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
- package/Components/Transitioner/Scene.tsx +52 -23
- package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +62 -46
- 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/index.js +8 -4
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +5 -2
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +14 -9
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -10
- package/Components/VideoModal/ModalAnimation/index.ts +2 -1
- package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -9
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -66
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +1 -1
- package/Components/VideoModal/utils.ts +2 -4
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
- package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
- package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
- 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__/__snapshots__/riverResolver.test.tsx.snap +5 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
- package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
- package/README.md +1 -13
- package/package.json +12 -6
- package/Components/Cell/CellWithFocusable.ios.tsx +0 -126
- package/Decorators/RiverFeedLoader/utils.ts +0 -100
- /package/Decorators/Analytics/{index.js → index.tsx} +0 -0
|
@@ -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
|
|
|
@@ -75,28 +74,70 @@ const riverComponents = [
|
|
|
75
74
|
},
|
|
76
75
|
];
|
|
77
76
|
|
|
78
|
-
const
|
|
77
|
+
const mockScreenData = {
|
|
79
78
|
ui_components: riverComponents,
|
|
80
79
|
rules: { pull_to_refresh_enabled: false },
|
|
81
80
|
id: "A1234",
|
|
82
81
|
};
|
|
83
82
|
|
|
83
|
+
jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
|
|
84
|
+
appStore: {
|
|
85
|
+
get: jest.fn((prop) => mockStore[prop]),
|
|
86
|
+
getState: jest.fn(),
|
|
87
|
+
},
|
|
88
|
+
}));
|
|
89
|
+
|
|
84
90
|
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
85
91
|
useIsRTL: jest.fn(() => mock_rtl_flag),
|
|
86
92
|
}));
|
|
87
93
|
|
|
88
|
-
jest.mock(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
jest.mock(
|
|
95
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
96
|
+
() => ({
|
|
97
|
+
useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
|
|
98
|
+
})
|
|
99
|
+
);
|
|
94
100
|
|
|
95
|
-
jest.mock(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
jest.mock(
|
|
102
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
103
|
+
() => ({
|
|
104
|
+
useRoute: jest.fn(() => ({
|
|
105
|
+
pathname: "/river/A1234",
|
|
106
|
+
screenData: mockScreenData,
|
|
107
|
+
})),
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
jest.mock(
|
|
112
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
113
|
+
() => ({
|
|
114
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
jest.mock(
|
|
119
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
|
|
120
|
+
() => ({
|
|
121
|
+
useCurrentScreenData: jest.fn(() => mockScreenData),
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
jest.mock(
|
|
126
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
|
|
127
|
+
() => ({
|
|
128
|
+
useScreenData: jest.fn(() => mockScreenData),
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
jest.mock(
|
|
133
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
134
|
+
() => ({
|
|
135
|
+
...jest.requireActual(
|
|
136
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext"
|
|
137
|
+
),
|
|
138
|
+
useScreenContext: jest.fn(() => mockScreenData),
|
|
139
|
+
})
|
|
140
|
+
);
|
|
100
141
|
|
|
101
142
|
const { View } = require("react-native");
|
|
102
143
|
const { ComponentsMap } = require("../ComponentsMap/ComponentsMap");
|
|
@@ -118,7 +159,13 @@ const plugins = [];
|
|
|
118
159
|
const navigation = {};
|
|
119
160
|
|
|
120
161
|
const props = { components, cellStyles, riverComponents, navigation };
|
|
121
|
-
|
|
162
|
+
|
|
163
|
+
const store = mockStore({
|
|
164
|
+
components,
|
|
165
|
+
cellStyles,
|
|
166
|
+
plugins,
|
|
167
|
+
getState: jest.fn(),
|
|
168
|
+
});
|
|
122
169
|
|
|
123
170
|
jest.useFakeTimers();
|
|
124
171
|
|
|
@@ -135,12 +182,12 @@ describe("componentsMap", () => {
|
|
|
135
182
|
.spyOn(themeUtils, "useTheme")
|
|
136
183
|
.mockImplementation(() => () => theme);
|
|
137
184
|
|
|
138
|
-
const
|
|
185
|
+
const { toJSON } = render(
|
|
139
186
|
<Provider store={store}>
|
|
140
187
|
<ComponentsMap {...props} />
|
|
141
188
|
</Provider>
|
|
142
189
|
);
|
|
143
190
|
|
|
144
|
-
expect(
|
|
191
|
+
expect(toJSON()).toMatchSnapshot();
|
|
145
192
|
});
|
|
146
193
|
});
|
|
@@ -46,27 +46,37 @@ 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
|
-
|
|
67
|
-
|
|
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
|
+
|
|
71
|
+
jest.mock(
|
|
72
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
|
|
73
|
+
() => ({
|
|
74
|
+
useScreenData: jest.fn(() => ({
|
|
75
|
+
id: "testId",
|
|
76
|
+
navigations: [{ id: "testId", category: "nav_bar" }],
|
|
77
|
+
})),
|
|
78
|
+
})
|
|
79
|
+
);
|
|
70
80
|
|
|
71
81
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
72
82
|
isNavBarVisible: mockIsNavBarVisible,
|
|
@@ -84,20 +94,24 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
84
94
|
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
85
95
|
}));
|
|
86
96
|
|
|
87
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks", () =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks/usePickFromState", () => {
|
|
98
|
+
const View = jest.requireActual("react-native").View;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
usePickFromState: () => ({
|
|
102
|
+
plugins: [
|
|
103
|
+
{
|
|
104
|
+
name: "Offline Plugin",
|
|
105
|
+
identifier: "offline-experience",
|
|
106
|
+
type: "general",
|
|
107
|
+
module: {
|
|
108
|
+
OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
|
|
109
|
+
},
|
|
96
110
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
})
|
|
111
|
+
],
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
});
|
|
101
115
|
|
|
102
116
|
const {
|
|
103
117
|
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,
|
|
@@ -22,7 +22,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
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,
|
|
@@ -54,7 +54,7 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
54
54
|
<View
|
|
55
55
|
pathname="/river/testId"
|
|
56
56
|
screenData={
|
|
57
|
-
|
|
57
|
+
{
|
|
58
58
|
"id": "testId",
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
11
|
+
import { useMemo, useEffect, useState } from "react";
|
|
12
|
+
|
|
13
|
+
export const useWaitForValidOrientation = () => {
|
|
14
|
+
const {
|
|
15
|
+
width: screenWidth,
|
|
16
|
+
height,
|
|
17
|
+
deviceInfo,
|
|
18
|
+
} = useDimensions("screen", {
|
|
19
|
+
fullDimensions: true,
|
|
20
|
+
updateForInactiveScreens: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const currentScreenData = useCurrentScreenData();
|
|
24
|
+
|
|
25
|
+
const { screenData } = useRoute();
|
|
26
|
+
|
|
27
|
+
const [readyState, setReadyState] = useState(false);
|
|
28
|
+
|
|
29
|
+
const isTablet = deviceInfo?.isTablet;
|
|
30
|
+
|
|
31
|
+
const { appData } = usePickFromState(["appData"]);
|
|
32
|
+
const isTabletPortrait = appData?.isTabletPortrait;
|
|
33
|
+
|
|
34
|
+
const layoutData = useMemo(
|
|
35
|
+
() => ({ isTablet, isTabletPortrait, width: screenWidth, height }),
|
|
36
|
+
[isTablet, isTabletPortrait, screenWidth, height]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const targetScreenData =
|
|
40
|
+
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
41
|
+
|
|
42
|
+
const orientation = useGetScreenOrientation(targetScreenData);
|
|
43
|
+
|
|
44
|
+
const isReadyForDisplay = isOrientationCompatible({
|
|
45
|
+
orientation,
|
|
46
|
+
layoutData,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isReadyForDisplay && !readyState) {
|
|
51
|
+
setReadyState(true);
|
|
52
|
+
}
|
|
53
|
+
}, [readyState, orientation, layoutData]);
|
|
54
|
+
|
|
55
|
+
return readyState;
|
|
56
|
+
};
|
|
@@ -2,10 +2,6 @@
|
|
|
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";
|
|
@@ -15,7 +11,6 @@ import {
|
|
|
15
11
|
getScreenId,
|
|
16
12
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
17
13
|
import {
|
|
18
|
-
useDimensions,
|
|
19
14
|
useRoute,
|
|
20
15
|
useCurrentScreenData,
|
|
21
16
|
useNavbarState,
|
|
@@ -27,6 +22,7 @@ import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/Ap
|
|
|
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} />}
|
|
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
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<ScreenResolver /> renders correctly 1`] = `
|
|
4
4
|
<mockConstructor
|
|
5
|
-
screenData={
|
|
5
|
+
screenData={{}}
|
|
6
6
|
screenId="1234"
|
|
7
7
|
screenType="screen_type_1"
|
|
8
8
|
/>
|
|
@@ -11,7 +11,7 @@ exports[`<ScreenResolver /> renders correctly 1`] = `
|
|
|
11
11
|
exports[`<ScreenResolver /> wraps the player with the playerController component when the screenType is playable 1`] = `
|
|
12
12
|
<HandlePlayable
|
|
13
13
|
isModal={false}
|
|
14
|
-
item={
|
|
14
|
+
item={{}}
|
|
15
15
|
mode="FULLSCREEN"
|
|
16
16
|
/>
|
|
17
17
|
`;
|
|
@@ -2,42 +2,39 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { shallow } from "enzyme";
|
|
4
4
|
import { shallowToJson } from "enzyme-to-json";
|
|
5
|
-
import { connect as realConnect } from "react-redux";
|
|
6
|
-
|
|
7
5
|
const pluginConfiguration = { foo: "bar" };
|
|
8
6
|
|
|
9
7
|
const ScreenType1 = jest.fn(() => <View />);
|
|
10
8
|
const ScreenType2 = jest.fn(() => <View />);
|
|
9
|
+
const PlayerController = jest.fn(() => <View />);
|
|
11
10
|
|
|
12
|
-
const
|
|
11
|
+
const mockScreenType3 = {
|
|
13
12
|
module: jest.fn(() => <View />),
|
|
14
13
|
name: "ScreenType3",
|
|
15
14
|
type: "screen_type_3",
|
|
16
15
|
configuration: pluginConfiguration,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
const
|
|
18
|
+
const mockScreenType4 = {
|
|
20
19
|
module: jest.fn(() => <View />),
|
|
21
20
|
name: "ScreenType4",
|
|
22
21
|
type: "screen_type_4",
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const playerPlugin = {
|
|
24
|
+
const mockPlayerPlugin = {
|
|
28
25
|
module: jest.fn(() => <View />),
|
|
29
26
|
name: "playerPlugin",
|
|
30
27
|
type: "player",
|
|
31
28
|
};
|
|
32
29
|
|
|
33
|
-
const
|
|
30
|
+
const mockScreenPlugin = {
|
|
34
31
|
module: jest.fn(() => <View />),
|
|
35
32
|
type: "general",
|
|
36
33
|
name: "Screen plugin",
|
|
37
34
|
identifier: "screen-plugin",
|
|
38
35
|
};
|
|
39
36
|
|
|
40
|
-
const
|
|
37
|
+
const mockPluginWithConfig = {
|
|
41
38
|
module: jest.fn(() => <View />),
|
|
42
39
|
type: "general",
|
|
43
40
|
name: "Plugin with config",
|
|
@@ -47,15 +44,7 @@ const PluginWithConfig = {
|
|
|
47
44
|
|
|
48
45
|
const components = { ScreenType1, ScreenType2, PlayerController };
|
|
49
46
|
|
|
50
|
-
const
|
|
51
|
-
ScreenType3,
|
|
52
|
-
ScreenType4,
|
|
53
|
-
playerPlugin,
|
|
54
|
-
ScreenPlugin,
|
|
55
|
-
PluginWithConfig,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const withAnalytics = {
|
|
47
|
+
const mockWithAnalytics = {
|
|
59
48
|
sendOnClickEvent: jest.fn(),
|
|
60
49
|
sendMenuClickEvent: jest.fn(),
|
|
61
50
|
sendMenuToggleEvent: jest.fn(),
|
|
@@ -66,24 +55,39 @@ const withAnalytics = {
|
|
|
66
55
|
sendScreenEvent: jest.fn(),
|
|
67
56
|
};
|
|
68
57
|
|
|
58
|
+
const mockUsePickFromState = jest.fn(() => {
|
|
59
|
+
return {
|
|
60
|
+
components,
|
|
61
|
+
plugins: {
|
|
62
|
+
ScreenType3: mockScreenType3,
|
|
63
|
+
ScreenType4: mockScreenType4,
|
|
64
|
+
playerPlugin: mockPlayerPlugin,
|
|
65
|
+
ScreenPlugin: mockScreenPlugin,
|
|
66
|
+
PluginWithConfig: mockPluginWithConfig,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
69
71
|
jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
|
|
70
|
-
useAnalytics: jest.fn().mockReturnValue(
|
|
72
|
+
useAnalytics: jest.fn().mockReturnValue(mockWithAnalytics),
|
|
71
73
|
}));
|
|
72
74
|
|
|
73
75
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
74
|
-
usePickFromState:
|
|
76
|
+
usePickFromState: mockUsePickFromState,
|
|
75
77
|
}));
|
|
76
78
|
|
|
79
|
+
const mockUseScreenAnalytics = jest.fn();
|
|
80
|
+
|
|
77
81
|
jest.mock(
|
|
78
82
|
"@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
|
|
79
83
|
() => ({
|
|
80
|
-
useScreenAnalytics:
|
|
84
|
+
useScreenAnalytics: mockUseScreenAnalytics,
|
|
81
85
|
})
|
|
82
86
|
);
|
|
83
87
|
|
|
84
88
|
jest.mock("react-redux", () => ({
|
|
89
|
+
...jest.requireActual("react-redux"),
|
|
85
90
|
useDispatch: jest.fn(() => () => {}),
|
|
86
|
-
connect: realConnect,
|
|
87
91
|
}));
|
|
88
92
|
|
|
89
93
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
@@ -118,13 +122,13 @@ describe("<ScreenResolver />", () => {
|
|
|
118
122
|
it("picks screen from plugins if it exists", () => {
|
|
119
123
|
const wrapper = getWrapper("A1234", "screen_type_3", {});
|
|
120
124
|
|
|
121
|
-
expect(wrapper.find(
|
|
125
|
+
expect(wrapper.find(mockScreenType3.module)).toHaveProperty("length", 1);
|
|
122
126
|
});
|
|
123
127
|
|
|
124
128
|
it("picks the screen from its identifier if it exists", () => {
|
|
125
129
|
const wrapper = getWrapper("A1234", "screen-plugin", {});
|
|
126
130
|
|
|
127
|
-
expect(wrapper.find(
|
|
131
|
+
expect(wrapper.find(mockScreenPlugin.module)).toHaveProperty("length", 1);
|
|
128
132
|
});
|
|
129
133
|
|
|
130
134
|
it("picks screen from components if it doesn't exist in plugins", () => {
|
|
@@ -136,7 +140,7 @@ describe("<ScreenResolver />", () => {
|
|
|
136
140
|
it("renders the screen and passes screenId & locationState as props", () => {
|
|
137
141
|
const wrapper = getWrapper("A1234", "screen_type_3", "foo");
|
|
138
142
|
|
|
139
|
-
const screenWrapper = wrapper.find(
|
|
143
|
+
const screenWrapper = wrapper.find(mockScreenType3.module);
|
|
140
144
|
|
|
141
145
|
expect(screenWrapper.prop("screenId")).toEqual("A1234");
|
|
142
146
|
expect(screenWrapper.prop("screenData")).toEqual("foo");
|
|
@@ -151,7 +155,7 @@ describe("<ScreenResolver />", () => {
|
|
|
151
155
|
it("injects the plugin configuration if it exists", () => {
|
|
152
156
|
const wrapper = getWrapper("A1234", "plugin-with-config", {});
|
|
153
157
|
|
|
154
|
-
expect(wrapper.find(
|
|
158
|
+
expect(wrapper.find(mockPluginWithConfig.module).props()).toHaveProperty(
|
|
155
159
|
"configuration",
|
|
156
160
|
expect.objectContaining(pluginConfiguration)
|
|
157
161
|
);
|
|
@@ -160,7 +164,7 @@ describe("<ScreenResolver />", () => {
|
|
|
160
164
|
it("injects the plugin configuration if it exists, even when plugin is resolved by type", () => {
|
|
161
165
|
const wrapper = getWrapper("A1234", "screen_type_3", {});
|
|
162
166
|
|
|
163
|
-
expect(wrapper.find(
|
|
167
|
+
expect(wrapper.find(mockScreenType3.module).props()).toHaveProperty(
|
|
164
168
|
"configuration",
|
|
165
169
|
expect.objectContaining(pluginConfiguration)
|
|
166
170
|
);
|
package/Components/Tabs/Tab.tsx
CHANGED