@applicaster/zapp-react-native-ui-components 16.0.0-rc.99 → 17.0.0-alpha.1201533844
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 +2 -2
- package/Components/ComponentResolver/ComponentResolver.ts +2 -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 +13 -0
- 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/index.tsx +12 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
- 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 +60 -0
- package/Components/MasterCell/index.tsx +28 -4
- package/Components/MasterCell/logger.ts +2 -2
- 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 +21 -18
- 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/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/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/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
- package/Components/ScreenResolver/index.tsx +2 -3
- package/Components/Tabs/TV/index.web.tsx +5 -0
- 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__/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/PlayerWrapper.tsx +9 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +261 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +85 -0
- package/Components/VideoModal/hooks/useModalSize.ts +2 -7
- package/Components/VideoModal/playerWrapperStyle.ts +58 -23
- package/Components/VideoModal/playerWrapperUtils.ts +95 -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/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
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
style: { width: 1210, height: 834 },
|
|
88
|
+
inline: true,
|
|
89
|
+
isModal: true,
|
|
90
|
+
isTabletPortrait: false,
|
|
91
|
+
configuration: { tablet_landscape_sidebar_width: "35%" },
|
|
92
|
+
pip: false,
|
|
93
|
+
vertical: true,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const columnWidth = 1210 * (1 - 35 / 100);
|
|
98
|
+
const videoHeight = 834 - 24 - 20;
|
|
99
|
+
|
|
100
|
+
expect(result.current.wrapperStyle).toEqual({
|
|
101
|
+
width: columnWidth,
|
|
102
|
+
height: 834,
|
|
103
|
+
paddingBottom: 20,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(result.current.childrenStyles).toEqual({
|
|
107
|
+
width: videoHeight * (9 / 16),
|
|
108
|
+
height: videoHeight,
|
|
109
|
+
alignSelf: "center",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("useStyle keeps the previous frame outside vertical tablet inline", () => {
|
|
115
|
+
const screenRatio = getScreenAspectRatio();
|
|
116
|
+
|
|
117
|
+
const legacyAspectRatio = ({
|
|
118
|
+
vertical,
|
|
119
|
+
inline,
|
|
120
|
+
isModal,
|
|
121
|
+
pip,
|
|
122
|
+
orientation,
|
|
123
|
+
}: {
|
|
124
|
+
vertical: boolean;
|
|
125
|
+
inline: boolean;
|
|
126
|
+
isModal: boolean;
|
|
127
|
+
pip: boolean;
|
|
128
|
+
orientation: string;
|
|
129
|
+
}) => {
|
|
130
|
+
const isInlineModal = inline && isModal;
|
|
131
|
+
const value = !isInlineModal && !pip ? screenRatio : 16 / 9;
|
|
132
|
+
|
|
133
|
+
if (!vertical) {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (orientation === "landscape" && !isInlineModal && !pip) {
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return 1 / value;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const cases: Array<{
|
|
145
|
+
name: string;
|
|
146
|
+
vertical: boolean;
|
|
147
|
+
inline: boolean;
|
|
148
|
+
isModal: boolean;
|
|
149
|
+
pip: boolean;
|
|
150
|
+
isTablet: boolean;
|
|
151
|
+
isTabletPortrait: boolean;
|
|
152
|
+
orientation: "portrait" | "landscape";
|
|
153
|
+
}> = [
|
|
154
|
+
{
|
|
155
|
+
name: "phone portrait, horizontal",
|
|
156
|
+
vertical: false,
|
|
157
|
+
inline: true,
|
|
158
|
+
isModal: true,
|
|
159
|
+
pip: false,
|
|
160
|
+
isTablet: false,
|
|
161
|
+
isTabletPortrait: false,
|
|
162
|
+
orientation: "portrait",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "phone landscape, vertical inline",
|
|
166
|
+
vertical: true,
|
|
167
|
+
inline: true,
|
|
168
|
+
isModal: true,
|
|
169
|
+
pip: false,
|
|
170
|
+
isTablet: false,
|
|
171
|
+
isTabletPortrait: false,
|
|
172
|
+
orientation: "landscape",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "tablet portrait, vertical inline",
|
|
176
|
+
vertical: true,
|
|
177
|
+
inline: true,
|
|
178
|
+
isModal: true,
|
|
179
|
+
pip: false,
|
|
180
|
+
isTablet: true,
|
|
181
|
+
isTabletPortrait: true,
|
|
182
|
+
orientation: "portrait",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "tablet landscape, horizontal inline",
|
|
186
|
+
vertical: false,
|
|
187
|
+
inline: true,
|
|
188
|
+
isModal: true,
|
|
189
|
+
pip: false,
|
|
190
|
+
isTablet: true,
|
|
191
|
+
isTabletPortrait: false,
|
|
192
|
+
orientation: "landscape",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "tablet landscape, vertical fullscreen",
|
|
196
|
+
vertical: true,
|
|
197
|
+
inline: false,
|
|
198
|
+
isModal: true,
|
|
199
|
+
pip: false,
|
|
200
|
+
isTablet: true,
|
|
201
|
+
isTabletPortrait: false,
|
|
202
|
+
orientation: "landscape",
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "tablet landscape, vertical inline picture in picture",
|
|
206
|
+
vertical: true,
|
|
207
|
+
inline: true,
|
|
208
|
+
isModal: true,
|
|
209
|
+
pip: true,
|
|
210
|
+
isTablet: true,
|
|
211
|
+
isTabletPortrait: false,
|
|
212
|
+
orientation: "landscape",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "tablet landscape, vertical inline but not a modal",
|
|
216
|
+
vertical: true,
|
|
217
|
+
inline: true,
|
|
218
|
+
isModal: false,
|
|
219
|
+
pip: false,
|
|
220
|
+
isTablet: true,
|
|
221
|
+
isTabletPortrait: false,
|
|
222
|
+
orientation: "landscape",
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
it.each(cases)(
|
|
227
|
+
"$name keeps the legacy aspect-ratio frame",
|
|
228
|
+
({
|
|
229
|
+
vertical,
|
|
230
|
+
inline,
|
|
231
|
+
isModal,
|
|
232
|
+
pip,
|
|
233
|
+
isTablet,
|
|
234
|
+
isTabletPortrait,
|
|
235
|
+
orientation,
|
|
236
|
+
}) => {
|
|
237
|
+
mockIsTablet = isTablet;
|
|
238
|
+
mockOrientation = orientation;
|
|
239
|
+
|
|
240
|
+
const { result } = renderHook(() =>
|
|
241
|
+
useStyle({
|
|
242
|
+
style: { width: 1210, height: 834 },
|
|
243
|
+
inline,
|
|
244
|
+
isModal,
|
|
245
|
+
isTabletPortrait,
|
|
246
|
+
configuration: { tablet_landscape_sidebar_width: "35%" },
|
|
247
|
+
pip,
|
|
248
|
+
vertical,
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
expect(result.current.wrapperStyle).toBeNull();
|
|
253
|
+
|
|
254
|
+
expect(result.current.containerDimensions.aspectRatio).toBeCloseTo(
|
|
255
|
+
legacyAspectRatio({ vertical, inline, isModal, pip, orientation })
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
expect(result.current.childrenStyles.alignSelf).toBeUndefined();
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { getEdges, getPlayerLayout } from "../playerWrapperUtils";
|
|
2
|
+
|
|
3
|
+
describe("getEdges", () => {
|
|
4
|
+
it("keeps the top edge in fullscreen when not vertical", () => {
|
|
5
|
+
expect(getEdges(false, false)).toEqual(["top"]);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("has no edges in vertical fullscreen", () => {
|
|
9
|
+
expect(getEdges(false, false, true)).toEqual([]);
|
|
10
|
+
expect(getEdges(true, false, true)).toEqual([]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("keeps the top edge for the vertical inline modal", () => {
|
|
14
|
+
expect(getEdges(false, true, true)).toEqual(["top"]);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("getPlayerLayout", () => {
|
|
19
|
+
const baseDimensions = { width: 786.5, height: undefined };
|
|
20
|
+
|
|
21
|
+
it("keeps the aspect-ratio frame when the tablet vertical layout does not apply", () => {
|
|
22
|
+
expect(
|
|
23
|
+
getPlayerLayout({
|
|
24
|
+
baseDimensions,
|
|
25
|
+
aspectRatio: 16 / 9,
|
|
26
|
+
verticalInlineTablet: false,
|
|
27
|
+
frameHeight: 834,
|
|
28
|
+
topInset: 24,
|
|
29
|
+
bottomInset: 20,
|
|
30
|
+
})
|
|
31
|
+
).toEqual({
|
|
32
|
+
containerDimensions: {
|
|
33
|
+
width: 786.5,
|
|
34
|
+
height: undefined,
|
|
35
|
+
aspectRatio: 16 / 9,
|
|
36
|
+
},
|
|
37
|
+
playerDimensions: {
|
|
38
|
+
width: 786.5,
|
|
39
|
+
height: undefined,
|
|
40
|
+
aspectRatio: 16 / 9,
|
|
41
|
+
},
|
|
42
|
+
wrapperStyle: null,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("fills the column height and centers a 9:16 video inside the current width", () => {
|
|
47
|
+
const layout = getPlayerLayout({
|
|
48
|
+
baseDimensions,
|
|
49
|
+
aspectRatio: 9 / 16,
|
|
50
|
+
verticalInlineTablet: true,
|
|
51
|
+
frameHeight: 834,
|
|
52
|
+
topInset: 24,
|
|
53
|
+
bottomInset: 20,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const videoHeight = 834 - 24 - 20;
|
|
57
|
+
|
|
58
|
+
expect(layout.wrapperStyle).toEqual({
|
|
59
|
+
width: 786.5,
|
|
60
|
+
height: 834,
|
|
61
|
+
paddingBottom: 20,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
expect(layout.playerDimensions).toEqual({
|
|
65
|
+
width: videoHeight * (9 / 16),
|
|
66
|
+
height: videoHeight,
|
|
67
|
+
alignSelf: "center",
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("does not grow wider than the player column", () => {
|
|
72
|
+
const layout = getPlayerLayout({
|
|
73
|
+
baseDimensions: { width: 300, height: undefined },
|
|
74
|
+
aspectRatio: 9 / 16,
|
|
75
|
+
verticalInlineTablet: true,
|
|
76
|
+
frameHeight: 834,
|
|
77
|
+
topInset: 0,
|
|
78
|
+
bottomInset: 0,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(layout.playerDimensions.width).toBe(300);
|
|
82
|
+
expect(layout.playerDimensions.height).toBeCloseTo(300 * (16 / 9));
|
|
83
|
+
expect(layout.wrapperStyle).toMatchObject({ width: 300 });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
removeOrientationChangeListener,
|
|
8
8
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
11
11
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
12
12
|
import {
|
|
13
13
|
isAndroidPlatform,
|
|
@@ -16,12 +16,7 @@ import {
|
|
|
16
16
|
import { StatusBar } from "react-native";
|
|
17
17
|
import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const logger = new Logger(
|
|
22
|
-
"hooks",
|
|
23
|
-
"zapp-react-native-ui-components/Components/VideoModal"
|
|
24
|
-
);
|
|
19
|
+
const logger = subsystemLogger("player/modal", "hooks");
|
|
25
20
|
|
|
26
21
|
type Size = {
|
|
27
22
|
width: number | string;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
useSafeAreaFrame,
|
|
5
|
+
useSafeAreaInsets,
|
|
6
|
+
} from "react-native-safe-area-context";
|
|
3
7
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
useIsTablet,
|
|
10
|
+
useOrientation,
|
|
11
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
12
|
import { playerDimensionsHack } from "./utils";
|
|
6
13
|
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
7
14
|
import {
|
|
8
15
|
getBaseDimensions,
|
|
9
16
|
calculateAspectRatio,
|
|
10
|
-
|
|
11
|
-
getContainerDimensions,
|
|
17
|
+
getPlayerLayout,
|
|
12
18
|
} from "./playerWrapperUtils";
|
|
13
19
|
|
|
14
20
|
export const defaultStyles = StyleSheet.create({
|
|
@@ -22,13 +28,18 @@ export const useStyle = ({
|
|
|
22
28
|
isTabletPortrait,
|
|
23
29
|
configuration,
|
|
24
30
|
pip,
|
|
31
|
+
vertical,
|
|
25
32
|
}) => {
|
|
26
33
|
const isTablet = useIsTablet();
|
|
34
|
+
const isLandscape = useOrientation() === "landscape";
|
|
27
35
|
|
|
28
36
|
const isInlineModal = inline && isModal;
|
|
29
37
|
|
|
30
38
|
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
31
39
|
|
|
40
|
+
const frame = useSafeAreaFrame();
|
|
41
|
+
const insets = useSafeAreaInsets();
|
|
42
|
+
|
|
32
43
|
const tabletWidth = getTabletWidth(
|
|
33
44
|
configuration.tablet_landscape_sidebar_width,
|
|
34
45
|
style
|
|
@@ -40,31 +51,55 @@ export const useStyle = ({
|
|
|
40
51
|
);
|
|
41
52
|
|
|
42
53
|
const aspectRatio = React.useMemo(
|
|
43
|
-
() =>
|
|
54
|
+
() => {
|
|
55
|
+
const value = calculateAspectRatio(isInlineModal, pip);
|
|
56
|
+
|
|
57
|
+
if (!vertical) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// vertical fullscreen in landscape: the width is the long side, keep the screen ratio so the container matches the screen
|
|
62
|
+
if (isLandscape && !isInlineModal && !pip) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return 1 / value;
|
|
67
|
+
},
|
|
44
68
|
// ignoring insets - only initial needed
|
|
45
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
[isInlineModal, pip]
|
|
70
|
+
[isInlineModal, pip, vertical, isLandscape]
|
|
47
71
|
);
|
|
48
72
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
baseDimensions,
|
|
52
|
-
aspectRatio
|
|
53
|
-
);
|
|
73
|
+
const verticalInlineTablet =
|
|
74
|
+
vertical && isInlineModal && isTabletLandscape && !pip;
|
|
54
75
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
return React.useMemo(() => {
|
|
77
|
+
const { containerDimensions, playerDimensions, wrapperStyle } =
|
|
78
|
+
getPlayerLayout({
|
|
79
|
+
baseDimensions,
|
|
80
|
+
aspectRatio,
|
|
81
|
+
verticalInlineTablet,
|
|
82
|
+
frameHeight: frame.height,
|
|
83
|
+
topInset: insets.top,
|
|
84
|
+
bottomInset: insets.bottom,
|
|
85
|
+
});
|
|
59
86
|
|
|
60
|
-
|
|
61
|
-
...
|
|
62
|
-
|
|
87
|
+
return {
|
|
88
|
+
...StyleSheet.create({
|
|
89
|
+
containerDimensions,
|
|
90
|
+
childrenStyles: {
|
|
91
|
+
...playerDimensions,
|
|
92
|
+
...playerDimensionsHack,
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
wrapperStyle,
|
|
63
96
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
}, [
|
|
98
|
+
baseDimensions,
|
|
99
|
+
aspectRatio,
|
|
100
|
+
verticalInlineTablet,
|
|
101
|
+
frame.height,
|
|
102
|
+
insets.top,
|
|
103
|
+
insets.bottom,
|
|
104
|
+
]);
|
|
70
105
|
};
|
|
@@ -13,6 +13,14 @@ export type Configuration = {
|
|
|
13
13
|
tablet_landscape_player_container_background_color?: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export type PlayerLayout = {
|
|
17
|
+
containerDimensions: ViewStyle;
|
|
18
|
+
playerDimensions: ViewStyle;
|
|
19
|
+
wrapperStyle: ViewStyle | null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const VERTICAL_VIDEO_ASPECT_RATIO = 9 / 16;
|
|
23
|
+
|
|
16
24
|
// This is safe, remembering screen dimensions once as they do not change during runtime
|
|
17
25
|
// TODO: consider sharing screen orientation as a shared function for the app
|
|
18
26
|
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
@@ -44,8 +52,14 @@ export const getScreenAspectRatio = () => {
|
|
|
44
52
|
|
|
45
53
|
export const getEdges = (
|
|
46
54
|
isTablet: boolean,
|
|
47
|
-
isInlineModal: boolean
|
|
55
|
+
isInlineModal: boolean,
|
|
56
|
+
vertical: boolean = false
|
|
48
57
|
): readonly Edge[] => {
|
|
58
|
+
// vertical fullscreen: the player takes the full screen height, a top inset would push it below the screen
|
|
59
|
+
if (vertical && !isInlineModal) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
if (isTablet) {
|
|
50
64
|
return ["top"];
|
|
51
65
|
}
|
|
@@ -89,3 +103,83 @@ export const getContainerDimensions = (
|
|
|
89
103
|
...baseDimensions,
|
|
90
104
|
aspectRatio,
|
|
91
105
|
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Tablet landscape inline. Column widths stay put. The 9:16 video fills the
|
|
109
|
+
* height and is centered; controls use the full column.
|
|
110
|
+
*/
|
|
111
|
+
const getTabletVerticalInlineLayout = ({
|
|
112
|
+
columnWidth,
|
|
113
|
+
frameHeight,
|
|
114
|
+
topInset,
|
|
115
|
+
bottomInset,
|
|
116
|
+
}: {
|
|
117
|
+
columnWidth: number;
|
|
118
|
+
frameHeight: number;
|
|
119
|
+
topInset: number;
|
|
120
|
+
bottomInset: number;
|
|
121
|
+
}): PlayerLayout | null => {
|
|
122
|
+
const availableHeight = frameHeight - topInset - bottomInset;
|
|
123
|
+
|
|
124
|
+
if (!(columnWidth > 0) || !(availableHeight > 0)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const videoWidth = Math.min(
|
|
129
|
+
columnWidth,
|
|
130
|
+
availableHeight * VERTICAL_VIDEO_ASPECT_RATIO
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
wrapperStyle: {
|
|
135
|
+
width: columnWidth,
|
|
136
|
+
height: frameHeight,
|
|
137
|
+
paddingBottom: bottomInset,
|
|
138
|
+
},
|
|
139
|
+
containerDimensions: {
|
|
140
|
+
flex: 1,
|
|
141
|
+
width: "100%",
|
|
142
|
+
alignSelf: "stretch",
|
|
143
|
+
},
|
|
144
|
+
playerDimensions: {
|
|
145
|
+
width: videoWidth,
|
|
146
|
+
height: videoWidth / VERTICAL_VIDEO_ASPECT_RATIO,
|
|
147
|
+
alignSelf: "center",
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const getPlayerLayout = ({
|
|
153
|
+
baseDimensions,
|
|
154
|
+
aspectRatio,
|
|
155
|
+
verticalInlineTablet,
|
|
156
|
+
frameHeight,
|
|
157
|
+
topInset,
|
|
158
|
+
bottomInset,
|
|
159
|
+
}: {
|
|
160
|
+
baseDimensions: ViewStyle;
|
|
161
|
+
aspectRatio: number;
|
|
162
|
+
verticalInlineTablet: boolean;
|
|
163
|
+
frameHeight: number;
|
|
164
|
+
topInset: number;
|
|
165
|
+
bottomInset: number;
|
|
166
|
+
}): PlayerLayout => {
|
|
167
|
+
if (verticalInlineTablet && typeof baseDimensions.width === "number") {
|
|
168
|
+
const layout = getTabletVerticalInlineLayout({
|
|
169
|
+
columnWidth: baseDimensions.width,
|
|
170
|
+
frameHeight,
|
|
171
|
+
topInset,
|
|
172
|
+
bottomInset,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (layout) {
|
|
176
|
+
return layout;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
containerDimensions: getContainerDimensions(baseDimensions, aspectRatio),
|
|
182
|
+
playerDimensions: getPlayerDimensions(baseDimensions, aspectRatio),
|
|
183
|
+
wrapperStyle: null,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Web builds resolve `*.web.*` files first. Each web variant must export what its
|
|
2
|
+
// platformSelect module picks on every web platform, without importing the native
|
|
3
|
+
// implementations.
|
|
4
|
+
|
|
5
|
+
jest.mock(
|
|
6
|
+
"@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions",
|
|
7
|
+
() => ({ withDimensionsHOC: (Component) => Component })
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const UI = "@applicaster/zapp-react-native-ui-components/Components";
|
|
11
|
+
const TVOS_UI = "@applicaster/zapp-react-native-tvos-ui-components/Components";
|
|
12
|
+
|
|
13
|
+
const SWITCHES = [
|
|
14
|
+
[`${UI}/River/ComponentsMap/index`, "ComponentsMap"],
|
|
15
|
+
[`${UI}/Cell/PlatformCellComponent`, "PlatformCellComponent"],
|
|
16
|
+
[`${UI}/Focusable/index`, "Focusable"],
|
|
17
|
+
[`${UI}/Tabs/TV/index`, "Tabs"],
|
|
18
|
+
[`${UI}/Tabs/TV/index`, "TabContent"],
|
|
19
|
+
[`${UI}/MasterCell/DefaultComponents/Image/index`, "default"],
|
|
20
|
+
[`${TVOS_UI}/TVEventHandlerComponent/index`, "TVEventHandlerComponent"],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const COMPONENT_TYPES = [
|
|
24
|
+
"hero",
|
|
25
|
+
"screen_picker",
|
|
26
|
+
"grid",
|
|
27
|
+
"horizontal_list",
|
|
28
|
+
"gallery-qb",
|
|
29
|
+
"unknown",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
describe.each(["web", "samsung_tv", "lg_tv"])("on %s", (platform) => {
|
|
33
|
+
it.each(SWITCHES)("%s.web exports the selected %s", (path, name) => {
|
|
34
|
+
jest.isolateModules(() => {
|
|
35
|
+
require("react-native").Platform.OS = platform;
|
|
36
|
+
|
|
37
|
+
const selected = require(path)[name];
|
|
38
|
+
|
|
39
|
+
expect(selected).toBeDefined();
|
|
40
|
+
expect(require(`${path}.web`)[name]).toBe(selected);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("AudioPlayer.web renders the same player as AudioPlayer", () => {
|
|
45
|
+
jest.isolateModules(() => {
|
|
46
|
+
require("react-native").Platform.OS = platform;
|
|
47
|
+
|
|
48
|
+
const props = { entry: { id: "a" } };
|
|
49
|
+
const selected = require(`${UI}/AudioPlayer/index`).AudioPlayer(props);
|
|
50
|
+
const web = require(`${UI}/AudioPlayer/index.web`).AudioPlayer(props);
|
|
51
|
+
|
|
52
|
+
expect(selected.type).toBe(require(`${UI}/AudioPlayer/tv`).AudioPlayerTV);
|
|
53
|
+
expect(web.type).toBe(selected.type);
|
|
54
|
+
expect(web.props).toEqual(selected.props);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it.each([
|
|
59
|
+
["viewTrees", "viewTreeResolver"],
|
|
60
|
+
["containerStyles", "containerStyleResolver"],
|
|
61
|
+
])("default-cell-renderer %s.web resolves like the original", (dir, name) => {
|
|
62
|
+
jest.isolateModules(() => {
|
|
63
|
+
require("react-native").Platform.OS = platform;
|
|
64
|
+
|
|
65
|
+
const base = require(`${UI}/default-cell-renderer/${dir}/index`)[name];
|
|
66
|
+
const web = require(`${UI}/default-cell-renderer/${dir}/index.web`)[name];
|
|
67
|
+
|
|
68
|
+
COMPONENT_TYPES.forEach((component_type) => {
|
|
69
|
+
expect(web({ component_type })).toEqual(base({ component_type }));
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { containerStyleResolver as tvResolver } from "./tv";
|
|
2
|
+
|
|
3
|
+
// Web platforms (web, samsung_tv, lg_tv) always use the TV resolver, so web builds leave the mobile one out.
|
|
4
|
+
export function containerStyleResolver({ component_type }) {
|
|
5
|
+
return tvResolver({ component_type });
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { viewTreeResolver as tvResolver } from "./tv";
|
|
2
|
+
|
|
3
|
+
// Web platforms (web, samsung_tv, lg_tv) always use the TV resolver, so web builds leave the mobile one out.
|
|
4
|
+
export function viewTreeResolver({
|
|
5
|
+
component_type,
|
|
6
|
+
}: {
|
|
7
|
+
component_type: string;
|
|
8
|
+
}) {
|
|
9
|
+
return tvResolver({ component_type });
|
|
10
|
+
}
|