@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1803625751 → 16.0.0-alpha.1816065263
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/tv/__tests__/audioPlayer.test.js +19 -0
- package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
- package/Components/AudioPlayer/tv/index.tsx +5 -1
- package/Components/CellRendererResolver/index.ts +1 -1
- package/Components/Layout/FullWidthRow.tsx +38 -0
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -0
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +27 -7
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -136
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +30 -10
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +0 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +21 -15
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/dataAdapter.ts +15 -5
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/MasterCell/index.tsx +30 -5
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
- package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
- package/Components/MasterCell/utils/index.ts +85 -46
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +332 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +402 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +811 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +878 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +49 -26
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +18 -10
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
- package/Components/Screen/index.tsx +8 -4
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +1 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/CachedDimensionsContext/index.ts +17 -2
- package/package.json +5 -5
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- package/Components/Screen/utils.ts +0 -16
- /package/Components/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
- /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
toNumberWithDefault,
|
|
3
|
+
toNumberWithDefaultZero,
|
|
4
|
+
} from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
2
5
|
import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
3
6
|
|
|
4
7
|
import { Asset } from "./Asset";
|
|
@@ -11,25 +14,29 @@ import {
|
|
|
11
14
|
getTextLabelStyles,
|
|
12
15
|
} from "./utils";
|
|
13
16
|
import { ViewStyle } from "react-native";
|
|
17
|
+
import { Spacer } from "./Spacer";
|
|
14
18
|
|
|
15
|
-
const displayModeStyle = (value) => {
|
|
19
|
+
const displayModeStyle = (value, isVertical: boolean) => {
|
|
16
20
|
const mode = value("display_mode") || "dynamic";
|
|
17
21
|
|
|
18
22
|
const defaultStyle = {
|
|
19
23
|
flexShrink: 1,
|
|
20
24
|
};
|
|
21
25
|
|
|
26
|
+
const width = toNumberWithDefault(140, value("width"));
|
|
27
|
+
|
|
22
28
|
switch (mode) {
|
|
23
29
|
case "fixed":
|
|
24
30
|
return {
|
|
25
31
|
...defaultStyle,
|
|
26
|
-
width
|
|
27
|
-
maxWidth:
|
|
32
|
+
width,
|
|
33
|
+
maxWidth: width,
|
|
28
34
|
};
|
|
29
35
|
case "fill":
|
|
30
36
|
return {
|
|
31
37
|
...defaultStyle,
|
|
32
|
-
|
|
38
|
+
width: isVertical ? "100%" : undefined,
|
|
39
|
+
flex: !isVertical ? 1 : undefined,
|
|
33
40
|
};
|
|
34
41
|
case "dynamic":
|
|
35
42
|
default:
|
|
@@ -45,6 +52,7 @@ type Props = {
|
|
|
45
52
|
stylePrefix: string;
|
|
46
53
|
specificPrefix: string;
|
|
47
54
|
spacingStyle: ViewStyle;
|
|
55
|
+
isVertical: boolean;
|
|
48
56
|
};
|
|
49
57
|
|
|
50
58
|
export const Button = ({
|
|
@@ -53,8 +61,9 @@ export const Button = ({
|
|
|
53
61
|
stylePrefix,
|
|
54
62
|
specificPrefix,
|
|
55
63
|
spacingStyle,
|
|
64
|
+
isVertical,
|
|
56
65
|
}: Props) => {
|
|
57
|
-
//
|
|
66
|
+
// Retrieves values depending to the slot
|
|
58
67
|
const getSlotBasedValue = (property: string) =>
|
|
59
68
|
value(`${specificPrefix}_${property}`);
|
|
60
69
|
|
|
@@ -78,21 +87,27 @@ export const Button = ({
|
|
|
78
87
|
const testID = `mobile_action_button_${index + 1}`;
|
|
79
88
|
const actionIdentifier = getSlotBasedValue("assign_action");
|
|
80
89
|
const assetAlignment = getValue("asset_alignment") || "left";
|
|
90
|
+
|
|
91
|
+
const hasHorizontalAlignment = ["left", "right"].includes(assetAlignment);
|
|
92
|
+
const vGutter = toNumberWithDefaultZero(getValue("vertical_gutter"));
|
|
93
|
+
const hGutter = toNumberWithDefaultZero(getValue("horizontal_gutter"));
|
|
81
94
|
const actionAssetFlavour = getValue("action_asset_flavour");
|
|
82
95
|
const contentsAlignment = getValue("contents_alignment") || "center";
|
|
96
|
+
const displayMode = getValue("display_mode") || "dynamic";
|
|
83
97
|
|
|
84
98
|
return {
|
|
85
99
|
type: "MobileActionButton",
|
|
86
100
|
style: {
|
|
87
|
-
flexDirection: getContentDirection(assetAlignment),
|
|
88
101
|
// alignContent: "center", Why do we need this?
|
|
89
102
|
...getPressableStyles(getValue),
|
|
90
|
-
...displayModeStyle(getValue),
|
|
103
|
+
...displayModeStyle(getValue, isVertical),
|
|
91
104
|
...spacingStyle,
|
|
92
105
|
},
|
|
93
106
|
additionalProps: {
|
|
107
|
+
displayMode,
|
|
94
108
|
alignment: {
|
|
95
109
|
alignContent: "center",
|
|
110
|
+
flexDirection: getContentDirection(assetAlignment),
|
|
96
111
|
alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
97
112
|
justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
98
113
|
},
|
|
@@ -115,7 +130,12 @@ export const Button = ({
|
|
|
115
130
|
testID,
|
|
116
131
|
})
|
|
117
132
|
: null,
|
|
118
|
-
|
|
133
|
+
Spacer({
|
|
134
|
+
enabled: assetEnabled && labelEnabled,
|
|
135
|
+
style: hasHorizontalAlignment
|
|
136
|
+
? { width: hGutter }
|
|
137
|
+
: { height: vGutter },
|
|
138
|
+
}),
|
|
119
139
|
labelEnabled
|
|
120
140
|
? TextLabelsContainer({
|
|
121
141
|
style: getTextLabelStyles(getValue),
|
|
@@ -128,7 +148,7 @@ export const Button = ({
|
|
|
128
148
|
},
|
|
129
149
|
transformText: getValue("text_transform") || "default",
|
|
130
150
|
numberOfLines: getValue("number_of_lines") || 1,
|
|
131
|
-
|
|
151
|
+
ellipsizeMode: "tail",
|
|
132
152
|
},
|
|
133
153
|
actionIdentifier,
|
|
134
154
|
testID,
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
type Props = {
|
|
2
2
|
enabled?: boolean;
|
|
3
|
+
style?: object;
|
|
3
4
|
};
|
|
4
5
|
|
|
5
|
-
export const Spacer = ({
|
|
6
|
+
export const Spacer = ({
|
|
7
|
+
enabled = false,
|
|
8
|
+
style = { flex: 1 },
|
|
9
|
+
}: Props = {}) => {
|
|
6
10
|
if (!enabled) {
|
|
7
11
|
return null;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
return {
|
|
11
15
|
type: "View",
|
|
12
|
-
style
|
|
13
|
-
flex: 1,
|
|
14
|
-
},
|
|
16
|
+
style,
|
|
15
17
|
};
|
|
16
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Text as RNText,
|
|
2
|
+
import { Pressable, Text as RNText, View } from "react-native";
|
|
3
3
|
import { render, fireEvent } from "@testing-library/react-native";
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
5
|
|
|
@@ -8,6 +8,11 @@ import { elementMapper } from "../../../../elementMapper";
|
|
|
8
8
|
import { defaultComponents } from "../../../index";
|
|
9
9
|
import { MobileActionButtons } from "..";
|
|
10
10
|
import { AssetComponent } from "../AssetComponent";
|
|
11
|
+
import { usePressedState } from "../../../../hooks/usePressedState";
|
|
12
|
+
|
|
13
|
+
jest.mock("../../../../hooks/usePressedState", () => ({
|
|
14
|
+
usePressedState: jest.fn(),
|
|
15
|
+
}));
|
|
11
16
|
|
|
12
17
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
|
|
13
18
|
useActions: jest.fn(),
|
|
@@ -136,6 +141,7 @@ const baseNode = {
|
|
|
136
141
|
borderColor: "rgba(4,4,4,1)",
|
|
137
142
|
},
|
|
138
143
|
testID: "mobile-action-button",
|
|
144
|
+
testOnly_pressed: false,
|
|
139
145
|
},
|
|
140
146
|
elements: [
|
|
141
147
|
{
|
|
@@ -190,14 +196,20 @@ const baseNode = {
|
|
|
190
196
|
describe("MobileActionButton", () => {
|
|
191
197
|
beforeEach(() => {
|
|
192
198
|
jest.clearAllMocks();
|
|
199
|
+
(usePressedState as jest.Mock).mockReturnValue(false);
|
|
193
200
|
});
|
|
194
201
|
|
|
195
|
-
const renderNode = (node = baseNode) =>
|
|
196
|
-
|
|
202
|
+
const renderNode = ({ node = baseNode, pressed = false } = {}) => {
|
|
203
|
+
if (pressed) {
|
|
204
|
+
node.props.testOnly_pressed = true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return render(
|
|
197
208
|
<React.Fragment>
|
|
198
209
|
{elementMapper(defaultComponents)(node as never)}
|
|
199
210
|
</React.Fragment>
|
|
200
211
|
);
|
|
212
|
+
};
|
|
201
213
|
|
|
202
214
|
it("renders nested image and text children through elementMapper", () => {
|
|
203
215
|
mockUseActions.mockReturnValue(buildActionContext());
|
|
@@ -210,12 +222,13 @@ describe("MobileActionButton", () => {
|
|
|
210
222
|
});
|
|
211
223
|
|
|
212
224
|
it("applies focused styles when action entry state is active", () => {
|
|
225
|
+
(usePressedState as jest.Mock).mockReturnValue(true);
|
|
213
226
|
mockUseActions.mockReturnValue(buildActionContext({ active: true }));
|
|
214
227
|
|
|
215
|
-
const { getByTestId, getByText } = renderNode();
|
|
228
|
+
const { getByTestId, getByText } = renderNode({ pressed: true });
|
|
216
229
|
|
|
217
230
|
expect(
|
|
218
|
-
getByTestId("mobile-action-button").props.style.backgroundColor
|
|
231
|
+
getByTestId("mobile-action-button").props.style[2].backgroundColor
|
|
219
232
|
).toBe("rgba(3,3,3,1)");
|
|
220
233
|
|
|
221
234
|
expect(getByText("Play").props.style).toEqual(
|
|
@@ -253,6 +266,8 @@ describe("MobileActionButton", () => {
|
|
|
253
266
|
})
|
|
254
267
|
);
|
|
255
268
|
|
|
269
|
+
node.props.testOnly_pressed = false;
|
|
270
|
+
|
|
256
271
|
const { UNSAFE_getAllByType, UNSAFE_getByType, getByTestId, getByText } =
|
|
257
272
|
render(
|
|
258
273
|
<React.Fragment>
|
|
@@ -260,14 +275,14 @@ describe("MobileActionButton", () => {
|
|
|
260
275
|
</React.Fragment>
|
|
261
276
|
);
|
|
262
277
|
|
|
263
|
-
const pressable = UNSAFE_getByType(
|
|
278
|
+
const pressable = UNSAFE_getByType(Pressable);
|
|
264
279
|
const label = getByText("Play");
|
|
265
280
|
const asset = getByTestId("mobile_action_button_1-asset");
|
|
266
281
|
|
|
267
282
|
expect(pressable.props.testID).toBe("mobile_action_button_1");
|
|
268
283
|
expect(pressable.props.accessibilityLabel).toBe("entry-1");
|
|
269
284
|
|
|
270
|
-
expect(pressable.props.style).toMatchObject({
|
|
285
|
+
expect(pressable.props.style({ pressed: false })[0]).toMatchObject({
|
|
271
286
|
backgroundColor: "rgba(1,1,1,1)",
|
|
272
287
|
borderColor: "rgba(2,2,2,1)",
|
|
273
288
|
borderWidth: 1,
|
|
@@ -278,15 +293,11 @@ describe("MobileActionButton", () => {
|
|
|
278
293
|
height: 24,
|
|
279
294
|
});
|
|
280
295
|
|
|
281
|
-
expect(label.props.style).
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
lineHeight: 24,
|
|
287
|
-
}),
|
|
288
|
-
])
|
|
289
|
-
);
|
|
296
|
+
expect(label.props.style[0]).toMatchObject({
|
|
297
|
+
color: "rgba(10,10,10,1)",
|
|
298
|
+
fontSize: 15,
|
|
299
|
+
lineHeight: 24,
|
|
300
|
+
});
|
|
290
301
|
|
|
291
302
|
expect(UNSAFE_getAllByType(View).length).toBeGreaterThan(0);
|
|
292
303
|
expect(UNSAFE_getAllByType(RNText).length).toBeGreaterThan(0);
|
|
@@ -324,7 +335,7 @@ describe("MobileActionButton", () => {
|
|
|
324
335
|
buildActionContext({ mobileButtonAssets: MockAssetComponent })
|
|
325
336
|
);
|
|
326
337
|
|
|
327
|
-
const { getByTestId } = renderNode(nodeWithFlavour1);
|
|
338
|
+
const { getByTestId } = renderNode({ node: nodeWithFlavour1 });
|
|
328
339
|
|
|
329
340
|
expect(MockAssetComponent).toHaveBeenCalled();
|
|
330
341
|
expect(getByTestId("mobile-action-button-asset")).toBeTruthy();
|
|
@@ -339,7 +350,7 @@ describe("MobileActionButton", () => {
|
|
|
339
350
|
buildActionContext({ mobileButtonAssets: MockAssetComponent })
|
|
340
351
|
);
|
|
341
352
|
|
|
342
|
-
renderNode(nodeWithFlavour1);
|
|
353
|
+
renderNode({ node: nodeWithFlavour1 });
|
|
343
354
|
|
|
344
355
|
expect(MockAssetComponent).toHaveBeenCalledWith(
|
|
345
356
|
expect.objectContaining({ flavour: "flavour_1" }),
|
|
@@ -356,7 +367,7 @@ describe("MobileActionButton", () => {
|
|
|
356
367
|
buildActionContext({ mobileButtonAssets: MockAssetComponent })
|
|
357
368
|
);
|
|
358
369
|
|
|
359
|
-
renderNode(nodeWithFlavour2);
|
|
370
|
+
renderNode({ node: nodeWithFlavour2 });
|
|
360
371
|
|
|
361
372
|
expect(MockAssetComponent).toHaveBeenCalledWith(
|
|
362
373
|
expect.objectContaining({ flavour: "flavour_2" }),
|
|
@@ -369,7 +380,7 @@ describe("MobileActionButton", () => {
|
|
|
369
380
|
buildActionContext({ mobileButtonAssets: undefined })
|
|
370
381
|
);
|
|
371
382
|
|
|
372
|
-
const { queryByTestId } = renderNode(nodeWithFlavour1);
|
|
383
|
+
const { queryByTestId } = renderNode({ node: nodeWithFlavour1 });
|
|
373
384
|
|
|
374
385
|
expect(queryByTestId("mobile-action-button-asset")).toBeNull();
|
|
375
386
|
});
|
|
@@ -385,7 +396,7 @@ describe("MobileActionButton", () => {
|
|
|
385
396
|
})
|
|
386
397
|
);
|
|
387
398
|
|
|
388
|
-
const { getByTestId } = renderNode(nodeWithFlavour1);
|
|
399
|
+
const { getByTestId } = renderNode({ node: nodeWithFlavour1 });
|
|
389
400
|
|
|
390
401
|
expect(getByTestId("mobile-action-button-asset")).toBeTruthy();
|
|
391
402
|
});
|
package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts
CHANGED
|
@@ -241,10 +241,21 @@ describe("MobileActionButtons", () => {
|
|
|
241
241
|
expect(overImageResult?.additionalProps?.contentStyle).toMatchObject({
|
|
242
242
|
flexDirection: "column",
|
|
243
243
|
alignItems: "center",
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
paddingTop: 5,
|
|
245
|
+
paddingRight: 6,
|
|
246
|
+
paddingBottom: 7,
|
|
247
|
+
paddingLeft: 8,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
expect(overImageResult?.style).toMatchObject({
|
|
251
|
+
alignItems: "flex-end",
|
|
252
|
+
bottom: 0,
|
|
253
|
+
justifyContent: "flex-start",
|
|
254
|
+
left: 0,
|
|
255
|
+
position: "absolute",
|
|
256
|
+
right: 0,
|
|
257
|
+
top: 0,
|
|
258
|
+
zIndex: 10,
|
|
248
259
|
});
|
|
249
260
|
|
|
250
261
|
expect(
|
|
@@ -43,9 +43,24 @@ export const MobileActionButtons = ({
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const {
|
|
47
|
+
container: { stacking, verticalGutter, horizontalGutter },
|
|
48
|
+
} = model;
|
|
49
|
+
|
|
50
|
+
const isVertical = stacking === "vertical";
|
|
51
|
+
const isOverImage = position === "over_image";
|
|
52
|
+
const gutter = isVertical ? verticalGutter : horizontalGutter;
|
|
53
|
+
|
|
54
|
+
const containerPaddings = {
|
|
55
|
+
paddingTop: model.container.margins.top,
|
|
56
|
+
paddingRight: model.container.margins.right,
|
|
57
|
+
paddingBottom: model.container.margins.bottom,
|
|
58
|
+
paddingLeft: model.container.margins.left,
|
|
59
|
+
};
|
|
60
|
+
|
|
46
61
|
const style = {
|
|
47
62
|
alignItems: "center",
|
|
48
|
-
...(
|
|
63
|
+
...(isOverImage
|
|
49
64
|
? {
|
|
50
65
|
position: "absolute",
|
|
51
66
|
zIndex: 10,
|
|
@@ -61,27 +76,17 @@ export const MobileActionButtons = ({
|
|
|
61
76
|
};
|
|
62
77
|
|
|
63
78
|
const contentStyle = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
...containerPaddings,
|
|
80
|
+
flexDirection: isVertical ? "column" : "row",
|
|
81
|
+
width: isVertical ? "100%" : undefined,
|
|
82
|
+
alignSelf: !isOverImage ? model.container.horizontalAlign : undefined,
|
|
67
83
|
alignItems: model.container.horizontalAlign,
|
|
68
|
-
marginTop: model.container.margins.top,
|
|
69
|
-
marginRight: model.container.margins.right,
|
|
70
|
-
marginBottom: model.container.margins.bottom,
|
|
71
|
-
marginLeft: model.container.margins.left,
|
|
72
84
|
};
|
|
73
85
|
|
|
74
86
|
const elements = compact(
|
|
75
87
|
model.buttons.map(({ renderIndex, specificPrefix, stylePrefix }) => {
|
|
76
88
|
const isNotLast = renderIndex < model.buttons.length - 1;
|
|
77
89
|
|
|
78
|
-
const {
|
|
79
|
-
container: { stacking, verticalGutter, horizontalGutter },
|
|
80
|
-
} = model;
|
|
81
|
-
|
|
82
|
-
const isVertical = stacking === "vertical";
|
|
83
|
-
const gutter = isVertical ? verticalGutter : horizontalGutter;
|
|
84
|
-
|
|
85
90
|
const spacingStyle: ViewStyle = {
|
|
86
91
|
[isVertical ? "marginBottom" : "marginRight"]: isNotLast ? gutter : 0,
|
|
87
92
|
};
|
|
@@ -92,6 +97,7 @@ export const MobileActionButtons = ({
|
|
|
92
97
|
stylePrefix,
|
|
93
98
|
specificPrefix,
|
|
94
99
|
spacingStyle,
|
|
100
|
+
isVertical,
|
|
95
101
|
});
|
|
96
102
|
|
|
97
103
|
if (!button) return null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
3
|
+
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
3
4
|
|
|
4
5
|
import { functionForName } from "./MappingFunctions";
|
|
5
6
|
import { resolveColor } from "./utils";
|
|
@@ -52,7 +53,8 @@ export function configInflater(
|
|
|
52
53
|
additionalProps?: Record<string, any>;
|
|
53
54
|
data?: Array<{ propName: string; func: Function; args: any[] }>;
|
|
54
55
|
elements?: any[];
|
|
55
|
-
}
|
|
56
|
+
},
|
|
57
|
+
allowDynamicColorsOutsideExtensions: boolean
|
|
56
58
|
) {
|
|
57
59
|
const props = data.reduce(
|
|
58
60
|
(acc, curr) => {
|
|
@@ -68,13 +70,13 @@ export function configInflater(
|
|
|
68
70
|
|
|
69
71
|
if (Array.isArray(elements)) {
|
|
70
72
|
adjustedElements = elements.map((element) =>
|
|
71
|
-
configInflater(entry, element as any)
|
|
73
|
+
configInflater(entry, element as any, allowDynamicColorsOutsideExtensions)
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
return {
|
|
76
78
|
type,
|
|
77
|
-
style: resolveColor(entry, style),
|
|
79
|
+
style: resolveColor(entry, style, allowDynamicColorsOutsideExtensions),
|
|
78
80
|
props,
|
|
79
81
|
elements: adjustedElements,
|
|
80
82
|
};
|
|
@@ -98,9 +100,17 @@ function resolveElementsNode(entry, state, elements) {
|
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
export function defaultDataAdapter(elements) {
|
|
101
|
-
return function elementsBuilder({
|
|
103
|
+
return function elementsBuilder({
|
|
104
|
+
entry,
|
|
105
|
+
state = "default",
|
|
106
|
+
allowDynamicColorsOutsideExtensions,
|
|
107
|
+
}) {
|
|
102
108
|
return resolveElementsNode(entry, state, elements).map((element) =>
|
|
103
|
-
configInflater(
|
|
109
|
+
configInflater(
|
|
110
|
+
entry,
|
|
111
|
+
element,
|
|
112
|
+
toBooleanWithDefaultFalse(allowDynamicColorsOutsideExtensions)
|
|
113
|
+
)
|
|
104
114
|
);
|
|
105
115
|
};
|
|
106
116
|
}
|
|
@@ -2,7 +2,10 @@ import * as R from "ramda";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { v4 as uuid } from "uuid";
|
|
4
4
|
|
|
5
|
+
import { isHorizontalList } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
6
|
+
import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
|
|
5
7
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
8
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
9
|
import { useScreenState } from "@applicaster/zapp-react-native-utils/screenState";
|
|
7
10
|
import { defaultComponents } from "./DefaultComponents";
|
|
8
11
|
import { defaultDataAdapter } from "./dataAdapter";
|
|
@@ -34,8 +37,8 @@ type MasterCellBuilderOptions = {
|
|
|
34
37
|
containerStyle: any;
|
|
35
38
|
cellOptions?: {
|
|
36
39
|
isRTL?: boolean;
|
|
37
|
-
generateId?: () => string;
|
|
38
40
|
skipButtons?: boolean;
|
|
41
|
+
component?: ZappComponent;
|
|
39
42
|
};
|
|
40
43
|
};
|
|
41
44
|
|
|
@@ -46,7 +49,7 @@ export function masterCellBuilder({
|
|
|
46
49
|
containerStyle = defaultContainerStyle,
|
|
47
50
|
cellOptions = {},
|
|
48
51
|
}: MasterCellBuilderOptions) {
|
|
49
|
-
const {
|
|
52
|
+
const { skipButtons = false, component } = cellOptions;
|
|
50
53
|
|
|
51
54
|
const componentsMap = R.merge(defaultComponents, components);
|
|
52
55
|
const { View } = componentsMap;
|
|
@@ -65,6 +68,7 @@ export function masterCellBuilder({
|
|
|
65
68
|
*/
|
|
66
69
|
function MasterCell({ item, state, ...otherProps }: Props) {
|
|
67
70
|
const { screenData } = useRoute();
|
|
71
|
+
const theme = useTheme();
|
|
68
72
|
|
|
69
73
|
const screenId =
|
|
70
74
|
screenData && "targetScreen" in screenData
|
|
@@ -85,14 +89,35 @@ export function masterCellBuilder({
|
|
|
85
89
|
elementsBuilder({
|
|
86
90
|
entry: item,
|
|
87
91
|
state: getEntryState(state, entryIsSelected),
|
|
92
|
+
allowDynamicColorsOutsideExtensions:
|
|
93
|
+
theme?.allow_dynamic_colors_outside_extensions,
|
|
88
94
|
}),
|
|
89
|
-
[
|
|
95
|
+
[
|
|
96
|
+
state,
|
|
97
|
+
item,
|
|
98
|
+
entryIsSelected,
|
|
99
|
+
theme?.allow_dynamic_colors_outside_extensions,
|
|
100
|
+
] // Assuming that item won't mutate
|
|
90
101
|
);
|
|
91
102
|
|
|
92
103
|
const wrapperRef = React.useRef(null);
|
|
93
104
|
|
|
94
|
-
const cellUUID = React.useMemo<string>(
|
|
95
|
-
|
|
105
|
+
const cellUUID = React.useMemo<string>(() => {
|
|
106
|
+
const isLiveImage = isVideoPreviewEnabled({
|
|
107
|
+
enable_video_preview: component?.rules?.enable_video_preview,
|
|
108
|
+
player_screen_id: component?.rules?.player_screen_id,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const isHL = isHorizontalList(component);
|
|
112
|
+
|
|
113
|
+
return isHL && isLiveImage
|
|
114
|
+
? `${component?.id}-${component?.styles?.cell_plugin_configuration_id}`
|
|
115
|
+
: uuid();
|
|
116
|
+
}, [
|
|
117
|
+
component?.id,
|
|
118
|
+
component?.styles?.cell_plugin_configuration_id,
|
|
119
|
+
component?.rules?.enable_video_preview,
|
|
120
|
+
component?.rules?.player_screen_id,
|
|
96
121
|
screenId,
|
|
97
122
|
item?.id,
|
|
98
123
|
]);
|