@applicaster/zapp-react-native-ui-components 17.0.0-rc.2 → 17.0.0-rc.4
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 +20 -1
- package/Components/ComponentResolver/ComponentResolver.ts +4 -0
- package/Components/Focusable/index.web.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +29 -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/index.web.ts +7 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +22 -4
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
- package/Components/MasterCell/__tests__/masterCell.test.js +56 -0
- package/Components/MasterCell/index.tsx +17 -2
- package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
- package/Components/MasterCell/utils/index.ts +39 -1
- package/Components/ModalComponent/Button/index.tsx +3 -1
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
- package/Components/ModalComponent/presets/index.ts +2 -3
- 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/ScreenResolver/index.tsx +4 -1
- 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/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
- package/Components/VideoModal/PlayerDetails.tsx +27 -2
- package/Components/VideoModal/PlayerWrapper.tsx +5 -1
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +206 -1
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +110 -1
- package/Components/VideoModal/playerWrapperStyle.ts +41 -20
- package/Components/VideoModal/playerWrapperUtils.ts +134 -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/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
- package/Decorators/RiverResolver/index.tsx +25 -0
- package/package.json +5 -5
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getEdges,
|
|
3
|
+
getPlayerLayout,
|
|
4
|
+
getVerticalColumnWidth,
|
|
5
|
+
} from "../playerWrapperUtils";
|
|
2
6
|
|
|
3
7
|
describe("getEdges", () => {
|
|
4
8
|
it("keeps the top edge in fullscreen when not vertical", () => {
|
|
@@ -14,3 +18,108 @@ describe("getEdges", () => {
|
|
|
14
18
|
expect(getEdges(false, true, true)).toEqual(["top"]);
|
|
15
19
|
});
|
|
16
20
|
});
|
|
21
|
+
|
|
22
|
+
describe("getVerticalColumnWidth", () => {
|
|
23
|
+
it("splits the frame by the configured percentage", () => {
|
|
24
|
+
expect(getVerticalColumnWidth(1000, "25%")).toBeCloseTo(750);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("subtracts a fixed sidebar", () => {
|
|
28
|
+
expect(getVerticalColumnWidth(1000, "300")).toBeCloseTo(700);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("falls back to the default split without a sidebar", () => {
|
|
32
|
+
expect(getVerticalColumnWidth(1000, undefined)).toBeCloseTo(650);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("falls back to the default split for a malformed sidebar", () => {
|
|
36
|
+
expect(getVerticalColumnWidth(1000, "abc")).toBeCloseTo(650);
|
|
37
|
+
expect(getVerticalColumnWidth(1000, "abc%")).toBeCloseTo(650);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("never leaves a negative column for a sidebar wider than the frame", () => {
|
|
41
|
+
expect(getVerticalColumnWidth(1000, "120%")).toBeCloseTo(650);
|
|
42
|
+
expect(getVerticalColumnWidth(1000, "1200")).toBeCloseTo(650);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("has no column before the frame is known", () => {
|
|
46
|
+
expect(getVerticalColumnWidth(0, "35%")).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("getPlayerLayout", () => {
|
|
51
|
+
const baseDimensions = { width: 786.5, height: undefined };
|
|
52
|
+
|
|
53
|
+
it("keeps the aspect-ratio frame when the tablet vertical layout does not apply", () => {
|
|
54
|
+
expect(
|
|
55
|
+
getPlayerLayout({
|
|
56
|
+
baseDimensions,
|
|
57
|
+
aspectRatio: 16 / 9,
|
|
58
|
+
verticalInlineTablet: false,
|
|
59
|
+
frameWidth: 1210,
|
|
60
|
+
frameHeight: 834,
|
|
61
|
+
sidebarWidth: "35%",
|
|
62
|
+
topInset: 24,
|
|
63
|
+
bottomInset: 20,
|
|
64
|
+
})
|
|
65
|
+
).toEqual({
|
|
66
|
+
containerDimensions: {
|
|
67
|
+
width: 786.5,
|
|
68
|
+
height: undefined,
|
|
69
|
+
aspectRatio: 16 / 9,
|
|
70
|
+
},
|
|
71
|
+
playerDimensions: {
|
|
72
|
+
width: 786.5,
|
|
73
|
+
height: undefined,
|
|
74
|
+
aspectRatio: 16 / 9,
|
|
75
|
+
},
|
|
76
|
+
wrapperStyle: null,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("fills the column height and centers a 9:16 video inside the current width", () => {
|
|
81
|
+
const layout = getPlayerLayout({
|
|
82
|
+
baseDimensions,
|
|
83
|
+
aspectRatio: 9 / 16,
|
|
84
|
+
verticalInlineTablet: true,
|
|
85
|
+
frameWidth: 1210,
|
|
86
|
+
frameHeight: 834,
|
|
87
|
+
sidebarWidth: "35%",
|
|
88
|
+
topInset: 24,
|
|
89
|
+
bottomInset: 20,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const videoHeight = 834 - 24 - 20;
|
|
93
|
+
|
|
94
|
+
expect(layout.wrapperStyle).toEqual({
|
|
95
|
+
width: 786.5,
|
|
96
|
+
height: 834,
|
|
97
|
+
paddingBottom: 20,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(layout.playerDimensions).toEqual({
|
|
101
|
+
width: videoHeight * (9 / 16),
|
|
102
|
+
height: videoHeight,
|
|
103
|
+
alignSelf: "center",
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("does not grow wider than the player column", () => {
|
|
108
|
+
const layout = getPlayerLayout({
|
|
109
|
+
baseDimensions: { width: 300, height: undefined },
|
|
110
|
+
aspectRatio: 9 / 16,
|
|
111
|
+
verticalInlineTablet: true,
|
|
112
|
+
frameWidth: 300,
|
|
113
|
+
frameHeight: 834,
|
|
114
|
+
sidebarWidth: "0%",
|
|
115
|
+
topInset: 0,
|
|
116
|
+
bottomInset: 0,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(layout.playerDimensions.width).toBe(300);
|
|
120
|
+
expect(layout.playerDimensions.height).toBeCloseTo(300 * (16 / 9));
|
|
121
|
+
expect(layout.playerDimensions.marginTop).toBe("auto");
|
|
122
|
+
expect(layout.playerDimensions.marginBottom).toBe("auto");
|
|
123
|
+
expect(layout.wrapperStyle).toMatchObject({ width: 300 });
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -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,40 @@ 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
|
+
frameWidth: frame.width,
|
|
83
|
+
frameHeight: frame.height,
|
|
84
|
+
sidebarWidth: configuration.tablet_landscape_sidebar_width,
|
|
85
|
+
topInset: insets.top,
|
|
86
|
+
bottomInset: insets.bottom,
|
|
87
|
+
});
|
|
77
88
|
|
|
78
|
-
|
|
79
|
-
...
|
|
80
|
-
|
|
89
|
+
return {
|
|
90
|
+
...StyleSheet.create({
|
|
91
|
+
containerDimensions,
|
|
92
|
+
childrenStyles: {
|
|
93
|
+
...playerDimensions,
|
|
94
|
+
...playerDimensionsHack,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
wrapperStyle,
|
|
81
98
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
}, [
|
|
100
|
+
baseDimensions,
|
|
101
|
+
aspectRatio,
|
|
102
|
+
verticalInlineTablet,
|
|
103
|
+
configuration.tablet_landscape_sidebar_width,
|
|
104
|
+
frame.width,
|
|
105
|
+
frame.height,
|
|
106
|
+
insets.top,
|
|
107
|
+
insets.bottom,
|
|
108
|
+
]);
|
|
88
109
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
|
|
2
2
|
import { Edge } from "react-native-safe-area-context";
|
|
3
|
+
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
3
4
|
|
|
4
5
|
export type DimensionsT = {
|
|
5
6
|
width: number | string;
|
|
@@ -13,6 +14,43 @@ export type Configuration = {
|
|
|
13
14
|
tablet_landscape_player_container_background_color?: string;
|
|
14
15
|
};
|
|
15
16
|
|
|
17
|
+
export type PlayerLayout = {
|
|
18
|
+
containerDimensions: ViewStyle;
|
|
19
|
+
playerDimensions: ViewStyle;
|
|
20
|
+
wrapperStyle: ViewStyle | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const VERTICAL_VIDEO_ASPECT_RATIO = 9 / 16;
|
|
24
|
+
|
|
25
|
+
const DEFAULT_PLAYER_COLUMN_RATIO = 0.65;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Player column width for the given frame, using the same split as the rest of
|
|
29
|
+
* the tablet landscape layout. `getTabletWidth` resolves percentages against
|
|
30
|
+
* `Dimensions.get("screen")`, which is the whole device in split view and lags
|
|
31
|
+
* a rotation on Android, so it is fed the live frame instead.
|
|
32
|
+
*/
|
|
33
|
+
export const getVerticalColumnWidth = (
|
|
34
|
+
frameWidth: number,
|
|
35
|
+
sidebarWidth?: string
|
|
36
|
+
): number => {
|
|
37
|
+
if (!(frameWidth > 0)) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const columnWidth = getTabletWidth(sidebarWidth, {
|
|
42
|
+
width: frameWidth,
|
|
43
|
+
height: undefined,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// A malformed sidebar width yields NaN or a negative column.
|
|
47
|
+
if (!(columnWidth > 0)) {
|
|
48
|
+
return frameWidth * DEFAULT_PLAYER_COLUMN_RATIO;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return Math.min(columnWidth, frameWidth);
|
|
52
|
+
};
|
|
53
|
+
|
|
16
54
|
// This is safe, remembering screen dimensions once as they do not change during runtime
|
|
17
55
|
// TODO: consider sharing screen orientation as a shared function for the app
|
|
18
56
|
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
@@ -95,3 +133,99 @@ export const getContainerDimensions = (
|
|
|
95
133
|
...baseDimensions,
|
|
96
134
|
aspectRatio,
|
|
97
135
|
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Tablet landscape inline. Column widths stay put. The 9:16 video fills the
|
|
139
|
+
* height and is centered; controls use the full column.
|
|
140
|
+
*/
|
|
141
|
+
const getTabletVerticalInlineLayout = ({
|
|
142
|
+
columnWidth,
|
|
143
|
+
frameHeight,
|
|
144
|
+
topInset,
|
|
145
|
+
bottomInset,
|
|
146
|
+
}: {
|
|
147
|
+
columnWidth: number;
|
|
148
|
+
frameHeight: number;
|
|
149
|
+
topInset: number;
|
|
150
|
+
bottomInset: number;
|
|
151
|
+
}): PlayerLayout | null => {
|
|
152
|
+
const availableHeight = frameHeight - topInset - bottomInset;
|
|
153
|
+
|
|
154
|
+
if (!(columnWidth > 0) || !(availableHeight > 0)) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const videoWidth = Math.min(
|
|
159
|
+
columnWidth,
|
|
160
|
+
availableHeight * VERTICAL_VIDEO_ASPECT_RATIO
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const videoHeight = videoWidth / VERTICAL_VIDEO_ASPECT_RATIO;
|
|
164
|
+
|
|
165
|
+
// alignSelf only centers horizontally. A column narrower than a full-height
|
|
166
|
+
// 9:16 frame (common on Android tablets) leaves empty space below the video.
|
|
167
|
+
const verticalMargins =
|
|
168
|
+
videoHeight < availableHeight
|
|
169
|
+
? { marginTop: "auto" as const, marginBottom: "auto" as const }
|
|
170
|
+
: null;
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
wrapperStyle: {
|
|
174
|
+
width: columnWidth,
|
|
175
|
+
height: frameHeight,
|
|
176
|
+
paddingBottom: bottomInset,
|
|
177
|
+
},
|
|
178
|
+
containerDimensions: {
|
|
179
|
+
flex: 1,
|
|
180
|
+
width: "100%",
|
|
181
|
+
alignSelf: "stretch",
|
|
182
|
+
},
|
|
183
|
+
playerDimensions: {
|
|
184
|
+
width: videoWidth,
|
|
185
|
+
height: videoHeight,
|
|
186
|
+
alignSelf: "center",
|
|
187
|
+
...verticalMargins,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const getPlayerLayout = ({
|
|
193
|
+
baseDimensions,
|
|
194
|
+
aspectRatio,
|
|
195
|
+
verticalInlineTablet,
|
|
196
|
+
frameWidth,
|
|
197
|
+
frameHeight,
|
|
198
|
+
sidebarWidth,
|
|
199
|
+
topInset,
|
|
200
|
+
bottomInset,
|
|
201
|
+
}: {
|
|
202
|
+
baseDimensions: ViewStyle;
|
|
203
|
+
aspectRatio: number;
|
|
204
|
+
verticalInlineTablet: boolean;
|
|
205
|
+
frameWidth: number;
|
|
206
|
+
frameHeight: number;
|
|
207
|
+
sidebarWidth?: string;
|
|
208
|
+
topInset: number;
|
|
209
|
+
bottomInset: number;
|
|
210
|
+
}): PlayerLayout => {
|
|
211
|
+
const columnWidth = getVerticalColumnWidth(frameWidth, sidebarWidth);
|
|
212
|
+
|
|
213
|
+
if (verticalInlineTablet && columnWidth > 0) {
|
|
214
|
+
const layout = getTabletVerticalInlineLayout({
|
|
215
|
+
columnWidth,
|
|
216
|
+
frameHeight,
|
|
217
|
+
topInset,
|
|
218
|
+
bottomInset,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
if (layout) {
|
|
222
|
+
return layout;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
containerDimensions: getContainerDimensions(baseDimensions, aspectRatio),
|
|
228
|
+
playerDimensions: getPlayerDimensions(baseDimensions, aspectRatio),
|
|
229
|
+
wrapperStyle: null,
|
|
230
|
+
};
|
|
231
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
|
|
5
|
+
const mockError = jest.fn();
|
|
6
|
+
|
|
7
|
+
jest.mock("@applicaster/zapp-react-native-utils/logger", () => ({
|
|
8
|
+
// Called on import, before mockError is assigned: look it up at call time.
|
|
9
|
+
subsystemLogger: () => ({ error: (event) => mockError(event) }),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
13
|
+
useRivers: () => ({ A123: { id: "A123" } }),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock(
|
|
17
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname",
|
|
18
|
+
() => ({ usePathname: () => "/home" })
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
import { withRiver } from "../";
|
|
22
|
+
|
|
23
|
+
const Wrapped = withRiver((props) => <View {...props} />);
|
|
24
|
+
|
|
25
|
+
describe("withRiver with a screen that is not in the layout", () => {
|
|
26
|
+
beforeEach(() => mockError.mockClear());
|
|
27
|
+
|
|
28
|
+
it("renders nothing and logs the entry that led there", () => {
|
|
29
|
+
const entry = { id: "e1", title: "Star Wars", type: { value: "movie" } };
|
|
30
|
+
|
|
31
|
+
const { toJSON } = render(<Wrapped screenId="e1" screenData={entry} />);
|
|
32
|
+
|
|
33
|
+
expect(toJSON()).toBeNull();
|
|
34
|
+
expect(mockError).toHaveBeenCalledTimes(1);
|
|
35
|
+
|
|
36
|
+
expect(mockError).toHaveBeenCalledWith({
|
|
37
|
+
message:
|
|
38
|
+
"river not found, blank screen shown, screen_id=e1, entry_type=movie",
|
|
39
|
+
data: {
|
|
40
|
+
diagnostic: { code: "type-mapping" },
|
|
41
|
+
screen_id: "e1",
|
|
42
|
+
entry,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("does not log for a screen that exists", () => {
|
|
48
|
+
render(<Wrapped screenId="A123" />);
|
|
49
|
+
|
|
50
|
+
expect(mockError).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -3,6 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
4
|
import { usePathname } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname";
|
|
5
5
|
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
7
|
+
|
|
8
|
+
const logger = subsystemLogger("ui/screens", "RiverResolver");
|
|
6
9
|
|
|
7
10
|
type Props = ZappUIComponentProps & {
|
|
8
11
|
rivers: ZappRivers;
|
|
@@ -15,6 +18,28 @@ export function withRiver(Component: ZappComponent): ZappComponent {
|
|
|
15
18
|
const river = useRivers()?.[screenId];
|
|
16
19
|
const pathname = usePathname();
|
|
17
20
|
|
|
21
|
+
// Nothing is rendered for a screen that is not in the layout, so the log is the only trace of
|
|
22
|
+
// the blank screen: usually a tapped entry whose type leads to no screen.
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (!river) {
|
|
25
|
+
// Without a river the screen data is the entry that was pushed.
|
|
26
|
+
const entry = otherProps.screenData as unknown as ZappEntry | undefined;
|
|
27
|
+
|
|
28
|
+
logger.error({
|
|
29
|
+
message: `river not found, blank screen shown, screen_id=${screenId}, entry_type=${entry?.type?.value}`,
|
|
30
|
+
data: {
|
|
31
|
+
// For X-Ray diagnostics: keep when the message is reworded. No `case`: all that is
|
|
32
|
+
// known here is that the screen is missing.
|
|
33
|
+
diagnostic: { code: "type-mapping" },
|
|
34
|
+
screen_id: screenId,
|
|
35
|
+
entry,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Once per screen: the entry object is new on every render.
|
|
40
|
+
// eslint-disable-next-line @wogns3623/better-exhaustive-deps/exhaustive-deps
|
|
41
|
+
}, [river, screenId]);
|
|
42
|
+
|
|
18
43
|
if (!river) {
|
|
19
44
|
return null;
|
|
20
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.4",
|
|
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-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "17.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "17.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "17.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "17.0.0-rc.4",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "17.0.0-rc.4",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "17.0.0-rc.4",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "17.0.0-rc.4",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"react-native-sortables": "1.7.1",
|