@applicaster/zapp-react-native-ui-components 13.0.0-alpha.5371423120 → 13.0.0-alpha.6714678893
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 +10 -13
- package/Components/Cell/CellWithFocusable.tsx +1 -1
- package/Components/Cell/TvOSCellComponent.tsx +7 -8
- package/Components/Focusable/FocusableTvOS.tsx +4 -0
- package/Components/FocusableScrollView/index.tsx +39 -12
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +67 -7
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +53 -9
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/Screen/index.tsx +1 -1
- package/Components/VideoModal/PlayerWrapper.tsx +59 -71
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +6 -36
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +1 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +18 -11
- package/Decorators/Analytics/{index.js → index.tsx} +11 -11
- package/package.json +5 -5
package/Components/Cell/Cell.tsx
CHANGED
|
@@ -14,10 +14,7 @@ import { BaseFocusable } from "../BaseFocusable";
|
|
|
14
14
|
import { AccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager";
|
|
15
15
|
|
|
16
16
|
type Props = {
|
|
17
|
-
item:
|
|
18
|
-
id: string;
|
|
19
|
-
title: string;
|
|
20
|
-
};
|
|
17
|
+
item: ZappEntry;
|
|
21
18
|
index: number;
|
|
22
19
|
shouldScrollHorizontally: (arg1: [any]) => boolean | null | undefined;
|
|
23
20
|
shouldScrollVertically: (...args: any) => boolean | null | undefined;
|
|
@@ -33,10 +30,9 @@ type Props = {
|
|
|
33
30
|
id: string;
|
|
34
31
|
};
|
|
35
32
|
selected?: boolean;
|
|
36
|
-
CellRenderer: React.
|
|
37
|
-
item:
|
|
38
|
-
|
|
39
|
-
}> & { hasFocusableInside: (item: Record<string, string>) => boolean };
|
|
33
|
+
CellRenderer: React.FunctionComponent<any> & {
|
|
34
|
+
hasFocusableInside: (item: ZappEntry) => boolean;
|
|
35
|
+
};
|
|
40
36
|
preferredFocus: boolean;
|
|
41
37
|
navigator: {
|
|
42
38
|
push: (arg1: Record<any, any>) => void;
|
|
@@ -148,10 +144,6 @@ export class CellComponent extends React.Component<Props, State> {
|
|
|
148
144
|
shouldScrollVertically?.(mouse, focusable, id, title)
|
|
149
145
|
) {
|
|
150
146
|
this.scrollVertically(focusable);
|
|
151
|
-
|
|
152
|
-
const accessibilityManager = AccessibilityManager.getInstance();
|
|
153
|
-
// Text from DSP should be localized already
|
|
154
|
-
accessibilityManager.readText({ text: title });
|
|
155
147
|
}
|
|
156
148
|
}
|
|
157
149
|
}
|
|
@@ -280,7 +272,12 @@ export class CellComponent extends React.Component<Props, State> {
|
|
|
280
272
|
|
|
281
273
|
if (isFocused) {
|
|
282
274
|
const accessibilityManager = AccessibilityManager.getInstance();
|
|
283
|
-
|
|
275
|
+
|
|
276
|
+
accessibilityManager.readText({
|
|
277
|
+
text: String(
|
|
278
|
+
item.extensions?.accessibility?.label || item.title
|
|
279
|
+
),
|
|
280
|
+
});
|
|
284
281
|
}
|
|
285
282
|
|
|
286
283
|
return (
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { View, StyleSheet } from "react-native";
|
|
4
4
|
|
|
5
|
-
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
|
|
5
|
+
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
6
6
|
import { FocusableCell } from "@applicaster/zapp-react-native-ui-components/Components/FocusableCell";
|
|
7
7
|
import { getItemType } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
8
8
|
import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/itemTypes";
|
|
@@ -36,10 +36,9 @@ type Props = {
|
|
|
36
36
|
component_type: string;
|
|
37
37
|
};
|
|
38
38
|
selected: boolean;
|
|
39
|
-
CellRenderer: React.
|
|
40
|
-
item: any;
|
|
41
|
-
|
|
42
|
-
}> & { hasFocusableInside: (item: any) => boolean };
|
|
39
|
+
CellRenderer: React.FunctionComponent<any> & {
|
|
40
|
+
hasFocusableInside: (item: any) => boolean;
|
|
41
|
+
};
|
|
43
42
|
preferredFocus: boolean;
|
|
44
43
|
navigator: {
|
|
45
44
|
push: (arg1: Record<any, any>) => void;
|
|
@@ -252,7 +251,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
252
251
|
|
|
253
252
|
const focusableId = R.join("-", [component?.id, id, index]);
|
|
254
253
|
|
|
255
|
-
const handleFocus = (arg1: any, index
|
|
254
|
+
const handleFocus = (arg1: any, index?: number) => {
|
|
256
255
|
const focusFn = onFocus || noop;
|
|
257
256
|
focusFn(arg1, index);
|
|
258
257
|
|
|
@@ -285,7 +284,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
285
284
|
<View onLayout={this.onLayout} style={styles.container}>
|
|
286
285
|
<Focusable
|
|
287
286
|
id={focusableId}
|
|
288
|
-
groupId={groupId || component?.id}
|
|
287
|
+
groupId={(groupId || component?.id).toString()}
|
|
289
288
|
onFocus={handleFocus}
|
|
290
289
|
onBlur={onBlur || this.onBlur}
|
|
291
290
|
isParallaxDisabled={this.layout?.width > 1740}
|
|
@@ -304,7 +303,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
304
303
|
index,
|
|
305
304
|
CellRenderer,
|
|
306
305
|
item,
|
|
307
|
-
focused: this.props.focused || selectedCell || focused,
|
|
306
|
+
focused: !!(this.props.focused || selectedCell || focused),
|
|
308
307
|
scrollTo: this.scrollTo,
|
|
309
308
|
behavior,
|
|
310
309
|
}}
|
|
@@ -16,6 +16,8 @@ function noop() {}
|
|
|
16
16
|
type Props = {
|
|
17
17
|
id: string;
|
|
18
18
|
groupId: string;
|
|
19
|
+
willReceiveFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
20
|
+
hasReceivedFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
19
21
|
onPress?: (nativeEvent: React.SyntheticEvent) => void;
|
|
20
22
|
onFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
21
23
|
onBlur?: (nativeEvent: React.SyntheticEvent) => void;
|
|
@@ -35,6 +37,8 @@ type Props = {
|
|
|
35
37
|
forceFocus?: boolean;
|
|
36
38
|
initialFocus?: boolean;
|
|
37
39
|
onLayout?: (e: any) => void;
|
|
40
|
+
offsetUpdater: (arg1: string, arg2: number) => number;
|
|
41
|
+
style: any;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export class Focusable extends BaseFocusable<Props> {
|
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
useInitialFocus,
|
|
12
12
|
} from "@applicaster/zapp-react-native-utils/focusManager";
|
|
13
13
|
|
|
14
|
+
export type FocusableScrollViewRenderItem = (info: {
|
|
15
|
+
item: ZappUIComponent;
|
|
16
|
+
index: number;
|
|
17
|
+
focused: boolean;
|
|
18
|
+
parentFocus: ParentFocus;
|
|
19
|
+
}) => React.ReactElement;
|
|
20
|
+
|
|
14
21
|
export type Props = ScrollViewProps & {
|
|
15
22
|
id?: number | string;
|
|
16
23
|
horizontal?: boolean;
|
|
@@ -32,17 +39,27 @@ export type Props = ScrollViewProps & {
|
|
|
32
39
|
initialFocusDirection?: FocusManager.Android.FocusNavigationDirections;
|
|
33
40
|
onAllComponentsLoaded?: () => void;
|
|
34
41
|
omitPropsPropagation?: Array<keyof FlatListProps<any>>;
|
|
35
|
-
renderItem:
|
|
36
|
-
item: ZappUIComponent;
|
|
37
|
-
index: number;
|
|
38
|
-
focused: boolean;
|
|
39
|
-
parentFocus: ParentFocus;
|
|
40
|
-
}) => React.ReactElement;
|
|
42
|
+
renderItem: FocusableScrollViewRenderItem;
|
|
41
43
|
} & ParentFocus;
|
|
42
44
|
|
|
43
45
|
type State = boolean[];
|
|
44
46
|
type Action = { index?: number; isFocusable: boolean; type?: string };
|
|
45
47
|
|
|
48
|
+
const unwrapArray = (maybeArray) =>
|
|
49
|
+
Array.isArray(maybeArray) ? maybeArray[0] : maybeArray;
|
|
50
|
+
|
|
51
|
+
function getEntry<T>(data: T | T[], index: unknown): T {
|
|
52
|
+
let entry;
|
|
53
|
+
|
|
54
|
+
if (R.isNil(index)) {
|
|
55
|
+
entry = unwrapArray(data);
|
|
56
|
+
} else if (typeof index === "number") {
|
|
57
|
+
entry = unwrapArray(data[index]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return entry;
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
const focusableStateReducer = (
|
|
47
64
|
state: State,
|
|
48
65
|
{ index = null, isFocusable, type = null }: Action
|
|
@@ -73,7 +90,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
|
|
|
73
90
|
};
|
|
74
91
|
|
|
75
92
|
_ref.scrollToIndex = (params) => {
|
|
76
|
-
const { index, viewOffset } = params;
|
|
93
|
+
const { index, viewOffset = 0 } = params;
|
|
77
94
|
|
|
78
95
|
const itemByIndex = R.find(R.propEq("index", index))(
|
|
79
96
|
R.values(childCompsMeasurementsMap)
|
|
@@ -129,8 +146,11 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
129
146
|
);
|
|
130
147
|
|
|
131
148
|
const getFocusableEntryId = React.useCallback(
|
|
132
|
-
(_entry: ZappEntry, index?: number) => {
|
|
133
|
-
const entry
|
|
149
|
+
(_entry: ZappEntry | null, index?: number) => {
|
|
150
|
+
const entry: { id?: string } = getEntry(
|
|
151
|
+
R.isNil(index) ? _entry : data,
|
|
152
|
+
index
|
|
153
|
+
);
|
|
134
154
|
|
|
135
155
|
return entry ? `${props.id}--${entry?.id}` : undefined;
|
|
136
156
|
},
|
|
@@ -273,11 +293,18 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
273
293
|
const renderItem = React.useCallback(
|
|
274
294
|
(item, index) => {
|
|
275
295
|
const renderArgs = { item, index };
|
|
276
|
-
|
|
277
|
-
const
|
|
296
|
+
|
|
297
|
+
const id = getFocusableEntryId(
|
|
298
|
+
Array.isArray(item) ? item[0] : item,
|
|
299
|
+
index
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const nextFocus = getNextFocus(index);
|
|
278
303
|
|
|
279
304
|
const onItemLayout = (event) => {
|
|
280
|
-
childCompsMeasurementsMap.current[
|
|
305
|
+
childCompsMeasurementsMap.current[
|
|
306
|
+
Array.isArray(item) ? index : item.id
|
|
307
|
+
] = {
|
|
281
308
|
index,
|
|
282
309
|
layout: event.nativeEvent.layout,
|
|
283
310
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import { renderHook } from "@testing-library/react-hooks";
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -9,6 +10,42 @@ import {
|
|
|
9
10
|
import * as redux from "react-redux";
|
|
10
11
|
import * as layoutPresets from "@applicaster/zapp-react-native-redux/hooks/useLayoutPresets";
|
|
11
12
|
import * as pipesFeeds from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
|
|
13
|
+
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
14
|
+
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
15
|
+
|
|
16
|
+
import { Provider } from "react-redux";
|
|
17
|
+
import configureStore from "redux-mock-store";
|
|
18
|
+
|
|
19
|
+
const homeStack = {
|
|
20
|
+
route: "/home",
|
|
21
|
+
state: {
|
|
22
|
+
screen: { id: "123" },
|
|
23
|
+
entry: { id: "abc" },
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const mainStackNavigator = {
|
|
28
|
+
getStackForPathname: jest.fn().mockReturnValue(homeStack),
|
|
29
|
+
modalState: {
|
|
30
|
+
screen: {
|
|
31
|
+
id: "modal-1",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const store = configureStore()({});
|
|
37
|
+
|
|
38
|
+
const wrapper = ({ children }) => (
|
|
39
|
+
<Provider store={store}>
|
|
40
|
+
<NavigationContext.Provider
|
|
41
|
+
value={{ ...mainStackNavigator, currentRoute: homeStack.route }}
|
|
42
|
+
>
|
|
43
|
+
<PathnameContext.Provider value={homeStack.route}>
|
|
44
|
+
{children}
|
|
45
|
+
</PathnameContext.Provider>
|
|
46
|
+
</NavigationContext.Provider>
|
|
47
|
+
</Provider>
|
|
48
|
+
);
|
|
12
49
|
|
|
13
50
|
describe("getTransformedPreset should return the passed components if smartComponents is empty", () => {
|
|
14
51
|
describe("getTransformedPreset function", () => {
|
|
@@ -94,9 +131,13 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
94
131
|
},
|
|
95
132
|
};
|
|
96
133
|
|
|
134
|
+
const mockUrlsMap = {
|
|
135
|
+
[mockSmartComp.id]: mockSmartComp.data.source,
|
|
136
|
+
};
|
|
137
|
+
|
|
97
138
|
it("should return the component itself if its component_type is not SMART_COMPONENT_TYPE", () => {
|
|
98
139
|
expect(
|
|
99
|
-
enrichComponent(mockComp, 0, mockFeeds, mockLayoutPresets)
|
|
140
|
+
enrichComponent(mockComp, 0, mockFeeds, mockLayoutPresets, mockUrlsMap)
|
|
100
141
|
).toEqual([mockComp]);
|
|
101
142
|
});
|
|
102
143
|
|
|
@@ -106,8 +147,18 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
106
147
|
data: { source: "missing_source" },
|
|
107
148
|
};
|
|
108
149
|
|
|
150
|
+
const missing_source_urls_map = {
|
|
151
|
+
[missing_source_comp.id]: missing_source_comp.data.source,
|
|
152
|
+
};
|
|
153
|
+
|
|
109
154
|
expect(
|
|
110
|
-
enrichComponent(
|
|
155
|
+
enrichComponent(
|
|
156
|
+
missing_source_comp,
|
|
157
|
+
0,
|
|
158
|
+
mockFeeds,
|
|
159
|
+
mockLayoutPresets,
|
|
160
|
+
missing_source_urls_map
|
|
161
|
+
)
|
|
111
162
|
).toEqual(null);
|
|
112
163
|
});
|
|
113
164
|
|
|
@@ -116,7 +167,8 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
116
167
|
mockSmartComp,
|
|
117
168
|
0,
|
|
118
169
|
mockFeeds,
|
|
119
|
-
mockLayoutPresets
|
|
170
|
+
mockLayoutPresets,
|
|
171
|
+
mockUrlsMap
|
|
120
172
|
);
|
|
121
173
|
|
|
122
174
|
expect(Array.isArray(result)).toBe(true);
|
|
@@ -262,7 +314,9 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
262
314
|
|
|
263
315
|
mockUseLayoutPresets.mockReturnValue({});
|
|
264
316
|
|
|
265
|
-
const { result } = renderHook(() => useCurationAPI(mockComponents)
|
|
317
|
+
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
318
|
+
wrapper,
|
|
319
|
+
});
|
|
266
320
|
|
|
267
321
|
// if there are no smart components, it should return the original array
|
|
268
322
|
expect(result.current).toEqual(mockComponents);
|
|
@@ -313,7 +367,9 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
313
367
|
|
|
314
368
|
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
315
369
|
|
|
316
|
-
const { result } = renderHook(() => useCurationAPI(mockComponents)
|
|
370
|
+
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
371
|
+
wrapper,
|
|
372
|
+
});
|
|
317
373
|
|
|
318
374
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
319
375
|
});
|
|
@@ -383,7 +439,9 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
383
439
|
|
|
384
440
|
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
385
441
|
|
|
386
|
-
const { result } = renderHook(() => useCurationAPI(mockComponents)
|
|
442
|
+
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
443
|
+
wrapper,
|
|
444
|
+
});
|
|
387
445
|
|
|
388
446
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
389
447
|
});
|
|
@@ -434,7 +492,9 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
434
492
|
const mockUseLayoutPresets = jest.spyOn(layoutPresets, "useLayoutPresets");
|
|
435
493
|
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
436
494
|
|
|
437
|
-
const { result } = renderHook(() => useCurationAPI(mockComponents)
|
|
495
|
+
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
496
|
+
wrapper,
|
|
497
|
+
});
|
|
438
498
|
|
|
439
499
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
440
500
|
});
|
|
@@ -9,6 +9,18 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
|
9
9
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
10
10
|
import { Categories } from "./logger";
|
|
11
11
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
12
|
+
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
13
|
+
import {
|
|
14
|
+
ZappPipesEntryContext,
|
|
15
|
+
ZappPipesScreenContext,
|
|
16
|
+
ZappPipesSearchContext,
|
|
17
|
+
} from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
getInflatedDataSourceUrl,
|
|
21
|
+
getSearchContext,
|
|
22
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
|
|
23
|
+
|
|
12
24
|
import { produce } from "immer";
|
|
13
25
|
// types reference
|
|
14
26
|
|
|
@@ -20,6 +32,7 @@ type LayoutPresets = PresetsMapping["presets_mappings"];
|
|
|
20
32
|
|
|
21
33
|
const SMART_COMPONENT_TYPE = "quick-brick-smart-component";
|
|
22
34
|
const SOURCE_PATH = ["data", "source"];
|
|
35
|
+
const MAPPING_PATH = ["data", "mapping"];
|
|
23
36
|
|
|
24
37
|
const isSmartComponent = (component) =>
|
|
25
38
|
component.component_type === SMART_COMPONENT_TYPE;
|
|
@@ -58,13 +71,14 @@ export const enrichComponent = (
|
|
|
58
71
|
comp: ZappUIComponent,
|
|
59
72
|
index: number,
|
|
60
73
|
feeds: Feeds,
|
|
61
|
-
layoutPresets: LayoutPresets
|
|
74
|
+
layoutPresets: LayoutPresets,
|
|
75
|
+
urlsMap: { [key: string]: string }
|
|
62
76
|
): ZappUIComponent[] | null => {
|
|
63
77
|
if (!isSmartComponent(comp)) {
|
|
64
78
|
return [comp];
|
|
65
79
|
}
|
|
66
80
|
|
|
67
|
-
const presets = prop<string[]>(
|
|
81
|
+
const presets = prop<string[]>(urlsMap[comp.id], feeds);
|
|
68
82
|
|
|
69
83
|
if (presets && presets.data && presets.data.entry) {
|
|
70
84
|
return presets.data.entry
|
|
@@ -113,11 +127,35 @@ export const useCurationAPI = (
|
|
|
113
127
|
[components]
|
|
114
128
|
);
|
|
115
129
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
const { pathname } = useRoute();
|
|
131
|
+
const [entryContext] = ZappPipesEntryContext.useZappPipesContext(pathname);
|
|
132
|
+
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
133
|
+
const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
|
|
134
|
+
|
|
135
|
+
const urlsMap = useMemo<{ [key: string]: string }>(() => {
|
|
136
|
+
const map = {};
|
|
137
|
+
|
|
138
|
+
smartComponents?.forEach?.((component) => {
|
|
139
|
+
const url = path(SOURCE_PATH, component);
|
|
140
|
+
const mapping = path(MAPPING_PATH, component);
|
|
141
|
+
|
|
142
|
+
map[component.id] = mapping
|
|
143
|
+
? getInflatedDataSourceUrl({
|
|
144
|
+
source: url,
|
|
145
|
+
contexts: {
|
|
146
|
+
entry: entryContext,
|
|
147
|
+
screen: screenContext,
|
|
148
|
+
search: getSearchContext(searchContext, mapping),
|
|
149
|
+
},
|
|
150
|
+
mapping,
|
|
151
|
+
})
|
|
152
|
+
: url;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return map;
|
|
156
|
+
}, [smartComponents, entryContext, screenContext, searchContext]);
|
|
157
|
+
|
|
158
|
+
const urls = useMemo<string[]>(() => Object.values(urlsMap), [urlsMap]);
|
|
121
159
|
|
|
122
160
|
useEffect(() => {
|
|
123
161
|
urls.forEach((url, index) => {
|
|
@@ -138,11 +176,17 @@ export const useCurationAPI = (
|
|
|
138
176
|
if (!components) return [];
|
|
139
177
|
|
|
140
178
|
return components.reduce((acc, comp, index) => {
|
|
141
|
-
const enrichedComp = enrichComponent(
|
|
179
|
+
const enrichedComp = enrichComponent(
|
|
180
|
+
comp,
|
|
181
|
+
index,
|
|
182
|
+
feeds,
|
|
183
|
+
layoutPresets,
|
|
184
|
+
urlsMap
|
|
185
|
+
);
|
|
142
186
|
|
|
143
187
|
return enrichedComp ? [...acc, ...enrichedComp] : acc;
|
|
144
188
|
}, [] as Array<ZappUIComponent>);
|
|
145
|
-
}, [components, feeds, layoutPresets]);
|
|
189
|
+
}, [components, feeds, layoutPresets, urlsMap]);
|
|
146
190
|
|
|
147
191
|
return getFinalComponents(
|
|
148
192
|
enrichedComponents,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { requireNativeComponent, View } from "react-native";
|
|
2
2
|
import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
|
|
3
3
|
|
|
4
|
+
// @TODO define the types
|
|
4
5
|
export const FocusableGroupNative = isAppleTV()
|
|
5
|
-
? requireNativeComponent("FocusableGroupViewModule"
|
|
6
|
+
? requireNativeComponent<any>("FocusableGroupViewModule")
|
|
6
7
|
: View;
|
|
7
8
|
|
|
9
|
+
// @TODO define the types
|
|
8
10
|
export const FocusableItemNative = isAppleTV()
|
|
9
|
-
? requireNativeComponent("FocusableViewModule"
|
|
11
|
+
? requireNativeComponent<any>("FocusableViewModule")
|
|
10
12
|
: View;
|
|
@@ -128,7 +128,7 @@ export function Screen(_props: Props) {
|
|
|
128
128
|
<View style={style}>
|
|
129
129
|
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
130
130
|
|
|
131
|
-
<OfflineFallbackScreen
|
|
131
|
+
<OfflineFallbackScreen>
|
|
132
132
|
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
133
133
|
<RouteManager pathname={pathname} screenData={screenData} />
|
|
134
134
|
</OfflineFallbackScreen>
|
|
@@ -11,9 +11,6 @@ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
11
11
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
12
|
import { PlayerDetails } from "./PlayerDetails";
|
|
13
13
|
import { playerDimesionsHack } from "./utils";
|
|
14
|
-
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
15
|
-
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
16
|
-
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
17
14
|
|
|
18
15
|
import {
|
|
19
16
|
AnimatedScrollModal,
|
|
@@ -124,19 +121,20 @@ const getTabletWidth = (
|
|
|
124
121
|
return Number(width) - sidebarWidth;
|
|
125
122
|
};
|
|
126
123
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
const showDetails = (
|
|
125
|
+
isMobile: boolean,
|
|
126
|
+
docked: boolean,
|
|
127
|
+
isInlineModal,
|
|
128
|
+
pip
|
|
129
|
+
): boolean => {
|
|
130
|
+
if (pip) {
|
|
131
|
+
return false;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
if (
|
|
133
|
-
return
|
|
134
|
+
if (!isInlineModal) {
|
|
135
|
+
return false;
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
return baseStyle;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const showDetails = (isMobile: boolean, docked: boolean): boolean => {
|
|
140
138
|
// for mobile we always show details. Mounting of it very heavy operation.
|
|
141
139
|
if (isMobile) {
|
|
142
140
|
return true;
|
|
@@ -154,7 +152,7 @@ const showDetails = (isMobile: boolean, docked: boolean): boolean => {
|
|
|
154
152
|
const PlayerWrapperComponent = (props: Props) => {
|
|
155
153
|
const {
|
|
156
154
|
entry,
|
|
157
|
-
style
|
|
155
|
+
style,
|
|
158
156
|
containerStyle,
|
|
159
157
|
inline,
|
|
160
158
|
docked,
|
|
@@ -169,7 +167,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
169
167
|
|
|
170
168
|
const isInlineModal = inline && isModal;
|
|
171
169
|
|
|
172
|
-
const style = getStyles(baseStyle, !isTablet, isInlineModal);
|
|
170
|
+
// const style = getStyles(baseStyle, !isTablet, isInlineModal, pip);
|
|
173
171
|
|
|
174
172
|
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
175
173
|
|
|
@@ -209,72 +207,62 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
209
207
|
[containerDimensions, playerDimesionsHack]
|
|
210
208
|
);
|
|
211
209
|
|
|
212
|
-
const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${entry?.id}`;
|
|
213
|
-
|
|
214
210
|
return (
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
<WrapperView
|
|
212
|
+
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
213
|
+
style={[
|
|
214
|
+
safeAreaStyles(configuration, isTablet),
|
|
215
|
+
style,
|
|
216
|
+
playerDimesionsHack,
|
|
217
|
+
]}
|
|
218
|
+
>
|
|
219
|
+
<AnimationComponent
|
|
220
|
+
animationType={ComponentAnimationType.moveUpComponent}
|
|
221
|
+
additionalData={{ saveArea: true }}
|
|
222
|
+
style={[directionStyles(isTabletLandscape), defaultStyles.flex]}
|
|
223
|
+
>
|
|
224
|
+
<View
|
|
225
|
+
testID={`${entry?.id}-player-container`}
|
|
219
226
|
style={[
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
defaultStyles.playerContainer,
|
|
228
|
+
containerDimensions,
|
|
229
|
+
containerStyle,
|
|
222
230
|
playerDimesionsHack,
|
|
223
231
|
]}
|
|
224
232
|
>
|
|
225
233
|
<AnimationComponent
|
|
226
234
|
animationType={ComponentAnimationType.moveUpComponent}
|
|
227
|
-
|
|
228
|
-
|
|
235
|
+
style={isTabletLandscape ? defaultStyles.flex : undefined}
|
|
236
|
+
additionalData={{
|
|
237
|
+
useLayoutMeasure: isTabletLandscape,
|
|
238
|
+
disableAnimatedComponent: !isTabletLandscape,
|
|
239
|
+
resetAnimationValue: isTabletLandscape && docked,
|
|
240
|
+
}}
|
|
229
241
|
>
|
|
230
|
-
<
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
testID={`${entry?.id}-player-container`}
|
|
234
|
-
style={[
|
|
235
|
-
defaultStyles.playerContainer,
|
|
236
|
-
containerDimensions,
|
|
237
|
-
containerStyle,
|
|
238
|
-
playerDimesionsHack,
|
|
239
|
-
]}
|
|
240
|
-
>
|
|
241
|
-
<AnimationComponent
|
|
242
|
-
animationType={ComponentAnimationType.moveUpComponent}
|
|
243
|
-
style={isTabletLandscape ? defaultStyles.flex : undefined}
|
|
244
|
-
additionalData={{
|
|
245
|
-
useLayoutMeasure: isTabletLandscape,
|
|
246
|
-
disableAnimatedComponent: !isTabletLandscape,
|
|
247
|
-
resetAnimationValue: isTabletLandscape && docked,
|
|
248
|
-
}}
|
|
249
|
-
>
|
|
250
|
-
<AnimatedVideoPlayerComponent>
|
|
251
|
-
{children(childrenStyles)}
|
|
252
|
-
</AnimatedVideoPlayerComponent>
|
|
253
|
-
</AnimationComponent>
|
|
254
|
-
</View>
|
|
255
|
-
|
|
256
|
-
<AnimatedScrollModal>
|
|
257
|
-
{showDetails(!isTablet, docked) && (
|
|
258
|
-
<AnimationComponent
|
|
259
|
-
animationType={ComponentAnimationType.componentFade}
|
|
260
|
-
style={defaultStyles.flex}
|
|
261
|
-
>
|
|
262
|
-
<PlayerDetails
|
|
263
|
-
configuration={configuration}
|
|
264
|
-
style={defaultStyles.playerDetails}
|
|
265
|
-
entry={entry}
|
|
266
|
-
isTabletLandscape={isTabletLandscape}
|
|
267
|
-
isTablet={isTablet}
|
|
268
|
-
/>
|
|
269
|
-
</AnimationComponent>
|
|
270
|
-
)}
|
|
271
|
-
</AnimatedScrollModal>
|
|
272
|
-
</ScreenContextProvider>
|
|
273
|
-
</PathnameContext.Provider>
|
|
242
|
+
<AnimatedVideoPlayerComponent>
|
|
243
|
+
{children(childrenStyles)}
|
|
244
|
+
</AnimatedVideoPlayerComponent>
|
|
274
245
|
</AnimationComponent>
|
|
275
|
-
</
|
|
276
|
-
|
|
277
|
-
|
|
246
|
+
</View>
|
|
247
|
+
|
|
248
|
+
<AnimatedScrollModal>
|
|
249
|
+
{showDetails(!isTablet, docked, isInlineModal, pip) && (
|
|
250
|
+
<AnimationComponent
|
|
251
|
+
animationType={ComponentAnimationType.componentFade}
|
|
252
|
+
style={defaultStyles.flex}
|
|
253
|
+
>
|
|
254
|
+
<PlayerDetails
|
|
255
|
+
configuration={configuration}
|
|
256
|
+
style={defaultStyles.playerDetails}
|
|
257
|
+
entry={entry}
|
|
258
|
+
isTabletLandscape={isTabletLandscape}
|
|
259
|
+
isTablet={isTablet}
|
|
260
|
+
/>
|
|
261
|
+
</AnimationComponent>
|
|
262
|
+
)}
|
|
263
|
+
</AnimatedScrollModal>
|
|
264
|
+
</AnimationComponent>
|
|
265
|
+
</WrapperView>
|
|
278
266
|
);
|
|
279
267
|
};
|
|
280
268
|
|
|
@@ -27,8 +27,8 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
27
27
|
"backgroundColor": "transparent",
|
|
28
28
|
},
|
|
29
29
|
Object {
|
|
30
|
-
"height":
|
|
31
|
-
"width":
|
|
30
|
+
"height": 800,
|
|
31
|
+
"width": 300,
|
|
32
32
|
},
|
|
33
33
|
Object {},
|
|
34
34
|
]
|
|
@@ -133,8 +133,8 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
133
133
|
"backgroundColor": "transparent",
|
|
134
134
|
},
|
|
135
135
|
Object {
|
|
136
|
-
"height":
|
|
137
|
-
"width":
|
|
136
|
+
"height": undefined,
|
|
137
|
+
"width": 300,
|
|
138
138
|
},
|
|
139
139
|
Object {},
|
|
140
140
|
]
|
|
@@ -361,8 +361,8 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
361
361
|
"backgroundColor": "transparent",
|
|
362
362
|
},
|
|
363
363
|
Object {
|
|
364
|
-
"height":
|
|
365
|
-
"width":
|
|
364
|
+
"height": 800,
|
|
365
|
+
"width": 300,
|
|
366
366
|
},
|
|
367
367
|
Object {},
|
|
368
368
|
]
|
|
@@ -405,36 +405,6 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
405
405
|
}
|
|
406
406
|
testID="test-player-container"
|
|
407
407
|
/>
|
|
408
|
-
<View
|
|
409
|
-
animationType="componentFade"
|
|
410
|
-
style={
|
|
411
|
-
Object {
|
|
412
|
-
"flex": 1,
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
>
|
|
416
|
-
<View
|
|
417
|
-
configuration={
|
|
418
|
-
Object {
|
|
419
|
-
"tablet_landscape_player_container_background_color": "red",
|
|
420
|
-
"tablet_landscape_sidebar_width": "35%",
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
entry={
|
|
424
|
-
Object {
|
|
425
|
-
"id": "test",
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
isTablet={false}
|
|
429
|
-
isTabletLandscape={false}
|
|
430
|
-
style={
|
|
431
|
-
Object {
|
|
432
|
-
"flex": 1,
|
|
433
|
-
"paddingTop": 20,
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
/>
|
|
437
|
-
</View>
|
|
438
408
|
</View>
|
|
439
409
|
</RNCSafeAreaView>
|
|
440
410
|
</RNCSafeAreaProvider>
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { FocusableGroupContext } from "./FocusableGroupContext";
|
|
3
3
|
|
|
4
4
|
export const withFocusableContext = (Component) => {
|
|
5
5
|
// eslint-disable-next-line react/display-name
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const WithFocusableContext = (
|
|
7
|
+
{ groupId, ...props }: Record<string, any>,
|
|
8
|
+
ref
|
|
9
|
+
) => {
|
|
10
|
+
return (
|
|
11
|
+
<FocusableGroupContext.Consumer>
|
|
12
|
+
{(groupIdContext: string) => {
|
|
13
|
+
// eslint-disable-next-line react/display-name
|
|
14
|
+
const propsGroupId = groupId || null;
|
|
15
|
+
const providedGroupId = propsGroupId || groupIdContext;
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
return <Component {...props} groupId={providedGroupId} ref={ref} />;
|
|
18
|
+
}}
|
|
19
|
+
</FocusableGroupContext.Consumer>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return React.forwardRef(WithFocusableContext);
|
|
17
24
|
};
|
|
@@ -5,18 +5,18 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
5
5
|
|
|
6
6
|
type ComponentProps = {
|
|
7
7
|
component: {
|
|
8
|
-
id: string
|
|
9
|
-
rules: { item_limit: number
|
|
10
|
-
component_type: string
|
|
8
|
+
id: string;
|
|
9
|
+
rules: { item_limit: number; component_cells_selectable: boolean };
|
|
10
|
+
component_type: string;
|
|
11
11
|
styles: {
|
|
12
|
-
cell_style: string
|
|
13
|
-
header: { visible: boolean }
|
|
14
|
-
component_cells_selectable: boolean
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
zappPipesData: { url: string
|
|
18
|
-
selected: boolean
|
|
19
|
-
assets: { menu_button: string }
|
|
12
|
+
cell_style: string;
|
|
13
|
+
header: { visible: boolean };
|
|
14
|
+
component_cells_selectable: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
zappPipesData: { url: string; data: { title: string } };
|
|
18
|
+
selected: boolean;
|
|
19
|
+
assets: { menu_button: string };
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
function withAnalytics(Component) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.6714678893",
|
|
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": "13.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.6714678893",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.6714678893",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.6714678893",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.6714678893",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|