@applicaster/zapp-react-native-ui-components 16.0.0-rc.99 → 17.0.0-alpha.1102403272
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/AudioPlayer/index.web.tsx +10 -0
- package/Components/Cell/PlatformCellComponent.ts +9 -0
- package/Components/Cell/PlatformCellComponent.web.ts +3 -0
- package/Components/Cell/index.js +2 -9
- package/Components/CellRendererResolver/index.ts +22 -3
- package/Components/ComponentResolver/ComponentResolver.ts +6 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +13 -5
- package/Components/ContentScreen/index.js +2 -2
- package/Components/Focusable/index.web.tsx +3 -0
- package/Components/FocusableList/hooks/useCheckItemIdsForUnique.ts +2 -7
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +1 -1
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +1 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +158 -1
- package/Components/GeneralContentScreen/utils/index.ts +2 -2
- package/Components/GeneralContentScreen/utils/logger.ts +3 -4
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +32 -10
- package/Components/HandlePlayable/utils.ts +2 -7
- package/Components/HookRenderer/HookRenderer.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +42 -4
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +7 -4
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +1 -0
- package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +10 -4
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +2 -4
- package/Components/MasterCell/DefaultComponents/Image/hooks/checkTooBigImageSize.ts +2 -7
- package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +34 -7
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +288 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +2 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
- package/Components/MasterCell/__tests__/masterCell.test.js +116 -0
- package/Components/MasterCell/index.tsx +45 -6
- package/Components/MasterCell/logger.ts +2 -2
- package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
- package/Components/MasterCell/utils/__tests__/useIsCellSelected.test.ts +91 -0
- package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
- package/Components/MasterCell/utils/behaviorProvider.ts +57 -38
- package/Components/MasterCell/utils/index.ts +60 -19
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +1 -1
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +7 -3
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
- package/Components/ModalComponent/BottomSheetDragArea.web.tsx +15 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +51 -82
- package/Components/ModalComponent/Button/index.tsx +3 -1
- package/Components/ModalComponent/SortableList.tsx +2 -3
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +30 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +237 -17
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
- package/Components/ModalComponent/presets/index.ts +2 -3
- package/Components/ModalComponent/showTextInput.ts +2 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +136 -0
- package/Components/OfflineHandler/index.tsx +45 -6
- package/Components/PlayerContainer/PlayerContainer.tsx +30 -6
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +51 -0
- package/Components/PlayerContainer/logger.ts +9 -5
- package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
- package/Components/River/ComponentsMap/index.web.tsx +3 -0
- package/Components/River/RiverItem.tsx +4 -0
- package/Components/River/TV/River.tsx +7 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
- package/Components/ScreenResolver/index.tsx +6 -4
- package/Components/Tabs/TV/index.web.tsx +5 -0
- package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +56 -10
- package/Components/TopCutoffOverlay/index.tsx +41 -10
- package/Components/Transitioner/AnimationManager.js +1 -1
- package/Components/Transitioner/Scene.tsx +4 -3
- package/Components/Transitioner/Transitioner.tsx +71 -33
- package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
- package/Components/VideoLive/LiveImageManager.ts +126 -12
- package/Components/VideoLive/MuteUnmuteController.ts +135 -0
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +15 -19
- package/Components/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
- package/Components/VideoLive/__tests__/LiveImageMuteState.test.ts +311 -0
- package/Components/VideoLive/__tests__/MuteUnmuteController.test.ts +135 -0
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -1
- package/Components/VideoLive/loggerHelper.ts +2 -2
- package/Components/VideoModal/PlayerDetails.tsx +27 -2
- package/Components/VideoModal/PlayerWrapper.tsx +9 -2
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +263 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +125 -0
- package/Components/VideoModal/hooks/useModalSize.ts +2 -7
- package/Components/VideoModal/playerWrapperStyle.ts +62 -23
- package/Components/VideoModal/playerWrapperUtils.ts +141 -1
- package/Components/__tests__/webVariants.test.js +73 -0
- package/Components/default-cell-renderer/containerStyles/index.web.ts +6 -0
- package/Components/default-cell-renderer/viewTrees/index.web.ts +10 -0
- package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +3 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
- package/Decorators/RiverResolver/index.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +4 -3
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +2 -21
- package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +1 -1
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +1 -1
- package/Helpers/logger.js +2 -2
- package/package.json +5 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable react/display-name */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { act, render } from "@testing-library/react-native";
|
|
4
4
|
import * as PlayerFactory from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerFactory";
|
|
5
5
|
import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
6
|
import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
7
7
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
|
|
8
|
+
import { LiveImageManager, LiveImageType } from "../LiveImageManager";
|
|
8
9
|
|
|
9
10
|
import { PlayerLiveImage } from "../PlayerLiveImageComponent";
|
|
10
11
|
import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
@@ -153,4 +154,65 @@ describe("PlayerLiveImageComponent", () => {
|
|
|
153
154
|
const isPlayerRegistered = playerManager.isPlayerRegistered(props.playerId);
|
|
154
155
|
expect(isPlayerRegistered).toBe(false);
|
|
155
156
|
});
|
|
157
|
+
|
|
158
|
+
it("renders domain mute state after a pre-playback toggle and later player events", async () => {
|
|
159
|
+
jest.useFakeTimers();
|
|
160
|
+
const nativeView = jest.fn((_props: { muted: boolean }) => null);
|
|
161
|
+
|
|
162
|
+
const Player = jest.requireActual(
|
|
163
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/player"
|
|
164
|
+
).Player;
|
|
165
|
+
|
|
166
|
+
const factory = jest
|
|
167
|
+
.spyOn(PlayerFactory, "playerFactory")
|
|
168
|
+
.mockImplementation(async (props) => ({
|
|
169
|
+
controller: new Player(props),
|
|
170
|
+
Component: nativeView,
|
|
171
|
+
}));
|
|
172
|
+
|
|
173
|
+
const register = jest.spyOn(LiveImageManager.instance, "register");
|
|
174
|
+
|
|
175
|
+
const view = render(
|
|
176
|
+
<Wrapper>
|
|
177
|
+
<PlayerLiveImage {...defaultProps} audioMutedByDefault />
|
|
178
|
+
</Wrapper>
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const image = register.mock.calls[register.mock.calls.length - 1][0];
|
|
182
|
+
|
|
183
|
+
act(() => image.unmute());
|
|
184
|
+
|
|
185
|
+
view.rerender(
|
|
186
|
+
<Wrapper>
|
|
187
|
+
<PlayerLiveImage
|
|
188
|
+
{...defaultProps}
|
|
189
|
+
audioMutedByDefault
|
|
190
|
+
style={{ opacity: 1 }}
|
|
191
|
+
/>
|
|
192
|
+
</Wrapper>
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
expect(image.getMuted()).toBe(false);
|
|
196
|
+
|
|
197
|
+
await act(async () => {
|
|
198
|
+
await image.prepareForPlayback();
|
|
199
|
+
image.setMode?.(LiveImageType.Video);
|
|
200
|
+
jest.advanceTimersByTime(1000);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(
|
|
204
|
+
nativeView.mock.calls[nativeView.mock.calls.length - 1][0].muted
|
|
205
|
+
).toBe(false);
|
|
206
|
+
|
|
207
|
+
act(() => image.getPlayer()?.mute());
|
|
208
|
+
|
|
209
|
+
expect(
|
|
210
|
+
nativeView.mock.calls[nativeView.mock.calls.length - 1][0].muted
|
|
211
|
+
).toBe(true);
|
|
212
|
+
|
|
213
|
+
view.unmount();
|
|
214
|
+
register.mockRestore();
|
|
215
|
+
factory.mockRestore();
|
|
216
|
+
jest.useRealTimers();
|
|
217
|
+
});
|
|
156
218
|
});
|
|
@@ -2,12 +2,12 @@ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
|
2
2
|
|
|
3
3
|
const loggerLiveImageManager = createLogger({
|
|
4
4
|
category: "LiveImageManager",
|
|
5
|
-
subsystem: "
|
|
5
|
+
subsystem: "player/live",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
const loggerLiveImageComponent = createLogger({
|
|
9
9
|
category: "LiveImageComponent",
|
|
10
|
-
subsystem: "
|
|
10
|
+
subsystem: "player/live",
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export { loggerLiveImageManager, loggerLiveImageComponent };
|
|
@@ -9,16 +9,22 @@ import {
|
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
11
11
|
import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
useSafeAreaFrame,
|
|
14
|
+
useSafeAreaInsets,
|
|
15
|
+
} from "react-native-safe-area-context";
|
|
13
16
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
14
17
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
15
18
|
import { useDelayedPlayerDetails } from "./hooks";
|
|
19
|
+
import { getVerticalColumnWidth } from "./playerWrapperUtils";
|
|
16
20
|
|
|
17
21
|
const { width: SCREEN_WIDTH } = Dimensions.get("screen");
|
|
18
22
|
|
|
19
23
|
type Configuration = {
|
|
20
24
|
[key: string]: any;
|
|
21
25
|
modal_background_color?: string;
|
|
26
|
+
tablet_landscape_sidebar_width?: string;
|
|
27
|
+
vertical_video_player?: boolean;
|
|
22
28
|
};
|
|
23
29
|
|
|
24
30
|
type Props = {
|
|
@@ -68,6 +74,20 @@ export const PlayerDetails = ({
|
|
|
68
74
|
const isTablet = useIsTablet();
|
|
69
75
|
const screenData = useTargetScreenData(entry);
|
|
70
76
|
const insets = useSafeAreaInsets();
|
|
77
|
+
const frame = useSafeAreaFrame();
|
|
78
|
+
|
|
79
|
+
// Entering fullscreen gives the player the whole row and squeezes this
|
|
80
|
+
// column to nothing. Android keeps that measurement for the text, so the
|
|
81
|
+
// column is derived from the frame -- the same split the player column uses
|
|
82
|
+
// -- instead of being measured, and stays put while fullscreen is open.
|
|
83
|
+
const columnWidth =
|
|
84
|
+
isTablet && isTabletLandscape && configuration.vertical_video_player
|
|
85
|
+
? frame.width -
|
|
86
|
+
getVerticalColumnWidth(
|
|
87
|
+
frame.width,
|
|
88
|
+
configuration.tablet_landscape_sidebar_width
|
|
89
|
+
)
|
|
90
|
+
: undefined;
|
|
71
91
|
|
|
72
92
|
const extraTabletStyles =
|
|
73
93
|
!isAudioPlayer && isTabletLandscape
|
|
@@ -106,6 +126,7 @@ export const PlayerDetails = ({
|
|
|
106
126
|
|
|
107
127
|
return (
|
|
108
128
|
<Animated.View
|
|
129
|
+
collapsable={false}
|
|
109
130
|
style={[
|
|
110
131
|
style,
|
|
111
132
|
extraTabletStyles,
|
|
@@ -118,13 +139,17 @@ export const PlayerDetails = ({
|
|
|
118
139
|
// workaround for avoid wrong text-height after going back to portrait rotation
|
|
119
140
|
// we don't see this view in landscape mode, so we are able to use fixed width from portrait mode
|
|
120
141
|
width: isTablet
|
|
121
|
-
?
|
|
142
|
+
? columnWidth
|
|
122
143
|
: (StyleSheet.flatten(style)?.width ?? SCREEN_WIDTH),
|
|
123
144
|
},
|
|
124
145
|
]}
|
|
125
146
|
>
|
|
126
147
|
{screenData ? (
|
|
127
148
|
<ComponentsMap
|
|
149
|
+
// River components measure themselves once and keep that width when
|
|
150
|
+
// the column changes on rotation, so the text overflows it. Remount
|
|
151
|
+
// them on the new column.
|
|
152
|
+
key={columnWidth}
|
|
128
153
|
riverId={screenData.id}
|
|
129
154
|
feed={screenData?.data?.source}
|
|
130
155
|
riverComponents={screenData.ui_components}
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
inline?: boolean;
|
|
15
15
|
docked?: boolean;
|
|
16
16
|
pip?: boolean;
|
|
17
|
+
vertical?: boolean;
|
|
17
18
|
isModal?: boolean;
|
|
18
19
|
fullscreen?: boolean;
|
|
19
20
|
isTabletPortrait?: boolean;
|
|
@@ -32,6 +33,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
32
33
|
isTabletPortrait,
|
|
33
34
|
configuration,
|
|
34
35
|
pip,
|
|
36
|
+
vertical,
|
|
35
37
|
playerContent,
|
|
36
38
|
} = props;
|
|
37
39
|
|
|
@@ -42,6 +44,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
42
44
|
isTabletPortrait,
|
|
43
45
|
configuration,
|
|
44
46
|
pip,
|
|
47
|
+
vertical,
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
const isTablet = useIsTablet();
|
|
@@ -52,8 +55,12 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
52
55
|
|
|
53
56
|
return (
|
|
54
57
|
<WrapperView
|
|
55
|
-
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
56
|
-
style={
|
|
58
|
+
edges={getEdges(isTablet, isInlineModal, vertical) as readonly Edge[]}
|
|
59
|
+
style={
|
|
60
|
+
styles.wrapperStyle
|
|
61
|
+
? [playerDimensionsHack, styles.wrapperStyle]
|
|
62
|
+
: playerDimensionsHack
|
|
63
|
+
}
|
|
57
64
|
>
|
|
58
65
|
<View
|
|
59
66
|
testID={`${entry?.id}-player-container`}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Dimensions, StyleSheet } from "react-native";
|
|
2
3
|
import { render } from "@testing-library/react-native";
|
|
3
4
|
|
|
4
5
|
const props = {
|
|
@@ -7,6 +8,10 @@ const props = {
|
|
|
7
8
|
configuration: { modal_background_color: "transparent" },
|
|
8
9
|
};
|
|
9
10
|
|
|
11
|
+
let mockIsTablet = false;
|
|
12
|
+
|
|
13
|
+
const mockFrame = { x: 0, y: 0, width: 390, height: 844 };
|
|
14
|
+
|
|
10
15
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/layout", () => ({
|
|
11
16
|
useDimensions: jest.fn(() => ({
|
|
12
17
|
width: 20,
|
|
@@ -14,11 +19,20 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/layout", () => ({
|
|
|
14
19
|
})),
|
|
15
20
|
}));
|
|
16
21
|
|
|
22
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
23
|
+
useIsTablet: () => mockIsTablet,
|
|
24
|
+
}));
|
|
25
|
+
|
|
17
26
|
jest.mock("react-native-safe-area-context", () => ({
|
|
18
27
|
useSafeAreaInsets: jest.fn(() => ({
|
|
19
28
|
top: 20,
|
|
20
29
|
bottom: 0,
|
|
21
30
|
})),
|
|
31
|
+
useSafeAreaFrame: () => mockFrame,
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
jest.mock("../hooks", () => ({
|
|
35
|
+
useDelayedPlayerDetails: () => true,
|
|
22
36
|
}));
|
|
23
37
|
|
|
24
38
|
jest.mock(
|
|
@@ -38,6 +52,10 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
|
38
52
|
})),
|
|
39
53
|
}));
|
|
40
54
|
|
|
55
|
+
const {
|
|
56
|
+
useTargetScreenData,
|
|
57
|
+
} = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
58
|
+
|
|
41
59
|
const { PlayerDetails } = require("../PlayerDetails");
|
|
42
60
|
|
|
43
61
|
describe("PlayerDetails", () => {
|
|
@@ -55,3 +73,69 @@ describe("PlayerDetails", () => {
|
|
|
55
73
|
expect(toJSON()).toMatchSnapshot();
|
|
56
74
|
});
|
|
57
75
|
});
|
|
76
|
+
|
|
77
|
+
describe("PlayerDetails text column width", () => {
|
|
78
|
+
// Fullscreen collapses this column to nothing and Android keeps that
|
|
79
|
+
// measurement, so the width has to come from the frame instead of a layout
|
|
80
|
+
// pass. Rendering alone proves it: nothing here ever measures.
|
|
81
|
+
const renderDetails = (overrides = {}) => {
|
|
82
|
+
const { toJSON } = render(
|
|
83
|
+
<PlayerDetails
|
|
84
|
+
{...props}
|
|
85
|
+
configuration={{
|
|
86
|
+
...props.configuration,
|
|
87
|
+
vertical_video_player: true,
|
|
88
|
+
tablet_landscape_sidebar_width: "35%",
|
|
89
|
+
}}
|
|
90
|
+
isTabletLandscape={true}
|
|
91
|
+
{...overrides}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return StyleSheet.flatten(toJSON().props.style)?.width;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
mockIsTablet = true;
|
|
100
|
+
mockFrame.width = 1210;
|
|
101
|
+
mockFrame.height = 834;
|
|
102
|
+
|
|
103
|
+
useTargetScreenData.mockReturnValue({
|
|
104
|
+
id: "test-id",
|
|
105
|
+
ui_components: [{ id: "component-id" }],
|
|
106
|
+
data: { source: "test-source" },
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("derives the column from the frame, not from a measurement", () => {
|
|
111
|
+
expect(renderDetails()).toBeCloseTo(1210 * 0.35);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("follows the frame on rotation", () => {
|
|
115
|
+
mockFrame.width = 834;
|
|
116
|
+
mockFrame.height = 1210;
|
|
117
|
+
|
|
118
|
+
expect(renderDetails()).toBeCloseTo(834 * 0.35);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("leaves the tablet width alone without the vertical player", () => {
|
|
122
|
+
const width = renderDetails({
|
|
123
|
+
configuration: {
|
|
124
|
+
...props.configuration,
|
|
125
|
+
tablet_landscape_sidebar_width: "35%",
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expect(width).toBeUndefined();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("leaves the tablet width alone in portrait", () => {
|
|
133
|
+
expect(renderDetails({ isTabletLandscape: false })).toBeUndefined();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("keeps the screen width on a phone", () => {
|
|
137
|
+
mockIsTablet = false;
|
|
138
|
+
|
|
139
|
+
expect(renderDetails()).toBe(Dimensions.get("screen").width);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
|
|
3
|
+
import { useStyle } from "../playerWrapperStyle";
|
|
4
|
+
import { getScreenAspectRatio } from "../playerWrapperUtils";
|
|
5
|
+
|
|
6
|
+
let mockOrientation = "portrait";
|
|
7
|
+
let mockIsTablet = false;
|
|
8
|
+
|
|
9
|
+
const mockFrame = { x: 0, y: 0, width: 390, height: 844 };
|
|
10
|
+
const mockInsets = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
11
|
+
|
|
12
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
13
|
+
useIsTablet: () => mockIsTablet,
|
|
14
|
+
useOrientation: () => mockOrientation,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock("react-native-safe-area-context", () => ({
|
|
18
|
+
useSafeAreaFrame: () => mockFrame,
|
|
19
|
+
useSafeAreaInsets: () => mockInsets,
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const getAspectRatio = (props: {
|
|
23
|
+
vertical: boolean;
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
isModal?: boolean;
|
|
26
|
+
}) => {
|
|
27
|
+
const { result } = renderHook(() =>
|
|
28
|
+
useStyle({
|
|
29
|
+
style: {},
|
|
30
|
+
inline: false,
|
|
31
|
+
isModal: true,
|
|
32
|
+
isTabletPortrait: false,
|
|
33
|
+
configuration: {},
|
|
34
|
+
pip: false,
|
|
35
|
+
...props,
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return result.current.containerDimensions.aspectRatio;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
describe("useStyle aspectRatio", () => {
|
|
43
|
+
const screenRatio = getScreenAspectRatio();
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
mockOrientation = "portrait";
|
|
47
|
+
mockIsTablet = false;
|
|
48
|
+
mockFrame.width = 390;
|
|
49
|
+
mockFrame.height = 844;
|
|
50
|
+
mockInsets.top = 0;
|
|
51
|
+
mockInsets.bottom = 0;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("uses the screen ratio when not vertical", () => {
|
|
55
|
+
mockOrientation = "portrait";
|
|
56
|
+
expect(getAspectRatio({ vertical: false })).toBeCloseTo(screenRatio);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("inverts the screen ratio for vertical fullscreen in portrait", () => {
|
|
60
|
+
mockOrientation = "portrait";
|
|
61
|
+
expect(getAspectRatio({ vertical: true })).toBeCloseTo(1 / screenRatio);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("keeps the screen ratio for vertical fullscreen in landscape", () => {
|
|
65
|
+
mockOrientation = "landscape";
|
|
66
|
+
expect(getAspectRatio({ vertical: true })).toBeCloseTo(screenRatio);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("inverts 16:9 for the vertical inline modal in landscape", () => {
|
|
70
|
+
mockOrientation = "landscape";
|
|
71
|
+
|
|
72
|
+
expect(getAspectRatio({ vertical: true, inline: true })).toBeCloseTo(
|
|
73
|
+
9 / 16
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("stretches tablet landscape vertical video to the column height", () => {
|
|
78
|
+
mockOrientation = "landscape";
|
|
79
|
+
mockIsTablet = true;
|
|
80
|
+
mockFrame.width = 1210;
|
|
81
|
+
mockFrame.height = 834;
|
|
82
|
+
mockInsets.top = 24;
|
|
83
|
+
mockInsets.bottom = 20;
|
|
84
|
+
|
|
85
|
+
const { result } = renderHook(() =>
|
|
86
|
+
useStyle({
|
|
87
|
+
// Android reports the pre-rotation size here; the layout has to follow
|
|
88
|
+
// the frame instead.
|
|
89
|
+
style: { width: 834, height: 1210 },
|
|
90
|
+
inline: true,
|
|
91
|
+
isModal: true,
|
|
92
|
+
isTabletPortrait: false,
|
|
93
|
+
configuration: { tablet_landscape_sidebar_width: "35%" },
|
|
94
|
+
pip: false,
|
|
95
|
+
vertical: true,
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const columnWidth = 1210 * (1 - 35 / 100);
|
|
100
|
+
const videoHeight = 834 - 24 - 20;
|
|
101
|
+
|
|
102
|
+
expect(result.current.wrapperStyle).toEqual({
|
|
103
|
+
width: columnWidth,
|
|
104
|
+
height: 834,
|
|
105
|
+
paddingBottom: 20,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(result.current.childrenStyles).toEqual({
|
|
109
|
+
width: videoHeight * (9 / 16),
|
|
110
|
+
height: videoHeight,
|
|
111
|
+
alignSelf: "center",
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("useStyle keeps the previous frame outside vertical tablet inline", () => {
|
|
117
|
+
const screenRatio = getScreenAspectRatio();
|
|
118
|
+
|
|
119
|
+
const legacyAspectRatio = ({
|
|
120
|
+
vertical,
|
|
121
|
+
inline,
|
|
122
|
+
isModal,
|
|
123
|
+
pip,
|
|
124
|
+
orientation,
|
|
125
|
+
}: {
|
|
126
|
+
vertical: boolean;
|
|
127
|
+
inline: boolean;
|
|
128
|
+
isModal: boolean;
|
|
129
|
+
pip: boolean;
|
|
130
|
+
orientation: string;
|
|
131
|
+
}) => {
|
|
132
|
+
const isInlineModal = inline && isModal;
|
|
133
|
+
const value = !isInlineModal && !pip ? screenRatio : 16 / 9;
|
|
134
|
+
|
|
135
|
+
if (!vertical) {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (orientation === "landscape" && !isInlineModal && !pip) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return 1 / value;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const cases: Array<{
|
|
147
|
+
name: string;
|
|
148
|
+
vertical: boolean;
|
|
149
|
+
inline: boolean;
|
|
150
|
+
isModal: boolean;
|
|
151
|
+
pip: boolean;
|
|
152
|
+
isTablet: boolean;
|
|
153
|
+
isTabletPortrait: boolean;
|
|
154
|
+
orientation: "portrait" | "landscape";
|
|
155
|
+
}> = [
|
|
156
|
+
{
|
|
157
|
+
name: "phone portrait, horizontal",
|
|
158
|
+
vertical: false,
|
|
159
|
+
inline: true,
|
|
160
|
+
isModal: true,
|
|
161
|
+
pip: false,
|
|
162
|
+
isTablet: false,
|
|
163
|
+
isTabletPortrait: false,
|
|
164
|
+
orientation: "portrait",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "phone landscape, vertical inline",
|
|
168
|
+
vertical: true,
|
|
169
|
+
inline: true,
|
|
170
|
+
isModal: true,
|
|
171
|
+
pip: false,
|
|
172
|
+
isTablet: false,
|
|
173
|
+
isTabletPortrait: false,
|
|
174
|
+
orientation: "landscape",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "tablet portrait, vertical inline",
|
|
178
|
+
vertical: true,
|
|
179
|
+
inline: true,
|
|
180
|
+
isModal: true,
|
|
181
|
+
pip: false,
|
|
182
|
+
isTablet: true,
|
|
183
|
+
isTabletPortrait: true,
|
|
184
|
+
orientation: "portrait",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "tablet landscape, horizontal inline",
|
|
188
|
+
vertical: false,
|
|
189
|
+
inline: true,
|
|
190
|
+
isModal: true,
|
|
191
|
+
pip: false,
|
|
192
|
+
isTablet: true,
|
|
193
|
+
isTabletPortrait: false,
|
|
194
|
+
orientation: "landscape",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: "tablet landscape, vertical fullscreen",
|
|
198
|
+
vertical: true,
|
|
199
|
+
inline: false,
|
|
200
|
+
isModal: true,
|
|
201
|
+
pip: false,
|
|
202
|
+
isTablet: true,
|
|
203
|
+
isTabletPortrait: false,
|
|
204
|
+
orientation: "landscape",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "tablet landscape, vertical inline picture in picture",
|
|
208
|
+
vertical: true,
|
|
209
|
+
inline: true,
|
|
210
|
+
isModal: true,
|
|
211
|
+
pip: true,
|
|
212
|
+
isTablet: true,
|
|
213
|
+
isTabletPortrait: false,
|
|
214
|
+
orientation: "landscape",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "tablet landscape, vertical inline but not a modal",
|
|
218
|
+
vertical: true,
|
|
219
|
+
inline: true,
|
|
220
|
+
isModal: false,
|
|
221
|
+
pip: false,
|
|
222
|
+
isTablet: true,
|
|
223
|
+
isTabletPortrait: false,
|
|
224
|
+
orientation: "landscape",
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
it.each(cases)(
|
|
229
|
+
"$name keeps the legacy aspect-ratio frame",
|
|
230
|
+
({
|
|
231
|
+
vertical,
|
|
232
|
+
inline,
|
|
233
|
+
isModal,
|
|
234
|
+
pip,
|
|
235
|
+
isTablet,
|
|
236
|
+
isTabletPortrait,
|
|
237
|
+
orientation,
|
|
238
|
+
}) => {
|
|
239
|
+
mockIsTablet = isTablet;
|
|
240
|
+
mockOrientation = orientation;
|
|
241
|
+
|
|
242
|
+
const { result } = renderHook(() =>
|
|
243
|
+
useStyle({
|
|
244
|
+
style: { width: 1210, height: 834 },
|
|
245
|
+
inline,
|
|
246
|
+
isModal,
|
|
247
|
+
isTabletPortrait,
|
|
248
|
+
configuration: { tablet_landscape_sidebar_width: "35%" },
|
|
249
|
+
pip,
|
|
250
|
+
vertical,
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
expect(result.current.wrapperStyle).toBeNull();
|
|
255
|
+
|
|
256
|
+
expect(result.current.containerDimensions.aspectRatio).toBeCloseTo(
|
|
257
|
+
legacyAspectRatio({ vertical, inline, isModal, pip, orientation })
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
expect(result.current.childrenStyles.alignSelf).toBeUndefined();
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
});
|