@applicaster/zapp-react-native-ui-components 17.0.0-alpha.1037440043 → 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/Focusable/index.web.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
- package/Components/River/ComponentsMap/index.web.tsx +3 -0
- package/Components/Tabs/TV/index.web.tsx +5 -0
- package/Components/VideoModal/PlayerWrapper.tsx +5 -1
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +204 -1
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +70 -1
- package/Components/VideoModal/playerWrapperStyle.ts +37 -20
- package/Components/VideoModal/playerWrapperUtils.ts +88 -0
- 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/package.json +5 -5
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { AudioPlayerTV } from "./tv";
|
|
4
|
+
|
|
5
|
+
import { Props } from "./types";
|
|
6
|
+
|
|
7
|
+
// isTV() is true on every web platform, so web builds always render the TV audio player and leave the mobile one out.
|
|
8
|
+
export function AudioPlayer(props: Props) {
|
|
9
|
+
return <AudioPlayerTV {...props} />;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
2
|
+
|
|
3
|
+
import { CellComponent } from "./Cell";
|
|
4
|
+
import { TvOSCellComponent } from "./TvOSCellComponent";
|
|
5
|
+
|
|
6
|
+
export const PlatformCellComponent = platformSelect({
|
|
7
|
+
tvos: TvOSCellComponent,
|
|
8
|
+
default: CellComponent,
|
|
9
|
+
});
|
package/Components/Cell/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
3
|
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
|
-
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
HorizontalScrollContext,
|
|
@@ -9,8 +8,7 @@ import {
|
|
|
9
8
|
ScreenScrollingContext,
|
|
10
9
|
} from "../../Contexts";
|
|
11
10
|
|
|
12
|
-
import {
|
|
13
|
-
import { TvOSCellComponent } from "./TvOSCellComponent";
|
|
11
|
+
import { PlatformCellComponent } from "./PlatformCellComponent";
|
|
14
12
|
import { withConsumer } from "../../Contexts/HeaderOffsetContext";
|
|
15
13
|
|
|
16
14
|
import { ScreenLayoutContextConsumer } from "../../Contexts/ScreenLayoutContext";
|
|
@@ -23,11 +21,6 @@ export const ScrollInterceptorContext = createContext(
|
|
|
23
21
|
(_) => _
|
|
24
22
|
);
|
|
25
23
|
|
|
26
|
-
const Component = platformSelect({
|
|
27
|
-
tvos: TvOSCellComponent,
|
|
28
|
-
default: CellComponent,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
24
|
export const Cell = R.compose(
|
|
32
25
|
connectToStore(R.pick(["remoteConfigurations", "appData"])),
|
|
33
26
|
ScrollInterceptorContext.withConsumer,
|
|
@@ -37,4 +30,4 @@ export const Cell = R.compose(
|
|
|
37
30
|
withConsumer,
|
|
38
31
|
ScreenLayoutContextConsumer,
|
|
39
32
|
withComponentsMapOffsetContextConsumer
|
|
40
|
-
)(
|
|
33
|
+
)(PlatformCellComponent);
|
|
@@ -56,7 +56,11 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
56
56
|
return (
|
|
57
57
|
<WrapperView
|
|
58
58
|
edges={getEdges(isTablet, isInlineModal, vertical) as readonly Edge[]}
|
|
59
|
-
style={
|
|
59
|
+
style={
|
|
60
|
+
styles.wrapperStyle
|
|
61
|
+
? [playerDimensionsHack, styles.wrapperStyle]
|
|
62
|
+
: playerDimensionsHack
|
|
63
|
+
}
|
|
60
64
|
>
|
|
61
65
|
<View
|
|
62
66
|
testID={`${entry?.id}-player-container`}
|
|
@@ -4,12 +4,21 @@ import { useStyle } from "../playerWrapperStyle";
|
|
|
4
4
|
import { getScreenAspectRatio } from "../playerWrapperUtils";
|
|
5
5
|
|
|
6
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 };
|
|
7
11
|
|
|
8
12
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
9
|
-
useIsTablet: () =>
|
|
13
|
+
useIsTablet: () => mockIsTablet,
|
|
10
14
|
useOrientation: () => mockOrientation,
|
|
11
15
|
}));
|
|
12
16
|
|
|
17
|
+
jest.mock("react-native-safe-area-context", () => ({
|
|
18
|
+
useSafeAreaFrame: () => mockFrame,
|
|
19
|
+
useSafeAreaInsets: () => mockInsets,
|
|
20
|
+
}));
|
|
21
|
+
|
|
13
22
|
const getAspectRatio = (props: {
|
|
14
23
|
vertical: boolean;
|
|
15
24
|
inline?: boolean;
|
|
@@ -33,6 +42,15 @@ const getAspectRatio = (props: {
|
|
|
33
42
|
describe("useStyle aspectRatio", () => {
|
|
34
43
|
const screenRatio = getScreenAspectRatio();
|
|
35
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
|
+
|
|
36
54
|
it("uses the screen ratio when not vertical", () => {
|
|
37
55
|
mockOrientation = "portrait";
|
|
38
56
|
expect(getAspectRatio({ vertical: false })).toBeCloseTo(screenRatio);
|
|
@@ -55,4 +73,189 @@ describe("useStyle aspectRatio", () => {
|
|
|
55
73
|
9 / 16
|
|
56
74
|
);
|
|
57
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
|
+
);
|
|
58
261
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEdges } from "../playerWrapperUtils";
|
|
1
|
+
import { getEdges, getPlayerLayout } from "../playerWrapperUtils";
|
|
2
2
|
|
|
3
3
|
describe("getEdges", () => {
|
|
4
4
|
it("keeps the top edge in fullscreen when not vertical", () => {
|
|
@@ -14,3 +14,72 @@ describe("getEdges", () => {
|
|
|
14
14
|
expect(getEdges(false, true, true)).toEqual(["top"]);
|
|
15
15
|
});
|
|
16
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
|
+
});
|
|
@@ -1,5 +1,9 @@
|
|
|
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
8
|
import {
|
|
5
9
|
useIsTablet,
|
|
@@ -10,8 +14,7 @@ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils
|
|
|
10
14
|
import {
|
|
11
15
|
getBaseDimensions,
|
|
12
16
|
calculateAspectRatio,
|
|
13
|
-
|
|
14
|
-
getContainerDimensions,
|
|
17
|
+
getPlayerLayout,
|
|
15
18
|
} from "./playerWrapperUtils";
|
|
16
19
|
|
|
17
20
|
export const defaultStyles = StyleSheet.create({
|
|
@@ -34,6 +37,9 @@ export const useStyle = ({
|
|
|
34
37
|
|
|
35
38
|
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
36
39
|
|
|
40
|
+
const frame = useSafeAreaFrame();
|
|
41
|
+
const insets = useSafeAreaInsets();
|
|
42
|
+
|
|
37
43
|
const tabletWidth = getTabletWidth(
|
|
38
44
|
configuration.tablet_landscape_sidebar_width,
|
|
39
45
|
style
|
|
@@ -64,25 +70,36 @@ export const useStyle = ({
|
|
|
64
70
|
[isInlineModal, pip, vertical, isLandscape]
|
|
65
71
|
);
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
baseDimensions,
|
|
70
|
-
aspectRatio
|
|
71
|
-
);
|
|
73
|
+
const verticalInlineTablet =
|
|
74
|
+
vertical && isInlineModal && isTabletLandscape && !pip;
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
});
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
...
|
|
80
|
-
|
|
87
|
+
return {
|
|
88
|
+
...StyleSheet.create({
|
|
89
|
+
containerDimensions,
|
|
90
|
+
childrenStyles: {
|
|
91
|
+
...playerDimensions,
|
|
92
|
+
...playerDimensionsHack,
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
wrapperStyle,
|
|
81
96
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
}, [
|
|
98
|
+
baseDimensions,
|
|
99
|
+
aspectRatio,
|
|
100
|
+
verticalInlineTablet,
|
|
101
|
+
frame.height,
|
|
102
|
+
insets.top,
|
|
103
|
+
insets.bottom,
|
|
104
|
+
]);
|
|
88
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");
|
|
@@ -95,3 +103,83 @@ export const getContainerDimensions = (
|
|
|
95
103
|
...baseDimensions,
|
|
96
104
|
aspectRatio,
|
|
97
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "17.0.0-alpha.
|
|
3
|
+
"version": "17.0.0-alpha.1201533844",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "17.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "17.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "17.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "17.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "17.0.0-alpha.1201533844",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "17.0.0-alpha.1201533844",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "17.0.0-alpha.1201533844",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "17.0.0-alpha.1201533844",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"react-native-sortables": "1.7.1",
|