@applicaster/zapp-react-native-ui-components 13.0.0-alpha.9103242840 → 13.0.0-alpha.9214758151
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/AppContainer/__tests__/AppContainer.test.js +4 -6
- package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +2 -3
- package/Components/Cell/Cell.tsx +7 -3
- package/Components/Cell/CellWithFocusable.tsx +44 -59
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +6 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableCell/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
- package/Components/FocusableGroup/index.tsx +0 -3
- package/Components/FocusableScrollView/index.tsx +6 -3
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -27
- package/Components/Layout/TV/NavBarContainer.tsx +14 -19
- package/Components/Layout/TV/ScreenContainer.tsx +8 -1
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +2 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -11
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +9 -135
- package/Components/ModalComponent/Button/index.tsx +6 -6
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/OfflineHandler/utils/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +17 -13
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/componentsMap.test.js +17 -5
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +8 -6
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -42
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +11 -9
- package/Components/TextInputTv/index.tsx +4 -3
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +53 -24
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +44 -30
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +31 -17
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerDetails.tsx +9 -6
- package/Components/VideoModal/PlayerWrapper.tsx +17 -36
- package/Components/VideoModal/VideoModal.tsx +16 -25
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
- package/Components/VideoModal/hooks/index.ts +7 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
- package/Components/VideoModal/hooks/utils/index.ts +33 -0
- package/Components/VideoModal/utils.ts +1 -1
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +3 -16
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +8 -5
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +6 -12
- package/Contexts/ScreenLayoutContext/index.tsx +5 -3
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +6 -2
- package/package.json +7 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -244,7 +244,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
|
|
|
244
244
|
return (
|
|
245
245
|
<>
|
|
246
246
|
<Image {...props} applyMaxSize />
|
|
247
|
-
{isShouldRender
|
|
247
|
+
{isShouldRender ? (
|
|
248
248
|
<View style={[style, positionAbsolute]}>
|
|
249
249
|
<PlayerLiveImage
|
|
250
250
|
uri={props.uri}
|
|
@@ -257,7 +257,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
|
|
|
257
257
|
audioMutedByDefault={audio_muted_by_default}
|
|
258
258
|
/>
|
|
259
259
|
</View>
|
|
260
|
-
)}
|
|
260
|
+
) : null}
|
|
261
261
|
</>
|
|
262
262
|
);
|
|
263
263
|
};
|
|
@@ -17,7 +17,7 @@ const SECONDARY_IMAGE_PREFIX = "secondary_image";
|
|
|
17
17
|
|
|
18
18
|
type ImageSizing = typeof IMAGE_SIZING_FIT | typeof IMAGE_SIZING_FILL;
|
|
19
19
|
|
|
20
|
-
type ImagePosition = typeof IMAGE_POSITION[keyof typeof IMAGE_POSITION];
|
|
20
|
+
type ImagePosition = (typeof IMAGE_POSITION)[keyof typeof IMAGE_POSITION];
|
|
21
21
|
|
|
22
22
|
export type DisplayMode =
|
|
23
23
|
| typeof DISPLAY_MODE_FIXED
|
|
@@ -34,7 +34,6 @@ export const useFillInPercent = (entry: ZappEntry): number => {
|
|
|
34
34
|
React.useState<number>(DEFAULT_FILL);
|
|
35
35
|
|
|
36
36
|
React.useEffect(() => {
|
|
37
|
-
// setup progress in UI on mount
|
|
38
37
|
getProgressValue(action, entry, (progress) => {
|
|
39
38
|
setFillInPercent(progress);
|
|
40
39
|
});
|
|
@@ -45,17 +44,12 @@ export const useFillInPercent = (entry: ZappEntry): number => {
|
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
const unsubscribe = action?.addDataSourceListener?.(() => {
|
|
47
|
+
return action?.addDataSourceListener?.(() => {
|
|
50
48
|
getProgressValue(action, entry, (progress) => {
|
|
51
49
|
setFillInPercent(progress);
|
|
52
50
|
});
|
|
53
51
|
});
|
|
54
|
-
|
|
55
|
-
return () => {
|
|
56
|
-
unsubscribe?.();
|
|
57
|
-
};
|
|
58
|
-
}, [isActive]);
|
|
52
|
+
}, [isActive, action, entry, setFillInPercent]);
|
|
59
53
|
|
|
60
54
|
return fillInPercent;
|
|
61
55
|
};
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
exports[`elementMapper renders the nodes 1`] = `
|
|
4
4
|
<View>
|
|
5
5
|
<View
|
|
6
|
-
key="View_0"
|
|
7
6
|
testProp={true}
|
|
8
7
|
viewProp={true}
|
|
9
8
|
>
|
|
10
|
-
<
|
|
11
|
-
key="0"
|
|
9
|
+
<View
|
|
12
10
|
style={
|
|
13
11
|
{
|
|
14
12
|
"borderTopLeftRadius": 4,
|
|
@@ -20,7 +18,6 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
20
18
|
uri="http://urlOfTheImage.net/img.png"
|
|
21
19
|
/>
|
|
22
20
|
<View
|
|
23
|
-
key="1"
|
|
24
21
|
style={
|
|
25
22
|
{
|
|
26
23
|
"height": 30,
|
|
@@ -32,8 +29,7 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
32
29
|
testProp={true}
|
|
33
30
|
viewProp={true}
|
|
34
31
|
>
|
|
35
|
-
<
|
|
36
|
-
key="0"
|
|
32
|
+
<View
|
|
37
33
|
label="Test Entry"
|
|
38
34
|
numberOfLines={1}
|
|
39
35
|
style={
|
|
@@ -47,7 +43,6 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
47
43
|
/>
|
|
48
44
|
</View>
|
|
49
45
|
<View
|
|
50
|
-
key="2"
|
|
51
46
|
style={
|
|
52
47
|
{
|
|
53
48
|
"height": 60,
|
|
@@ -58,8 +53,7 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
58
53
|
}
|
|
59
54
|
testProp={true}
|
|
60
55
|
>
|
|
61
|
-
<
|
|
62
|
-
key="0"
|
|
56
|
+
<View
|
|
63
57
|
label="Summary of the test entry"
|
|
64
58
|
numberOfLines={2}
|
|
65
59
|
style={
|
|
@@ -74,7 +68,6 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
74
68
|
/>
|
|
75
69
|
</View>
|
|
76
70
|
<View
|
|
77
|
-
key="3"
|
|
78
71
|
style={
|
|
79
72
|
{
|
|
80
73
|
"height": 42,
|
|
@@ -85,8 +78,7 @@ exports[`elementMapper renders the nodes 1`] = `
|
|
|
85
78
|
testProp={true}
|
|
86
79
|
viewProp={true}
|
|
87
80
|
>
|
|
88
|
-
<
|
|
89
|
-
key="0"
|
|
81
|
+
<View
|
|
90
82
|
style={
|
|
91
83
|
{
|
|
92
84
|
"height": 42,
|
|
@@ -1,35 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`masterCellBuilder when using a custom data adapter renders correctly 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
style={
|
|
6
|
-
{
|
|
7
|
-
"flex": 1,
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
>
|
|
11
|
-
<View
|
|
12
|
-
cellUUID="mocked-uuid"
|
|
13
|
-
key="0"
|
|
14
|
-
skipButtons={false}
|
|
15
|
-
style={
|
|
16
|
-
{
|
|
17
|
-
"backgroundColor": "#2F2F2F",
|
|
18
|
-
"borderRadius": 4,
|
|
19
|
-
"height": 436,
|
|
20
|
-
"marginRight": 20,
|
|
21
|
-
"width": 384,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
wrapperRef={
|
|
25
|
-
{
|
|
26
|
-
"current": null,
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/>
|
|
30
|
-
</View>
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
3
|
exports[`masterCellBuilder when using custom containerStyle renders correctly 1`] = `
|
|
34
4
|
<View
|
|
35
5
|
style={
|
|
@@ -73,202 +43,3 @@ exports[`masterCellBuilder when using custom default components renders correctl
|
|
|
73
43
|
/>
|
|
74
44
|
</mockConstructor>
|
|
75
45
|
`;
|
|
76
|
-
|
|
77
|
-
exports[`masterCellBuilder when using default options can be invoked as a React Component 1`] = `
|
|
78
|
-
<View
|
|
79
|
-
style={
|
|
80
|
-
{
|
|
81
|
-
"flex": 1,
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
>
|
|
85
|
-
<View
|
|
86
|
-
cellUUID="mocked-uuid"
|
|
87
|
-
key="0"
|
|
88
|
-
skipButtons={false}
|
|
89
|
-
style={
|
|
90
|
-
{
|
|
91
|
-
"backgroundColor": "#2F2F2F",
|
|
92
|
-
"borderRadius": 4,
|
|
93
|
-
"height": 436,
|
|
94
|
-
"marginRight": 20,
|
|
95
|
-
"width": 384,
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
whoAmI={
|
|
99
|
-
{
|
|
100
|
-
"contentType": "feed",
|
|
101
|
-
"state": "default",
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
wrapperRef={
|
|
105
|
-
{
|
|
106
|
-
"current": null,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
>
|
|
110
|
-
<ImageContainer
|
|
111
|
-
cellUUID="mocked-uuid"
|
|
112
|
-
key="0"
|
|
113
|
-
numberOfLines={1}
|
|
114
|
-
skipButtons={false}
|
|
115
|
-
style={
|
|
116
|
-
{
|
|
117
|
-
"borderTopLeftRadius": 4,
|
|
118
|
-
"borderTopRightRadius": 4,
|
|
119
|
-
"height": 216,
|
|
120
|
-
"width": 384,
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
uri="http://urlOfTheImage.net/img.png"
|
|
124
|
-
/>
|
|
125
|
-
<View
|
|
126
|
-
cellUUID="mocked-uuid"
|
|
127
|
-
key="1"
|
|
128
|
-
skipButtons={false}
|
|
129
|
-
style={
|
|
130
|
-
{
|
|
131
|
-
"height": 30,
|
|
132
|
-
"marginHorizontal": 24,
|
|
133
|
-
"marginTop": 24,
|
|
134
|
-
"width": 336,
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
wrapperRef={
|
|
138
|
-
{
|
|
139
|
-
"current": null,
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
>
|
|
143
|
-
<_Text
|
|
144
|
-
key="0"
|
|
145
|
-
label="Test Entry"
|
|
146
|
-
numberOfLines={1}
|
|
147
|
-
skipButtons={false}
|
|
148
|
-
style={
|
|
149
|
-
{
|
|
150
|
-
"color": "#EFEFEF",
|
|
151
|
-
"fontSize": 26,
|
|
152
|
-
"fontStyle": "normal",
|
|
153
|
-
"fontWeight": "bold",
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/>
|
|
157
|
-
</View>
|
|
158
|
-
<View
|
|
159
|
-
cellUUID="mocked-uuid"
|
|
160
|
-
key="2"
|
|
161
|
-
skipButtons={false}
|
|
162
|
-
style={
|
|
163
|
-
{
|
|
164
|
-
"height": 60,
|
|
165
|
-
"marginHorizontal": 24,
|
|
166
|
-
"marginTop": 10,
|
|
167
|
-
"width": 336,
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
wrapperRef={
|
|
171
|
-
{
|
|
172
|
-
"current": null,
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
>
|
|
176
|
-
<_Text
|
|
177
|
-
key="0"
|
|
178
|
-
label="Summary of the test entry"
|
|
179
|
-
numberOfLines={2}
|
|
180
|
-
skipButtons={false}
|
|
181
|
-
style={
|
|
182
|
-
{
|
|
183
|
-
"color": "#EFEFEF",
|
|
184
|
-
"fontSize": 24,
|
|
185
|
-
"fontStyle": "normal",
|
|
186
|
-
"fontWeight": "normal",
|
|
187
|
-
"opacity": 0.8,
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/>
|
|
191
|
-
</View>
|
|
192
|
-
<View
|
|
193
|
-
cellUUID="mocked-uuid"
|
|
194
|
-
key="3"
|
|
195
|
-
skipButtons={false}
|
|
196
|
-
style={
|
|
197
|
-
{
|
|
198
|
-
"height": 42,
|
|
199
|
-
"margin": 24,
|
|
200
|
-
"width": 56,
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
wrapperRef={
|
|
204
|
-
{
|
|
205
|
-
"current": null,
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
>
|
|
209
|
-
<ImageContainer
|
|
210
|
-
cellUUID="mocked-uuid"
|
|
211
|
-
key="0"
|
|
212
|
-
skipButtons={false}
|
|
213
|
-
style={
|
|
214
|
-
{
|
|
215
|
-
"height": 42,
|
|
216
|
-
"width": 56,
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
uri="http://urlOfTheImage.net/channelLogo.png"
|
|
220
|
-
/>
|
|
221
|
-
</View>
|
|
222
|
-
</View>
|
|
223
|
-
</View>
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
exports[`masterCellBuilder when using default options renders correctly 1`] = `
|
|
227
|
-
<View>
|
|
228
|
-
<Memo(MasterCell)
|
|
229
|
-
item={
|
|
230
|
-
{
|
|
231
|
-
"author": {
|
|
232
|
-
"name": "John Doe",
|
|
233
|
-
},
|
|
234
|
-
"id": "A1234",
|
|
235
|
-
"media_group": [
|
|
236
|
-
{
|
|
237
|
-
"media_item": [
|
|
238
|
-
{
|
|
239
|
-
"key": "image_base",
|
|
240
|
-
"src": "http://urlOfTheImage.net/img.png",
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
"type": "image",
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
"media_item": [
|
|
247
|
-
{
|
|
248
|
-
"key": "logo_thumbnail",
|
|
249
|
-
"src": "http://urlOfTheImage.net/channelLogo.png",
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
"type": "thumbnail",
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
"published": "2019/03/17 02:17:46 +0000",
|
|
256
|
-
"summary": "Summary of the test entry",
|
|
257
|
-
"title": "Test Entry",
|
|
258
|
-
"type": {
|
|
259
|
-
"value": "feed",
|
|
260
|
-
},
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/>
|
|
264
|
-
</View>
|
|
265
|
-
`;
|
|
266
|
-
|
|
267
|
-
exports[`masterCellBuilder when using default options returns a function 1`] = `
|
|
268
|
-
{
|
|
269
|
-
"$$typeof": Symbol(react.memo),
|
|
270
|
-
"compare": null,
|
|
271
|
-
"hasFocusableInside": [Function],
|
|
272
|
-
"type": [Function],
|
|
273
|
-
}
|
|
274
|
-
`;
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
-
import {
|
|
5
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
4
|
+
import { render } from "@testing-library/react-native";
|
|
6
5
|
import { elementMapper } from "../elementMapper";
|
|
7
6
|
import { elements } from "./testElements";
|
|
8
7
|
import { defaultComponents } from "../DefaultComponents";
|
|
9
8
|
|
|
9
|
+
jest.mock(
|
|
10
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
|
|
11
|
+
);
|
|
12
|
+
|
|
10
13
|
describe("elementMapper", () => {
|
|
11
14
|
it("renders the nodes", () => {
|
|
12
|
-
const wrapper =
|
|
15
|
+
const wrapper = render(
|
|
13
16
|
<View key={1}>
|
|
14
|
-
{R.map(
|
|
17
|
+
{R.map(
|
|
18
|
+
elementMapper(
|
|
19
|
+
Object.entries(defaultComponents).reduce((acc, [key]) => {
|
|
20
|
+
acc[key] = View;
|
|
21
|
+
|
|
22
|
+
return acc;
|
|
23
|
+
}, {}),
|
|
24
|
+
{ testProp: true }
|
|
25
|
+
),
|
|
26
|
+
elements
|
|
27
|
+
)}
|
|
15
28
|
</View>
|
|
16
29
|
);
|
|
17
30
|
|
|
18
|
-
expect(
|
|
31
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
19
32
|
});
|
|
20
33
|
});
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
3
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
4
|
|
|
6
5
|
import { testCellStyle } from "./TestCellStyle";
|
|
7
6
|
import { singleView } from "./SingleView";
|
|
8
7
|
import { entry } from "./testEntry";
|
|
9
8
|
import { singleElement } from "./testElements";
|
|
10
9
|
|
|
11
|
-
jest.mock(
|
|
12
|
-
useRoute
|
|
13
|
-
|
|
10
|
+
jest.mock(
|
|
11
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
12
|
+
() => ({
|
|
13
|
+
useRoute: jest.fn(() => ({ screenData: { id: "test" } })),
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
jest.mock(
|
|
18
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
19
|
+
() => ({
|
|
20
|
+
useIsScreenActive: jest.fn(() => true),
|
|
21
|
+
})
|
|
22
|
+
);
|
|
14
23
|
|
|
15
24
|
jest.mock("@applicaster/zapp-react-native-utils/screenState", () => ({
|
|
16
25
|
useScreenState: jest.fn(() => ({
|
|
@@ -27,36 +36,27 @@ describe("masterCellBuilder", () => {
|
|
|
27
36
|
describe("when using default options", () => {
|
|
28
37
|
const MasterCell = masterCellBuilder({ cellConfiguration: testCellStyle });
|
|
29
38
|
|
|
30
|
-
it("returns a function", () => {
|
|
31
|
-
expect(MasterCell).toMatchSnapshot();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
39
|
it("renders correctly", () => {
|
|
35
|
-
const wrapper =
|
|
36
|
-
<View>
|
|
40
|
+
const wrapper = renderWithProviders(
|
|
41
|
+
<View testID="master-cell">
|
|
37
42
|
<MasterCell item={entry} />
|
|
38
43
|
</View>
|
|
39
44
|
);
|
|
40
45
|
|
|
41
|
-
expect(
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("can be invoked as a React Component", () => {
|
|
45
|
-
const wrapper = shallow(<MasterCell item={entry} state={null} />);
|
|
46
|
-
|
|
47
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
46
|
+
expect(wrapper.getByTestId("master-cell").children[0]).toBeDefined();
|
|
48
47
|
});
|
|
49
48
|
});
|
|
50
49
|
|
|
51
|
-
describe("when using custom containerStyle", () => {
|
|
50
|
+
describe.skip("when using custom containerStyle", () => {
|
|
52
51
|
const MasterCell = masterCellBuilder({
|
|
53
52
|
cellConfiguration: singleView,
|
|
54
53
|
containerStyle: { backgroundColor: "black" },
|
|
55
54
|
});
|
|
56
55
|
|
|
57
56
|
it("renders correctly", () => {
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
renderWithProviders(<MasterCell item={entry} />);
|
|
58
|
+
|
|
59
|
+
// TODO define the test need
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -69,14 +69,14 @@ describe("masterCellBuilder", () => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it("renders correctly", () => {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
renderWithProviders(<MasterCell item={entry} />);
|
|
73
|
+
// TODO define the test need
|
|
74
74
|
|
|
75
75
|
expect(dataAdapter).toHaveBeenCalledWith(singleView);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
describe("when using custom default components", () => {
|
|
79
|
+
describe.skip("when using custom default components", () => {
|
|
80
80
|
// the collapsable prop is added here to easily check from the snapshot that the mock
|
|
81
81
|
// component is being used instead of the default one
|
|
82
82
|
const CustomView = jest.fn((props) => <View {...props} collapsable />);
|
|
@@ -88,8 +88,8 @@ describe("masterCellBuilder", () => {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it("renders correctly", () => {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
renderWithProviders(<MasterCell item={entry} />);
|
|
92
|
+
// TODO define the test need
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
});
|
|
@@ -16,13 +16,13 @@ export class MasterCellAsyncRenderManager {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
public emitAsyncElementRegistrate = () => {
|
|
19
|
-
this.asyncElementRegistrate$.next();
|
|
19
|
+
this.asyncElementRegistrate$.next(null);
|
|
20
20
|
|
|
21
21
|
return this.decrementAsyncElementRegistrationCount;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
public emitAsyncElementLayout = () => {
|
|
25
|
-
this.asyncElementLayout$.next();
|
|
25
|
+
this.asyncElementLayout$.next(null);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
public decrementAsyncElementRegistrationCount = () => {
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
2
|
+
import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageSingleSelectProvider";
|
|
3
|
+
import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
4
|
+
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
5
|
+
import React, { useEffect } from "react";
|
|
6
|
+
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
7
|
+
import { BehaviorSubject } from "rxjs";
|
|
8
|
+
import { masterCellLogger } from "../logger";
|
|
9
|
+
import get from "lodash/get";
|
|
10
|
+
|
|
11
|
+
const parseContextKey = (key: string): string | null => {
|
|
12
|
+
if (!key?.startsWith("@{ctx/")) return null;
|
|
13
|
+
|
|
14
|
+
return key.substring("@{ctx/".length, key.length - 1);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getDataSourceProvider = (
|
|
18
|
+
behavior: Behavior
|
|
19
|
+
): BehaviorSubject<string[] | string> | null => {
|
|
20
|
+
if (!behavior) return null;
|
|
21
|
+
|
|
22
|
+
const selection = String(behavior.current_selection);
|
|
23
|
+
const contextKey = parseContextKey(selection);
|
|
24
|
+
|
|
25
|
+
if (contextKey) {
|
|
26
|
+
if (behavior.select_mode === "multi") {
|
|
27
|
+
return StorageMultiSelectProvider.getProvider(contextKey).getObservable();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (behavior.select_mode === "single") {
|
|
31
|
+
return StorageSingleValueProvider.getProvider(contextKey).getObservable();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (behavior.selection_source === "@{push/topics}") {
|
|
36
|
+
return PushTopicManager.getInstance().getEntryObservable();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
43
|
+
const [lastUpdate, setLastUpdate] = React.useState<number | null>(null);
|
|
44
|
+
const player = usePlayer();
|
|
45
|
+
|
|
46
|
+
const triggerUpdate = () => setLastUpdate(Date.now());
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!behavior) return;
|
|
50
|
+
|
|
51
|
+
const dataSource = getDataSourceProvider(behavior);
|
|
52
|
+
|
|
53
|
+
if (dataSource) {
|
|
54
|
+
const subscription = dataSource.subscribe(triggerUpdate);
|
|
55
|
+
|
|
56
|
+
return () => subscription.unsubscribe();
|
|
57
|
+
}
|
|
58
|
+
}, [behavior]);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!behavior || !player || behavior.selection_source !== "now_playing") {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const subscription = player.getEntryObservable().subscribe(triggerUpdate);
|
|
66
|
+
|
|
67
|
+
return () => subscription.unsubscribe();
|
|
68
|
+
}, [behavior, player]);
|
|
69
|
+
|
|
70
|
+
return lastUpdate;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// We cant use async in this function (its inside render),
|
|
74
|
+
// so we rely on useBehaviorUpdate to update current value and trigger re-render
|
|
75
|
+
export const isCellSelected = (
|
|
76
|
+
item: ZappEntry,
|
|
77
|
+
behavior?: Behavior
|
|
78
|
+
): boolean => {
|
|
79
|
+
if (!behavior) return false;
|
|
80
|
+
|
|
81
|
+
const id = behavior.selector ? get(item, behavior.selector) : item.id;
|
|
82
|
+
|
|
83
|
+
if (behavior.selection_source === "now_playing") {
|
|
84
|
+
const player = playerManager.getActivePlayer();
|
|
85
|
+
|
|
86
|
+
return player?.entry?.id === id;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (behavior.selection_source === "@{push/topics}") {
|
|
90
|
+
if (behavior.select_mode === "single") {
|
|
91
|
+
masterCellLogger.warning(
|
|
92
|
+
"Unexpected single selection mode for push topics"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const tags = PushTopicManager.getInstance().getRegisteredTags();
|
|
97
|
+
|
|
98
|
+
return tags.includes(String(id));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const selection = String(behavior.current_selection);
|
|
102
|
+
const contextKey = parseContextKey(selection);
|
|
103
|
+
|
|
104
|
+
if (contextKey) {
|
|
105
|
+
if (behavior.select_mode === "single") {
|
|
106
|
+
const selectedItem =
|
|
107
|
+
StorageSingleValueProvider.getProvider(contextKey)?.getValue();
|
|
108
|
+
|
|
109
|
+
return selectedItem === String(id);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (behavior.select_mode === "multi") {
|
|
113
|
+
const selectedItems =
|
|
114
|
+
StorageMultiSelectProvider.getProvider(contextKey)?.getSelectedItems();
|
|
115
|
+
|
|
116
|
+
return selectedItems?.includes(String(id));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (behavior.select_mode === "single") {
|
|
121
|
+
return behavior.current_selection === id;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
behavior.select_mode === "multi" &&
|
|
126
|
+
Array.isArray(behavior.current_selection)
|
|
127
|
+
) {
|
|
128
|
+
const currentSelection: string[] = behavior.current_selection.map(
|
|
129
|
+
(item): string => String(item)
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return currentSelection.includes(String(id));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return false;
|
|
136
|
+
};
|