@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5606245605 → 12.0.0-alpha.5722041245
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/Cell/Cell.tsx +2 -2
- package/Components/Cell/CellWithFocusable.tsx +21 -14
- package/Components/Cell/TvOSCellComponent.tsx +2 -2
- package/Components/FocusableCell/index.tsx +7 -7
- package/Components/HookRenderer/index.tsx +1 -3
- package/Components/Image/utils/index.ts +21 -11
- package/Components/Layout/TV/__tests__/index.test.tsx +1 -13
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
- package/Components/MasterCell/utils/index.ts +18 -7
- package/Components/PlayerContainer/PlayerContainer.tsx +46 -28
- package/Components/River/__tests__/componentsMap.test.js +1 -0
- package/Components/Screen/__tests__/Screen.test.tsx +5 -1
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +10 -2
- package/Components/Screen/index.tsx +15 -13
- package/Components/Tabs/TV/styles.ts +1 -1
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +5 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +211 -163
- package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
- package/package.json +5 -5
package/Components/Cell/Cell.tsx
CHANGED
|
@@ -202,7 +202,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
202
202
|
groupId,
|
|
203
203
|
isFocusable = true,
|
|
204
204
|
skipFocusManagerRegistration,
|
|
205
|
-
behavior
|
|
205
|
+
behavior,
|
|
206
206
|
} = this.props;
|
|
207
207
|
|
|
208
208
|
const { id } = item;
|
|
@@ -263,7 +263,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
263
263
|
item,
|
|
264
264
|
focused: this.isCellFocused(focused),
|
|
265
265
|
scrollTo: this.scrollToIndex(event),
|
|
266
|
-
behavior
|
|
266
|
+
behavior,
|
|
267
267
|
}}
|
|
268
268
|
/>
|
|
269
269
|
);
|
|
@@ -35,18 +35,18 @@ const useCellFocusedState = (groupId: string, id: string) => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
type Props = {
|
|
38
|
-
item: ZappEntry
|
|
39
|
-
CellRenderer: React.ComponentType<{ item: Object
|
|
40
|
-
id: string
|
|
41
|
-
groupId: string
|
|
42
|
-
onFocus: Function
|
|
43
|
-
index: number
|
|
44
|
-
scrollTo: Function
|
|
45
|
-
preferredFocus?: boolean
|
|
46
|
-
skipFocusManagerRegistration?: boolean
|
|
47
|
-
isFocusable?: boolean
|
|
48
|
-
behavior: Behavior
|
|
49
|
-
selected?: boolean
|
|
38
|
+
item: ZappEntry;
|
|
39
|
+
CellRenderer: React.ComponentType<{ item: Object; state: string }>;
|
|
40
|
+
id: string;
|
|
41
|
+
groupId: string;
|
|
42
|
+
onFocus: Function;
|
|
43
|
+
index: number;
|
|
44
|
+
scrollTo: Function;
|
|
45
|
+
preferredFocus?: boolean;
|
|
46
|
+
skipFocusManagerRegistration?: boolean;
|
|
47
|
+
isFocusable?: boolean;
|
|
48
|
+
behavior: Behavior;
|
|
49
|
+
selected?: boolean;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
export function CellWithFocusable(props: Props) {
|
|
@@ -62,11 +62,18 @@ export function CellWithFocusable(props: Props) {
|
|
|
62
62
|
skipFocusManagerRegistration,
|
|
63
63
|
isFocusable,
|
|
64
64
|
behavior,
|
|
65
|
-
selected
|
|
65
|
+
selected,
|
|
66
66
|
} = props;
|
|
67
67
|
|
|
68
68
|
const isFocused = useCellFocusedState(groupId, id);
|
|
69
|
-
|
|
69
|
+
|
|
70
|
+
const state = useCellState({
|
|
71
|
+
id: item.id,
|
|
72
|
+
behavior,
|
|
73
|
+
focused: isFocused,
|
|
74
|
+
selected,
|
|
75
|
+
});
|
|
76
|
+
|
|
70
77
|
const [focusedButtonId, setFocusedButtonId] = React.useState(undefined);
|
|
71
78
|
|
|
72
79
|
// for horizontal scrolling
|
|
@@ -249,7 +249,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
249
249
|
hasReceivedFocus,
|
|
250
250
|
groupId,
|
|
251
251
|
isFocusable,
|
|
252
|
-
behavior
|
|
252
|
+
behavior,
|
|
253
253
|
} = this.props;
|
|
254
254
|
|
|
255
255
|
const { id } = item;
|
|
@@ -310,7 +310,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
310
310
|
item,
|
|
311
311
|
focused: this.props.focused || selectedCell || focused,
|
|
312
312
|
scrollTo: this.scrollTo,
|
|
313
|
-
behavior
|
|
313
|
+
behavior,
|
|
314
314
|
}}
|
|
315
315
|
/>
|
|
316
316
|
);
|
|
@@ -3,12 +3,12 @@ import { Platform } from "react-native";
|
|
|
3
3
|
import { useCellState } from "../MasterCell/utils";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
|
-
index: number
|
|
7
|
-
item: ZappEntry
|
|
8
|
-
focused: boolean
|
|
9
|
-
scrollTo?: (index: number) => void
|
|
10
|
-
CellRenderer: React.ComponentType<{ item: Object
|
|
11
|
-
behavior: Behavior
|
|
6
|
+
index: number;
|
|
7
|
+
item: ZappEntry;
|
|
8
|
+
focused: boolean;
|
|
9
|
+
scrollTo?: (index: number) => void;
|
|
10
|
+
CellRenderer: React.ComponentType<{ item: Object; state: string }>;
|
|
11
|
+
behavior: Behavior;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const isAndroid = Platform.OS === "android";
|
|
@@ -20,7 +20,7 @@ export function FocusableCell(props: Props) {
|
|
|
20
20
|
CellRenderer,
|
|
21
21
|
focused,
|
|
22
22
|
scrollTo = null,
|
|
23
|
-
behavior
|
|
23
|
+
behavior,
|
|
24
24
|
} = props;
|
|
25
25
|
|
|
26
26
|
const state = useCellState({ id: item.id, behavior, focused });
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
+
import FastImage, { Source } from "@applicaster/react-native-fast-image";
|
|
1
2
|
import { useMemo } from "react";
|
|
3
|
+
import { ImageRequireSource } from "react-native";
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
function getSourceCache(cache: Source["cache"]) {
|
|
6
|
+
return cache || FastImage.cacheControl.web;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useImageSource = (source?: Source | ImageRequireSource) => {
|
|
4
10
|
return useMemo(() => {
|
|
5
|
-
if (
|
|
6
|
-
|
|
11
|
+
if (source) {
|
|
12
|
+
if (typeof source === "number") {
|
|
13
|
+
return source;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
uri: source.uri,
|
|
18
|
+
headers: source.headers,
|
|
19
|
+
priority: source.priority,
|
|
20
|
+
cache: getSourceCache(source?.cache),
|
|
21
|
+
maxWidth: source.maxWidth,
|
|
22
|
+
maxHeight: source.maxHeight,
|
|
23
|
+
};
|
|
7
24
|
}
|
|
8
25
|
|
|
9
|
-
return
|
|
10
|
-
uri: source.uri,
|
|
11
|
-
headers: source.headers,
|
|
12
|
-
priority: source.priority,
|
|
13
|
-
cache: source.cache,
|
|
14
|
-
maxWidth: source.maxWidth,
|
|
15
|
-
maxHeight: source.maxHeight,
|
|
16
|
-
};
|
|
26
|
+
return undefined;
|
|
17
27
|
}, [
|
|
18
28
|
...(typeof source === "object"
|
|
19
29
|
? [
|
|
@@ -12,19 +12,7 @@ jest.mock("@applicaster/quick-brick-core/App/ActionSetters", () => ({
|
|
|
12
12
|
useRiverInitialState: () => ({}),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen"
|
|
16
|
-
useCurrentScreenData: jest.fn(() => ({
|
|
17
|
-
navigations: [
|
|
18
|
-
{
|
|
19
|
-
category: "menu",
|
|
20
|
-
navigation_type: "menu",
|
|
21
|
-
styles: {
|
|
22
|
-
hide_secondary_level_menu: false,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
})),
|
|
27
|
-
}));
|
|
15
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
28
16
|
|
|
29
17
|
const Layout = require("..").default;
|
|
30
18
|
|
|
@@ -23,7 +23,11 @@ export const Toggle = (props: Props) => {
|
|
|
23
23
|
iosBackgroundColor,
|
|
24
24
|
} = style;
|
|
25
25
|
|
|
26
|
-
const isSelected = React.useMemo(
|
|
26
|
+
const isSelected = React.useMemo(
|
|
27
|
+
() => cellState === "selected",
|
|
28
|
+
[item?.id, cellState]
|
|
29
|
+
);
|
|
30
|
+
|
|
27
31
|
const actionContext = useActions(action?.identifier);
|
|
28
32
|
|
|
29
33
|
const [actionState, setActionState] = useState(
|
|
@@ -125,13 +125,24 @@ export const useFilterChildren = <
|
|
|
125
125
|
|
|
126
126
|
const filteredChildren = children.filter((child) => {
|
|
127
127
|
const item = child.props.item;
|
|
128
|
-
const
|
|
128
|
+
const actionIdentifier = child.props.pluginIdentifier;
|
|
129
|
+
const action = actions.actions[actionIdentifier];
|
|
130
|
+
|
|
129
131
|
// context value of specific plugin
|
|
130
|
-
|
|
132
|
+
if (action?.module && action.module.context) {
|
|
133
|
+
const currentValue = action.module.context._currentValue;
|
|
134
|
+
|
|
135
|
+
return currentValue?.isActionAvailable
|
|
136
|
+
? currentValue.isActionAvailable(item)
|
|
137
|
+
: true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
masterCellLogger.error({
|
|
141
|
+
message: `Action plugin for ${actionIdentifier} could not be found, check the configuration of your action button`,
|
|
142
|
+
data: { item, action: child.props.pluginIdentifier },
|
|
143
|
+
});
|
|
131
144
|
|
|
132
|
-
return
|
|
133
|
-
? currentValue.isActionAvailable(item)
|
|
134
|
-
: true;
|
|
145
|
+
return false;
|
|
135
146
|
});
|
|
136
147
|
|
|
137
148
|
return filteredChildren;
|
|
@@ -285,8 +296,8 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
|
285
296
|
}
|
|
286
297
|
}
|
|
287
298
|
}, [behavior]);
|
|
288
|
-
|
|
289
|
-
|
|
299
|
+
|
|
300
|
+
useEffect(() => {
|
|
290
301
|
if (!behavior) {
|
|
291
302
|
return;
|
|
292
303
|
}
|
|
@@ -145,34 +145,30 @@ const renderApplePlayer = ({
|
|
|
145
145
|
}) => {
|
|
146
146
|
const { title, summary } = item || {};
|
|
147
147
|
|
|
148
|
-
if (!
|
|
148
|
+
if (!isAppleTV() || !player) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (isAudioContent) {
|
|
153
|
+
return (
|
|
154
|
+
<AudioPlayer
|
|
155
|
+
audio_item={item}
|
|
156
|
+
plugin_configuration={pluginConfiguration}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!playNextData && player.isPaused() && player.isAd() === false) {
|
|
149
162
|
return null;
|
|
150
163
|
}
|
|
151
164
|
|
|
152
165
|
return (
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<ProgramInfo
|
|
160
|
-
title={title}
|
|
161
|
-
subtitle={summary}
|
|
162
|
-
plugin_configuration={pluginConfiguration}
|
|
163
|
-
videoStyle={videoStyle}
|
|
164
|
-
/>
|
|
165
|
-
)}
|
|
166
|
-
</>
|
|
167
|
-
)}
|
|
168
|
-
|
|
169
|
-
{isAudioContent && (
|
|
170
|
-
<AudioPlayer
|
|
171
|
-
audio_item={item}
|
|
172
|
-
plugin_configuration={pluginConfiguration}
|
|
173
|
-
/>
|
|
174
|
-
)}
|
|
175
|
-
</>
|
|
166
|
+
<ProgramInfo
|
|
167
|
+
title={title}
|
|
168
|
+
subtitle={summary}
|
|
169
|
+
plugin_configuration={pluginConfiguration}
|
|
170
|
+
videoStyle={videoStyle}
|
|
171
|
+
/>
|
|
176
172
|
);
|
|
177
173
|
};
|
|
178
174
|
|
|
@@ -339,6 +335,18 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
339
335
|
}
|
|
340
336
|
}, [item?.id, item?.extensions?.resumeTime, player]);
|
|
341
337
|
|
|
338
|
+
const onVideoFullscreenPlayerWillPresent = React.useCallback(() => {
|
|
339
|
+
playerManager.invokeHandler("toggleFullscreen", {
|
|
340
|
+
fullscreen: true,
|
|
341
|
+
});
|
|
342
|
+
}, []);
|
|
343
|
+
|
|
344
|
+
const onVideoFullscreenPlayerWillDismiss = React.useCallback(() => {
|
|
345
|
+
playerManager.invokeHandler("toggleFullscreen", {
|
|
346
|
+
fullscreen: false,
|
|
347
|
+
});
|
|
348
|
+
}, []);
|
|
349
|
+
|
|
342
350
|
// Util methods
|
|
343
351
|
const toggleFullscreen = (event) => {
|
|
344
352
|
const { fullscreen = false } = event || {};
|
|
@@ -381,17 +389,27 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
381
389
|
id: playerContainerId,
|
|
382
390
|
listener: {
|
|
383
391
|
onVideoEnd,
|
|
384
|
-
onError
|
|
385
|
-
onLoad
|
|
392
|
+
onError,
|
|
393
|
+
onLoad,
|
|
386
394
|
onPlayerClose: close,
|
|
387
395
|
onPlayerDetached: close,
|
|
396
|
+
onVideoFullscreenPlayerWillDismiss,
|
|
397
|
+
onVideoFullscreenPlayerWillPresent,
|
|
388
398
|
},
|
|
389
399
|
});
|
|
390
400
|
|
|
391
401
|
return () => {
|
|
392
402
|
player.removeListener(playerContainerId);
|
|
393
403
|
};
|
|
394
|
-
}, [
|
|
404
|
+
}, [
|
|
405
|
+
player,
|
|
406
|
+
onVideoEnd,
|
|
407
|
+
onError,
|
|
408
|
+
onLoad,
|
|
409
|
+
close,
|
|
410
|
+
onVideoFullscreenPlayerWillDismiss,
|
|
411
|
+
onVideoFullscreenPlayerWillPresent,
|
|
412
|
+
]);
|
|
395
413
|
|
|
396
414
|
useEffect(() => {
|
|
397
415
|
// TODO: We should not use playerManager here to connect buttons to player container
|
|
@@ -621,7 +639,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
621
639
|
}}
|
|
622
640
|
focused={isInlineTV ? true : undefined}
|
|
623
641
|
autoplay={true}
|
|
624
|
-
controls={
|
|
642
|
+
controls={false}
|
|
625
643
|
disableCastAction={disableCastAction}
|
|
626
644
|
docked={navigator.isVideoModalDocked()}
|
|
627
645
|
entry={item}
|
|
@@ -83,6 +83,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
83
83
|
useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
|
|
84
84
|
useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
|
|
85
85
|
useProfilerLogging: jest.fn(),
|
|
86
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
86
87
|
}));
|
|
87
88
|
|
|
88
89
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { act, create } from "react-test-renderer";
|
|
4
4
|
|
|
5
5
|
const Mocked_RouteManager = jest.fn((props) => (
|
|
6
6
|
<View testID="routeManager" {...props} />
|
|
@@ -69,12 +69,16 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
69
69
|
isNavBarVisible: mockIsNavBarVisible,
|
|
70
70
|
useRoute: jest.fn(() => ({
|
|
71
71
|
pathname: "/river/testId",
|
|
72
|
+
screenData: { id: "testId" },
|
|
72
73
|
})),
|
|
73
74
|
useNavigation: jest.fn(() => ({
|
|
74
75
|
canGoBack: () => false,
|
|
75
76
|
currentRoute: "/river/testId",
|
|
77
|
+
activeRiver: { id: "testId" },
|
|
78
|
+
screenData: { id: "testId" },
|
|
76
79
|
data: { screen: { id: "testId" } },
|
|
77
80
|
})),
|
|
81
|
+
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
78
82
|
}));
|
|
79
83
|
|
|
80
84
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
@@ -19,7 +19,11 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
19
19
|
<View>
|
|
20
20
|
<View
|
|
21
21
|
pathname="/river/testId"
|
|
22
|
-
screenData={
|
|
22
|
+
screenData={
|
|
23
|
+
Object {
|
|
24
|
+
"id": "testId",
|
|
25
|
+
}
|
|
26
|
+
}
|
|
23
27
|
testID="routeManager"
|
|
24
28
|
/>
|
|
25
29
|
</View>
|
|
@@ -45,7 +49,11 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
45
49
|
<View>
|
|
46
50
|
<View
|
|
47
51
|
pathname="/river/testId"
|
|
48
|
-
screenData={
|
|
52
|
+
screenData={
|
|
53
|
+
Object {
|
|
54
|
+
"id": "testId",
|
|
55
|
+
}
|
|
56
|
+
}
|
|
49
57
|
testID="routeManager"
|
|
50
58
|
/>
|
|
51
59
|
</View>
|
|
@@ -23,6 +23,17 @@ import { RouteManager } from "../RouteManager";
|
|
|
23
23
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
24
24
|
import { useScreenOrientationHandler } from "./orientationHandler";
|
|
25
25
|
|
|
26
|
+
const getScreenId = (
|
|
27
|
+
screenData: LegacyNavigationScreenData,
|
|
28
|
+
fallbackRiver: ZappRiver
|
|
29
|
+
) => {
|
|
30
|
+
return screenData?.targetScreen
|
|
31
|
+
? screenData?.targetScreen?.id ?? fallbackRiver.id
|
|
32
|
+
: "screen_id" in screenData
|
|
33
|
+
? screenData.screen_id
|
|
34
|
+
: fallbackRiver.id;
|
|
35
|
+
};
|
|
36
|
+
|
|
26
37
|
function colorIsNotTransparent(color) {
|
|
27
38
|
const layers = R.compose(
|
|
28
39
|
R.map(R.trim),
|
|
@@ -41,17 +52,11 @@ function isValidColor(string) {
|
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
type Props = {
|
|
44
|
-
pathname: string;
|
|
45
|
-
screenData: Record<string, any>;
|
|
46
55
|
setToggleMenu: () => void;
|
|
47
56
|
setCloseMenu: () => void;
|
|
48
57
|
};
|
|
49
58
|
|
|
50
|
-
export function Screen({
|
|
51
|
-
setToggleMenu,
|
|
52
|
-
setCloseMenu,
|
|
53
|
-
screenData: _screenData,
|
|
54
|
-
}: Props) {
|
|
59
|
+
export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
55
60
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
56
61
|
const navigation = useNavigation();
|
|
57
62
|
const { plugins } = usePickFromState(["plugins"]);
|
|
@@ -68,10 +73,7 @@ export function Screen({
|
|
|
68
73
|
const routeData = useRoute();
|
|
69
74
|
|
|
70
75
|
const currentRiver = useScreenData(
|
|
71
|
-
(routeData.screenData
|
|
72
|
-
? (routeData.screenData as ZappRiver)?.targetScreen?.id ??
|
|
73
|
-
navigation.activeRiver.id
|
|
74
|
-
: (routeData.screenData as ZappRiver)?.screen_id
|
|
76
|
+
getScreenId(routeData.screenData, navigation.activeRiver)
|
|
75
77
|
);
|
|
76
78
|
|
|
77
79
|
const { title } = useNavbarState();
|
|
@@ -135,9 +137,9 @@ export function Screen({
|
|
|
135
137
|
{...{ ...(navBarProps as MobileNavBarPluginProps), id: pathname }}
|
|
136
138
|
/>
|
|
137
139
|
|
|
138
|
-
<OfflineFallbackScreen screenData={
|
|
140
|
+
<OfflineFallbackScreen screenData={targetScreenData}>
|
|
139
141
|
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
140
|
-
<RouteManager pathname={pathname} screenData={
|
|
142
|
+
<RouteManager pathname={pathname} screenData={screenData} />
|
|
141
143
|
</OfflineFallbackScreen>
|
|
142
144
|
</View>
|
|
143
145
|
</ScreenContextProvider>
|
|
@@ -4,6 +4,7 @@ import { render } from "@testing-library/react-native";
|
|
|
4
4
|
import * as PlayerFactory from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerFactory";
|
|
5
5
|
import { Player } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/player";
|
|
6
6
|
import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
|
|
7
|
+
import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
7
8
|
|
|
8
9
|
import { PlayerLiveImage } from "../PlayerLiveImageComponent";
|
|
9
10
|
|
|
@@ -18,6 +19,8 @@ jest.mock(
|
|
|
18
19
|
})
|
|
19
20
|
);
|
|
20
21
|
|
|
22
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
|
|
23
|
+
|
|
21
24
|
const Wrapper = ({ children }: { children: React.ReactChildren }) => (
|
|
22
25
|
<ThemeContext.Provider
|
|
23
26
|
value={{ themes: { myTheme: {} }, selectedThemeId: "myTheme" }}
|
|
@@ -46,6 +49,8 @@ describe("PlayerLiveImageComponent", () => {
|
|
|
46
49
|
controller: new Player({}),
|
|
47
50
|
Component: () => null,
|
|
48
51
|
}));
|
|
52
|
+
|
|
53
|
+
jest.spyOn(navigationHooks, "useIsScreenActive").mockReturnValue(true);
|
|
49
54
|
});
|
|
50
55
|
|
|
51
56
|
it("should render correctly with default props", () => {
|
|
@@ -1,249 +1,297 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`PlayerWrapper renders inline 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
Object {
|
|
7
|
-
"bottom": "off",
|
|
8
|
-
"left": "off",
|
|
9
|
-
"right": "off",
|
|
10
|
-
"top": "additive",
|
|
11
|
-
}
|
|
12
|
-
}
|
|
4
|
+
<RNCSafeAreaProvider
|
|
5
|
+
onInsetsChange={[Function]}
|
|
13
6
|
style={
|
|
14
7
|
Array [
|
|
15
8
|
Object {
|
|
16
|
-
"
|
|
17
|
-
},
|
|
18
|
-
Object {
|
|
19
|
-
"backgroundColor": "transparent",
|
|
20
|
-
},
|
|
21
|
-
Object {
|
|
22
|
-
"height": 800,
|
|
23
|
-
"width": 300,
|
|
9
|
+
"flex": 1,
|
|
24
10
|
},
|
|
25
|
-
|
|
11
|
+
undefined,
|
|
26
12
|
]
|
|
27
13
|
}
|
|
28
14
|
>
|
|
29
|
-
<
|
|
15
|
+
<RNCSafeAreaView
|
|
16
|
+
edges={
|
|
17
|
+
Object {
|
|
18
|
+
"bottom": "off",
|
|
19
|
+
"left": "off",
|
|
20
|
+
"right": "off",
|
|
21
|
+
"top": "additive",
|
|
22
|
+
}
|
|
23
|
+
}
|
|
30
24
|
style={
|
|
31
25
|
Array [
|
|
32
26
|
Object {
|
|
33
|
-
"
|
|
34
|
-
"position": "relative",
|
|
35
|
-
"zIndex": 200,
|
|
27
|
+
"flexDirection": "column",
|
|
36
28
|
},
|
|
37
29
|
Object {
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
"backgroundColor": "transparent",
|
|
31
|
+
},
|
|
32
|
+
Object {
|
|
33
|
+
"height": 800,
|
|
34
|
+
"width": 300,
|
|
41
35
|
},
|
|
42
|
-
Object {},
|
|
43
36
|
Object {},
|
|
44
37
|
]
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
>
|
|
40
|
+
<View
|
|
41
|
+
style={
|
|
42
|
+
Array [
|
|
43
|
+
Object {
|
|
44
|
+
"alignSelf": "center",
|
|
45
|
+
"position": "relative",
|
|
46
|
+
"zIndex": 200,
|
|
47
|
+
},
|
|
48
|
+
Object {
|
|
49
|
+
"aspectRatio": 1.7777777777777777,
|
|
50
|
+
"height": undefined,
|
|
51
|
+
"width": "100%",
|
|
52
|
+
},
|
|
53
|
+
Object {},
|
|
54
|
+
Object {},
|
|
55
|
+
]
|
|
53
56
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
testID="test-player-container"
|
|
58
|
+
/>
|
|
59
|
+
<View
|
|
60
|
+
configuration={
|
|
61
|
+
Object {
|
|
62
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
63
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"flex": 1,
|
|
64
|
-
"paddingTop": 20,
|
|
66
|
+
entry={
|
|
67
|
+
Object {
|
|
68
|
+
"id": "test",
|
|
69
|
+
}
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
isTabletLandscape={false}
|
|
72
|
+
style={
|
|
73
|
+
Object {
|
|
74
|
+
"flex": 1,
|
|
75
|
+
"paddingTop": 20,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
</RNCSafeAreaView>
|
|
80
|
+
</RNCSafeAreaProvider>
|
|
69
81
|
`;
|
|
70
82
|
|
|
71
83
|
exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
Object {
|
|
75
|
-
"bottom": "additive",
|
|
76
|
-
"left": "off",
|
|
77
|
-
"right": "off",
|
|
78
|
-
"top": "off",
|
|
79
|
-
}
|
|
80
|
-
}
|
|
84
|
+
<RNCSafeAreaProvider
|
|
85
|
+
onInsetsChange={[Function]}
|
|
81
86
|
style={
|
|
82
87
|
Array [
|
|
83
88
|
Object {
|
|
84
|
-
"
|
|
85
|
-
},
|
|
86
|
-
Object {
|
|
87
|
-
"backgroundColor": "transparent",
|
|
88
|
-
},
|
|
89
|
-
Object {
|
|
90
|
-
"height": 50,
|
|
91
|
-
"width": 300,
|
|
89
|
+
"flex": 1,
|
|
92
90
|
},
|
|
93
|
-
|
|
91
|
+
undefined,
|
|
94
92
|
]
|
|
95
93
|
}
|
|
96
94
|
>
|
|
97
|
-
<
|
|
95
|
+
<RNCSafeAreaView
|
|
96
|
+
edges={
|
|
97
|
+
Object {
|
|
98
|
+
"bottom": "additive",
|
|
99
|
+
"left": "off",
|
|
100
|
+
"right": "off",
|
|
101
|
+
"top": "off",
|
|
102
|
+
}
|
|
103
|
+
}
|
|
98
104
|
style={
|
|
99
105
|
Array [
|
|
100
106
|
Object {
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
"flexDirection": "column",
|
|
108
|
+
},
|
|
109
|
+
Object {
|
|
110
|
+
"backgroundColor": "transparent",
|
|
104
111
|
},
|
|
105
112
|
Object {
|
|
106
|
-
"aspectRatio": undefined,
|
|
107
113
|
"height": 50,
|
|
108
|
-
"width":
|
|
114
|
+
"width": 300,
|
|
109
115
|
},
|
|
110
116
|
Object {},
|
|
111
|
-
Object {},
|
|
112
117
|
]
|
|
113
118
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
>
|
|
120
|
+
<View
|
|
121
|
+
style={
|
|
122
|
+
Array [
|
|
123
|
+
Object {
|
|
124
|
+
"alignSelf": "center",
|
|
125
|
+
"position": "relative",
|
|
126
|
+
"zIndex": 200,
|
|
127
|
+
},
|
|
128
|
+
Object {
|
|
129
|
+
"aspectRatio": undefined,
|
|
130
|
+
"height": 50,
|
|
131
|
+
"width": "100%",
|
|
132
|
+
},
|
|
133
|
+
Object {},
|
|
134
|
+
Object {},
|
|
135
|
+
]
|
|
121
136
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
testID="test-player-container"
|
|
138
|
+
/>
|
|
139
|
+
<View
|
|
140
|
+
style={
|
|
141
|
+
Object {
|
|
142
|
+
"flex": 1,
|
|
143
|
+
"paddingTop": 20,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/>
|
|
147
|
+
</RNCSafeAreaView>
|
|
148
|
+
</RNCSafeAreaProvider>
|
|
125
149
|
`;
|
|
126
150
|
|
|
127
151
|
exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
Object {
|
|
131
|
-
"bottom": "off",
|
|
132
|
-
"left": "off",
|
|
133
|
-
"right": "off",
|
|
134
|
-
"top": "additive",
|
|
135
|
-
}
|
|
136
|
-
}
|
|
152
|
+
<RNCSafeAreaProvider
|
|
153
|
+
onInsetsChange={[Function]}
|
|
137
154
|
style={
|
|
138
155
|
Array [
|
|
139
156
|
Object {
|
|
140
|
-
"
|
|
141
|
-
},
|
|
142
|
-
Object {
|
|
143
|
-
"backgroundColor": "red",
|
|
144
|
-
},
|
|
145
|
-
Object {
|
|
146
|
-
"height": 800,
|
|
147
|
-
"width": 300,
|
|
157
|
+
"flex": 1,
|
|
148
158
|
},
|
|
149
|
-
|
|
159
|
+
undefined,
|
|
150
160
|
]
|
|
151
161
|
}
|
|
152
162
|
>
|
|
153
|
-
<
|
|
163
|
+
<RNCSafeAreaView
|
|
164
|
+
edges={
|
|
165
|
+
Object {
|
|
166
|
+
"bottom": "off",
|
|
167
|
+
"left": "off",
|
|
168
|
+
"right": "off",
|
|
169
|
+
"top": "additive",
|
|
170
|
+
}
|
|
171
|
+
}
|
|
154
172
|
style={
|
|
155
173
|
Array [
|
|
156
174
|
Object {
|
|
157
|
-
"
|
|
158
|
-
"position": "relative",
|
|
159
|
-
"zIndex": 200,
|
|
175
|
+
"flexDirection": "row",
|
|
160
176
|
},
|
|
161
177
|
Object {
|
|
162
|
-
"
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
"backgroundColor": "red",
|
|
179
|
+
},
|
|
180
|
+
Object {
|
|
181
|
+
"height": 800,
|
|
182
|
+
"width": 300,
|
|
165
183
|
},
|
|
166
|
-
Object {},
|
|
167
184
|
Object {},
|
|
168
185
|
]
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
187
|
+
>
|
|
188
|
+
<View
|
|
189
|
+
style={
|
|
190
|
+
Array [
|
|
191
|
+
Object {
|
|
192
|
+
"alignSelf": "center",
|
|
193
|
+
"position": "relative",
|
|
194
|
+
"zIndex": 200,
|
|
195
|
+
},
|
|
196
|
+
Object {
|
|
197
|
+
"aspectRatio": 1.7777777777777777,
|
|
198
|
+
"height": undefined,
|
|
199
|
+
"width": 195,
|
|
200
|
+
},
|
|
201
|
+
Object {},
|
|
202
|
+
Object {},
|
|
203
|
+
]
|
|
177
204
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
205
|
+
testID="test-player-container"
|
|
206
|
+
/>
|
|
207
|
+
<View
|
|
208
|
+
configuration={
|
|
209
|
+
Object {
|
|
210
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
211
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
212
|
+
}
|
|
182
213
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
"flex": 1,
|
|
188
|
-
"paddingTop": 20,
|
|
214
|
+
entry={
|
|
215
|
+
Object {
|
|
216
|
+
"id": "test",
|
|
217
|
+
}
|
|
189
218
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
isTabletLandscape={true}
|
|
220
|
+
style={
|
|
221
|
+
Object {
|
|
222
|
+
"flex": 1,
|
|
223
|
+
"paddingTop": 20,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/>
|
|
227
|
+
</RNCSafeAreaView>
|
|
228
|
+
</RNCSafeAreaProvider>
|
|
193
229
|
`;
|
|
194
230
|
|
|
195
231
|
exports[`PlayerWrapper renders properly 1`] = `
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
Object {
|
|
199
|
-
"bottom": "off",
|
|
200
|
-
"left": "off",
|
|
201
|
-
"right": "off",
|
|
202
|
-
"top": "additive",
|
|
203
|
-
}
|
|
204
|
-
}
|
|
232
|
+
<RNCSafeAreaProvider
|
|
233
|
+
onInsetsChange={[Function]}
|
|
205
234
|
style={
|
|
206
235
|
Array [
|
|
207
236
|
Object {
|
|
208
|
-
"
|
|
209
|
-
},
|
|
210
|
-
Object {
|
|
211
|
-
"backgroundColor": "transparent",
|
|
212
|
-
},
|
|
213
|
-
Object {
|
|
214
|
-
"height": 800,
|
|
215
|
-
"width": 300,
|
|
237
|
+
"flex": 1,
|
|
216
238
|
},
|
|
217
|
-
|
|
239
|
+
undefined,
|
|
218
240
|
]
|
|
219
241
|
}
|
|
220
242
|
>
|
|
221
|
-
<
|
|
243
|
+
<RNCSafeAreaView
|
|
244
|
+
edges={
|
|
245
|
+
Object {
|
|
246
|
+
"bottom": "off",
|
|
247
|
+
"left": "off",
|
|
248
|
+
"right": "off",
|
|
249
|
+
"top": "additive",
|
|
250
|
+
}
|
|
251
|
+
}
|
|
222
252
|
style={
|
|
223
253
|
Array [
|
|
224
254
|
Object {
|
|
225
|
-
"
|
|
226
|
-
"position": "relative",
|
|
227
|
-
"zIndex": 200,
|
|
255
|
+
"flexDirection": "column",
|
|
228
256
|
},
|
|
229
257
|
Object {
|
|
230
|
-
"
|
|
231
|
-
|
|
232
|
-
|
|
258
|
+
"backgroundColor": "transparent",
|
|
259
|
+
},
|
|
260
|
+
Object {
|
|
261
|
+
"height": 800,
|
|
262
|
+
"width": 300,
|
|
233
263
|
},
|
|
234
|
-
Object {},
|
|
235
264
|
Object {},
|
|
236
265
|
]
|
|
237
266
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
267
|
+
>
|
|
268
|
+
<View
|
|
269
|
+
style={
|
|
270
|
+
Array [
|
|
271
|
+
Object {
|
|
272
|
+
"alignSelf": "center",
|
|
273
|
+
"position": "relative",
|
|
274
|
+
"zIndex": 200,
|
|
275
|
+
},
|
|
276
|
+
Object {
|
|
277
|
+
"aspectRatio": 1.7786666666666666,
|
|
278
|
+
"height": undefined,
|
|
279
|
+
"width": "100%",
|
|
280
|
+
},
|
|
281
|
+
Object {},
|
|
282
|
+
Object {},
|
|
283
|
+
]
|
|
245
284
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
285
|
+
testID="test-player-container"
|
|
286
|
+
/>
|
|
287
|
+
<View
|
|
288
|
+
style={
|
|
289
|
+
Object {
|
|
290
|
+
"flex": 1,
|
|
291
|
+
"paddingTop": 20,
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/>
|
|
295
|
+
</RNCSafeAreaView>
|
|
296
|
+
</RNCSafeAreaProvider>
|
|
249
297
|
`;
|
|
@@ -12,11 +12,16 @@ export function withComponentsMapProvider(Component: React.ComponentType<any>) {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const setComponentHeightById = (id: string | number, height: number) => {
|
|
15
|
-
componentsHeightMapRef.current = {
|
|
15
|
+
componentsHeightMapRef.current = {
|
|
16
|
+
...componentsHeightMapRef.current,
|
|
17
|
+
[id]: height,
|
|
18
|
+
};
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
return (
|
|
19
|
-
<ComponentsMapProvider
|
|
22
|
+
<ComponentsMapProvider
|
|
23
|
+
{...{ setComponentHeightById, getComponentHeightById }}
|
|
24
|
+
>
|
|
20
25
|
<Component {...props} />
|
|
21
26
|
</ComponentsMapProvider>
|
|
22
27
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.5722041245",
|
|
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",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.5722041245",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5722041245",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.5722041245",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.5722041245",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|