@applicaster/zapp-react-native-ui-components 14.0.0-alpha.6242515303 → 14.0.0-alpha.6391068513
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/AnimatedInOut/index.tsx +5 -3
- package/Components/AudioPlayer/mobile/Layout.tsx +1 -1
- package/Components/AudioPlayer/tv/helpers.tsx +10 -3
- package/Components/Cell/index.js +1 -1
- package/Components/ComponentResolver/index.ts +1 -1
- package/Components/FeedLoader/index.js +1 -1
- package/Components/Focusable/Focusable.tsx +5 -3
- package/Components/Focusable/FocusableTvOS.tsx +3 -3
- package/Components/Focusable/FocusableiOS.tsx +2 -2
- package/Components/Focusable/index.tsx +1 -1
- package/Components/FocusableList/index.tsx +4 -0
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +12 -8
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -8
- package/Components/Layout/TV/LayoutBackground.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
- package/Components/MasterCell/elementMapper.tsx +1 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
- package/Components/MasterCell/utils/index.ts +23 -3
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +20 -22
- package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +41 -28
- package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
- package/Components/PlayerContainer/index.ts +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
- package/Components/River/RefreshControl.tsx +6 -4
- package/Components/River/TV/River.tsx +2 -17
- package/Components/River/TV/index.tsx +3 -1
- package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
- package/Components/River/TV/withRiverDataLoader.tsx +17 -0
- package/Components/River/TV/withTVEventHandler.tsx +1 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +23 -12
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
- package/Components/ScreenRevealManager/index.ts +1 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
- package/Components/Tabs/TV/Tabs.android.tsx +0 -2
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
- package/Components/Transitioner/Scene.tsx +1 -0
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
- package/Components/VideoLive/animationUtils.ts +3 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -8
- package/Components/VideoModal/PlayerDetails.tsx +24 -2
- package/Components/VideoModal/PlayerWrapper.tsx +26 -142
- package/Components/VideoModal/VideoModal.tsx +3 -17
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
- package/Components/VideoModal/hooks/index.ts +0 -2
- package/Components/VideoModal/hooks/useModalSize.ts +18 -2
- package/Components/VideoModal/utils.ts +6 -0
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
- package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
- package/Decorators/RiverFeedLoader/index.tsx +8 -2
- package/Decorators/RiverFeedLoader/utils/index.ts +7 -2
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
- package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
- package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
- package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +255 -0
- package/Decorators/ZappPipesDataConnector/types.ts +29 -0
- package/Decorators/ZappPipesDataConnector/utils/index.ts +40 -0
- package/package.json +5 -6
- package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
|
@@ -8,6 +8,8 @@ import { masterCellLogger } from "../logger";
|
|
|
8
8
|
import { getCellState } from "../../Cell/utils";
|
|
9
9
|
import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
10
10
|
import { isCellSelected, useBehaviorUpdate } from "./behaviorProvider";
|
|
11
|
+
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
|
|
11
13
|
|
|
12
14
|
const hasElementSpecificViewType = (viewType) => (element) => {
|
|
13
15
|
if (R.isNil(element)) {
|
|
@@ -190,8 +192,18 @@ export const getFocusedButtonId = (focusable) => {
|
|
|
190
192
|
});
|
|
191
193
|
};
|
|
192
194
|
|
|
193
|
-
export const isSelected = (
|
|
194
|
-
|
|
195
|
+
export const isSelected = ({
|
|
196
|
+
item,
|
|
197
|
+
screenRoute,
|
|
198
|
+
screenStateStore,
|
|
199
|
+
behavior,
|
|
200
|
+
}: {
|
|
201
|
+
item: ZappEntry;
|
|
202
|
+
screenRoute: string;
|
|
203
|
+
screenStateStore: ScreenStateStore;
|
|
204
|
+
behavior?: Behavior;
|
|
205
|
+
}) => {
|
|
206
|
+
return isCellSelected({ item, screenRoute, screenStateStore, behavior });
|
|
195
207
|
};
|
|
196
208
|
|
|
197
209
|
export const useCellState = ({
|
|
@@ -204,9 +216,17 @@ export const useCellState = ({
|
|
|
204
216
|
focused: boolean;
|
|
205
217
|
}): CellState => {
|
|
206
218
|
const lastUpdate = useBehaviorUpdate(behavior);
|
|
219
|
+
const router = useRoute();
|
|
220
|
+
const screenStateStore = useScreenStateStore();
|
|
207
221
|
|
|
208
222
|
const _isSelected = useMemo(
|
|
209
|
-
() =>
|
|
223
|
+
() =>
|
|
224
|
+
isSelected({
|
|
225
|
+
item,
|
|
226
|
+
screenRoute: router?.pathname,
|
|
227
|
+
screenStateStore,
|
|
228
|
+
behavior,
|
|
229
|
+
}),
|
|
210
230
|
[behavior, item, lastUpdate]
|
|
211
231
|
);
|
|
212
232
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text, Animated } from "react-native";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
3
4
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
NotificationView,
|
|
7
|
+
onlinePhrase,
|
|
8
|
+
offlinePhrase,
|
|
9
|
+
} from "../NotificationView";
|
|
7
10
|
|
|
8
11
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
9
12
|
usePickFromState: () => ({
|
|
@@ -32,39 +35,31 @@ jest.mock("react-native-safe-area-context", () => ({
|
|
|
32
35
|
|
|
33
36
|
const dismiss = jest.fn();
|
|
34
37
|
|
|
35
|
-
const {
|
|
36
|
-
NotificationView,
|
|
37
|
-
onlinePhrase,
|
|
38
|
-
offlinePhrase,
|
|
39
|
-
} = require("../NotificationView");
|
|
40
|
-
|
|
41
38
|
describe("NotificationView", () => {
|
|
42
39
|
it("Show online message when Online", () => {
|
|
43
|
-
const component =
|
|
44
|
-
<NotificationView online dismiss={dismiss} />
|
|
45
|
-
);
|
|
40
|
+
const component = render(<NotificationView online dismiss={dismiss} />);
|
|
46
41
|
|
|
47
|
-
expect(component.
|
|
42
|
+
expect(component.UNSAFE_getByType(Text).props.children).toBe(onlinePhrase);
|
|
48
43
|
});
|
|
49
44
|
|
|
50
45
|
it("Show offline message when Online", () => {
|
|
51
|
-
const component =
|
|
46
|
+
const component = render(
|
|
52
47
|
<NotificationView online={false} dismiss={dismiss} />
|
|
53
48
|
);
|
|
54
49
|
|
|
55
|
-
expect(component.
|
|
50
|
+
expect(component.UNSAFE_getByType(Text).props.children).toBe(offlinePhrase);
|
|
56
51
|
});
|
|
57
52
|
|
|
58
53
|
it("When hidden is false to true notification is visible", () => {
|
|
59
|
-
const component =
|
|
54
|
+
const component = render(
|
|
60
55
|
<NotificationView online={false} hidden={false} dismiss={dismiss} />
|
|
61
56
|
);
|
|
62
57
|
|
|
63
|
-
component.
|
|
58
|
+
component.rerender(
|
|
64
59
|
<NotificationView online={false} hidden={true} dismiss={dismiss} />
|
|
65
60
|
);
|
|
66
61
|
|
|
67
|
-
const animatedView = component.
|
|
62
|
+
const animatedView = component.UNSAFE_getByType(Animated.View);
|
|
68
63
|
const animatedViewStyles = animatedView.props.style;
|
|
69
64
|
|
|
70
65
|
expect(animatedViewStyles.opacity).toBe(1);
|
|
@@ -21,6 +21,15 @@ exports[`OfflineHandler renders 1`] = `
|
|
|
21
21
|
}
|
|
22
22
|
>
|
|
23
23
|
<View
|
|
24
|
+
accessibilityState={
|
|
25
|
+
{
|
|
26
|
+
"busy": undefined,
|
|
27
|
+
"checked": undefined,
|
|
28
|
+
"disabled": undefined,
|
|
29
|
+
"expanded": undefined,
|
|
30
|
+
"selected": undefined,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
accessible={true}
|
|
25
34
|
collapsable={false}
|
|
26
35
|
focusable={true}
|
|
@@ -19,29 +19,27 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/utils", () => {
|
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
jest.mock(
|
|
23
|
-
"@applicaster/zapp-react-native-redux/hooks
|
|
24
|
-
() => ({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
22
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
23
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
|
|
24
|
+
usePickFromState: () => ({
|
|
25
|
+
plugins: [
|
|
26
|
+
{
|
|
27
|
+
name: "offline experience",
|
|
28
|
+
identifier: "offline-experience",
|
|
29
|
+
type: "general",
|
|
30
|
+
module: {
|
|
31
|
+
useOfflineExperienceConfiguration: () => ({
|
|
32
|
+
configurationFields: {},
|
|
33
|
+
localizations: {
|
|
34
|
+
offline_toast_message: "No internet connection",
|
|
35
|
+
online_toast_message: "You are back online",
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
40
38
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
);
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
}));
|
|
45
43
|
|
|
46
44
|
jest.mock("react-native-safe-area-context", () => ({
|
|
47
45
|
useSafeAreaInsets: () => ({ top: 44 }),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useEffect, useReducer } from "react";
|
|
3
|
-
|
|
4
|
-
import { TVMenuControl, View, ViewStyle } from "react-native";
|
|
3
|
+
import { View, ViewStyle } from "react-native";
|
|
5
4
|
import * as R from "ramda";
|
|
6
5
|
import uuid from "uuid/v4";
|
|
7
6
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
|
|
@@ -62,6 +61,11 @@ import {
|
|
|
62
61
|
useModalAnimationContext,
|
|
63
62
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
64
63
|
|
|
64
|
+
import {
|
|
65
|
+
PlayerNativeCommandTypes,
|
|
66
|
+
PlayerNativeSendCommand,
|
|
67
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerNativeCommand";
|
|
68
|
+
|
|
65
69
|
type Props = {
|
|
66
70
|
Player: React.ComponentType<any>;
|
|
67
71
|
PlayerLoadingView?: React.ComponentType<any>; // 👀 we are not receiving this prop
|
|
@@ -88,7 +92,7 @@ export const VideoModalMode = {
|
|
|
88
92
|
MAXIMIZED: "MAXIMIZED",
|
|
89
93
|
MINIMIZED: "MINIMIZED",
|
|
90
94
|
FULLSCREEN: "FULLSCREEN",
|
|
91
|
-
};
|
|
95
|
+
} as const;
|
|
92
96
|
|
|
93
97
|
export type PlayNextData = {
|
|
94
98
|
state: PlayNextState;
|
|
@@ -127,7 +131,7 @@ const webStyles = {
|
|
|
127
131
|
playerScreen: {
|
|
128
132
|
flex: 1,
|
|
129
133
|
height: "100vh",
|
|
130
|
-
|
|
134
|
+
backgroundColor: "black",
|
|
131
135
|
},
|
|
132
136
|
playerWrapper: {
|
|
133
137
|
height: "100%",
|
|
@@ -145,7 +149,6 @@ const nativeStyles = {
|
|
|
145
149
|
},
|
|
146
150
|
playerScreen: {
|
|
147
151
|
flex: 1,
|
|
148
|
-
backgroundColor: "black",
|
|
149
152
|
overflow: "hidden",
|
|
150
153
|
},
|
|
151
154
|
playerWrapper: {
|
|
@@ -260,9 +263,15 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
260
263
|
return;
|
|
261
264
|
}
|
|
262
265
|
|
|
266
|
+
// send command to clear and stop player
|
|
267
|
+
PlayerNativeSendCommand(
|
|
268
|
+
PlayerNativeCommandTypes.clearPlayerData,
|
|
269
|
+
state.playerId
|
|
270
|
+
);
|
|
271
|
+
|
|
263
272
|
showNavBar(true);
|
|
264
273
|
navigator.goBack();
|
|
265
|
-
}, [isModal, navigator.goBack, showNavBar]);
|
|
274
|
+
}, [isModal, navigator.goBack, state.playerId, showNavBar]);
|
|
266
275
|
|
|
267
276
|
const playEntry = (entry) => navigator.replaceTop(entry, { mode });
|
|
268
277
|
|
|
@@ -390,13 +399,17 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
390
399
|
}
|
|
391
400
|
};
|
|
392
401
|
|
|
393
|
-
const playerRemoteHandler = (
|
|
394
|
-
|
|
402
|
+
const playerRemoteHandler = React.useCallback(
|
|
403
|
+
(isLanguageOverlayVisible = false) =>
|
|
404
|
+
(event) => {
|
|
405
|
+
const { eventType } = event;
|
|
395
406
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
407
|
+
if (!isLanguageOverlayVisible && eventType === "menu") {
|
|
408
|
+
close();
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
[close]
|
|
412
|
+
);
|
|
400
413
|
|
|
401
414
|
// Effects
|
|
402
415
|
useEffect(() => {
|
|
@@ -509,16 +522,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
509
522
|
}
|
|
510
523
|
}, [isAudioContent]);
|
|
511
524
|
|
|
512
|
-
// Needs to handle back button on Apple TV
|
|
513
|
-
// https://github.com/facebook/react-native/issues/18930
|
|
514
|
-
useEffect(() => {
|
|
515
|
-
TVMenuControl?.enableTVMenuKey();
|
|
516
|
-
|
|
517
|
-
return () => {
|
|
518
|
-
TVMenuControl?.disableTVMenuKey();
|
|
519
|
-
};
|
|
520
|
-
}, []);
|
|
521
|
-
|
|
522
525
|
useEffect(() => {
|
|
523
526
|
playerEvent("source_changed", { item });
|
|
524
527
|
|
|
@@ -565,8 +568,9 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
565
568
|
const isInlineTV = isInlineTVUtil(screenData);
|
|
566
569
|
|
|
567
570
|
const inline =
|
|
568
|
-
[VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(
|
|
569
|
-
|
|
571
|
+
[VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(
|
|
572
|
+
mode as any
|
|
573
|
+
) || isInlineTV;
|
|
570
574
|
|
|
571
575
|
const value = React.useMemo(
|
|
572
576
|
() => ({ playerId: state.playerId }),
|
|
@@ -587,7 +591,11 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
587
591
|
);
|
|
588
592
|
}
|
|
589
593
|
|
|
590
|
-
if (
|
|
594
|
+
if (
|
|
595
|
+
screen_background_color &&
|
|
596
|
+
mode !== VideoModalMode.FULLSCREEN &&
|
|
597
|
+
isTV()
|
|
598
|
+
) {
|
|
591
599
|
updatedStyles.playerScreen.backgroundColor = screen_background_color;
|
|
592
600
|
}
|
|
593
601
|
|
|
@@ -617,6 +625,8 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
617
625
|
playNextData,
|
|
618
626
|
};
|
|
619
627
|
|
|
628
|
+
const pointerEventsProp = mode === "MINIMIZED" ? "box-none" : "auto";
|
|
629
|
+
|
|
620
630
|
return (
|
|
621
631
|
<PlayerStateContext.Provider value={value}>
|
|
622
632
|
<PlayerContainerContextProvider
|
|
@@ -627,9 +637,9 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
627
637
|
<PlayerContainerContext.Consumer>
|
|
628
638
|
{(context) => (
|
|
629
639
|
<TVEventHandlerComponent
|
|
630
|
-
tvEventHandler={(
|
|
631
|
-
|
|
632
|
-
}
|
|
640
|
+
tvEventHandler={playerRemoteHandler(
|
|
641
|
+
context.isLanguageOverlayVisible
|
|
642
|
+
)}
|
|
633
643
|
>
|
|
634
644
|
<FocusableGroup
|
|
635
645
|
id={FocusableGroupMainContainerId}
|
|
@@ -637,14 +647,17 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
637
647
|
preferredFocus
|
|
638
648
|
shouldUsePreferredFocus
|
|
639
649
|
groupId={groupId}
|
|
650
|
+
pointerEvents={pointerEventsProp}
|
|
640
651
|
>
|
|
641
652
|
{/* Video player and components */}
|
|
642
653
|
<View
|
|
643
654
|
style={styles.playerScreen}
|
|
644
655
|
testID={"player-screen-container"}
|
|
656
|
+
pointerEvents={pointerEventsProp}
|
|
645
657
|
>
|
|
646
658
|
{/* Player container */}
|
|
647
659
|
<View
|
|
660
|
+
pointerEvents={pointerEventsProp}
|
|
648
661
|
style={[
|
|
649
662
|
styles.playerWrapper,
|
|
650
663
|
// eslint-disable-next-line react-native/no-inline-styles, react-native/no-color-literals
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
1
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
2
2
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
3
|
import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
|
|
4
4
|
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
5
|
|
|
6
6
|
import { PlayerContainer as PlayerContainerComponent } from "./PlayerContainer";
|
|
@@ -10,11 +10,13 @@ import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/locali
|
|
|
10
10
|
import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
11
11
|
import { useSendAnalyticsEventWithFunction } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
|
|
12
12
|
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData";
|
|
13
|
-
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
14
|
-
import { useDispatch } from "react-redux";
|
|
15
13
|
import { useShallow } from "zustand/react/shallow";
|
|
16
14
|
import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
17
15
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
16
|
+
import {
|
|
17
|
+
ZappPipes,
|
|
18
|
+
useAppDispatch,
|
|
19
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
18
20
|
|
|
19
21
|
const BRIGHTNESS_THRESHOLD = 160;
|
|
20
22
|
const ABOVE_DEFAULT_COLOR = "gray";
|
|
@@ -61,7 +63,7 @@ export const usePullToRefresh = (
|
|
|
61
63
|
) => {
|
|
62
64
|
const isPipesV1 = !!pullToRefreshPipesV1RefreshingStateUpdater;
|
|
63
65
|
|
|
64
|
-
const dispatch =
|
|
66
|
+
const dispatch = useAppDispatch();
|
|
65
67
|
|
|
66
68
|
const [refreshing, setRefreshing] = React.useState(false);
|
|
67
69
|
|
|
@@ -81,7 +83,7 @@ export const usePullToRefresh = (
|
|
|
81
83
|
if (refreshing && !isPipesV1) {
|
|
82
84
|
feeds.forEach((feed) => {
|
|
83
85
|
dispatch(
|
|
84
|
-
loadPipesData(feed, {
|
|
86
|
+
ZappPipes.loadPipesData(feed, {
|
|
85
87
|
silentRefresh: true,
|
|
86
88
|
clearCache: true,
|
|
87
89
|
callback: () => {
|
|
@@ -4,10 +4,6 @@ import * as React from "react";
|
|
|
4
4
|
import { Text } from "react-native";
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
useFeedLoader,
|
|
9
|
-
useLayoutVersion,
|
|
10
|
-
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
11
7
|
import { GeneralContentScreen } from "../../GeneralContentScreen";
|
|
12
8
|
import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
|
|
13
9
|
import { utilsLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
@@ -21,6 +17,7 @@ type Props = {
|
|
|
21
17
|
screenId: string;
|
|
22
18
|
screenData: ZappRiver | ZappEntry;
|
|
23
19
|
feedUrl?: string;
|
|
20
|
+
feedData?: PipesDataObject["data"];
|
|
24
21
|
extraProps?: any;
|
|
25
22
|
screenResolverExtraProps?: any;
|
|
26
23
|
componentsMapExtraProps?: any;
|
|
@@ -32,7 +29,7 @@ type Props = {
|
|
|
32
29
|
export const River = (props: Props) => {
|
|
33
30
|
const {
|
|
34
31
|
screenId,
|
|
35
|
-
|
|
32
|
+
feedData,
|
|
36
33
|
extraProps,
|
|
37
34
|
screenResolverExtraProps,
|
|
38
35
|
componentsMapExtraProps,
|
|
@@ -46,7 +43,6 @@ export const River = (props: Props) => {
|
|
|
46
43
|
useSetNavbarState();
|
|
47
44
|
|
|
48
45
|
const rivers = useRivers();
|
|
49
|
-
const isV2 = useLayoutVersion({ isV2: true });
|
|
50
46
|
|
|
51
47
|
const river = React.useMemo(() => rivers?.[screenId], [screenId]);
|
|
52
48
|
|
|
@@ -55,17 +51,6 @@ export const River = (props: Props) => {
|
|
|
55
51
|
[screenId]
|
|
56
52
|
);
|
|
57
53
|
|
|
58
|
-
const connectedScreenUrl = React.useMemo(() => {
|
|
59
|
-
// Avoid using feedUrl or content.src on layouts v2
|
|
60
|
-
if (isV2) return null;
|
|
61
|
-
|
|
62
|
-
return feedUrl || R.path(["content", "src"], screenData);
|
|
63
|
-
}, [feedUrl, screenData]);
|
|
64
|
-
|
|
65
|
-
const { data: feedData } = useFeedLoader({
|
|
66
|
-
feedUrl: connectedScreenUrl,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
54
|
const stringOrEmpty = (value: string | number | undefined): string =>
|
|
70
55
|
R.isNil(value) ? "" : String(value);
|
|
71
56
|
|
|
@@ -2,8 +2,10 @@ import { compose } from "ramda";
|
|
|
2
2
|
import { River as RiverComponent } from "./River";
|
|
3
3
|
import { withTvEventHandler } from "./withTVEventHandler";
|
|
4
4
|
import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
|
|
5
|
+
import { withRiverDataLoader } from "./withRiverDataLoader";
|
|
5
6
|
|
|
6
7
|
export const River = compose(
|
|
7
8
|
withTvEventHandler,
|
|
8
|
-
withComponentsMapOffsetContext
|
|
9
|
+
withComponentsMapOffsetContext,
|
|
10
|
+
withRiverDataLoader
|
|
9
11
|
)(RiverComponent);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { path } from "ramda";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
useFeedLoader,
|
|
6
|
+
useRivers,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
screenId: string;
|
|
11
|
+
screenData: ZappRiver | ZappEntry;
|
|
12
|
+
feedUrl?: string;
|
|
13
|
+
river?: ZappRiver | ZappEntry;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const withPipesV1DataLoader = (
|
|
17
|
+
WrappedComponent: React.ComponentType<any>
|
|
18
|
+
) => {
|
|
19
|
+
return function WithPipesV1DataLoaderComponent(props: Props) {
|
|
20
|
+
const { screenId, feedUrl } = props;
|
|
21
|
+
|
|
22
|
+
const rivers = useRivers();
|
|
23
|
+
|
|
24
|
+
const river = React.useMemo(() => rivers?.[screenId], [screenId]);
|
|
25
|
+
|
|
26
|
+
const screenData = React.useMemo(
|
|
27
|
+
() => props.screenData || props.river || river,
|
|
28
|
+
[screenId]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const connectedScreenUrl = useMemo(() => {
|
|
32
|
+
// Avoid using feedUrl or content.src on layouts v2
|
|
33
|
+
|
|
34
|
+
return feedUrl || path(["content", "src"], screenData);
|
|
35
|
+
}, [feedUrl, screenData]);
|
|
36
|
+
|
|
37
|
+
const { data: feedData } = useFeedLoader({
|
|
38
|
+
feedUrl: connectedScreenUrl,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return <WrappedComponent {...props} feedData={feedData} />;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useLayoutVersion } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { withPipesV1DataLoader } from "./withPipesV1DataLoader";
|
|
4
|
+
|
|
5
|
+
export const withRiverDataLoader = (
|
|
6
|
+
WrappedComponent: React.ComponentType<any>
|
|
7
|
+
) => {
|
|
8
|
+
return function WithRiverDataLoaderComponent(props) {
|
|
9
|
+
const isV2 = useLayoutVersion({ isV2: true });
|
|
10
|
+
|
|
11
|
+
if (isV2) {
|
|
12
|
+
return <WrappedComponent {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return withPipesV1DataLoader(WrappedComponent)(props);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -8,7 +8,7 @@ export const withTvEventHandler = (Component) => {
|
|
|
8
8
|
return function WithTVEventHandler(props) {
|
|
9
9
|
const navigator = useNavigation();
|
|
10
10
|
|
|
11
|
-
const remoteHandler = (
|
|
11
|
+
const remoteHandler = (event) => {
|
|
12
12
|
const { eventType } = event;
|
|
13
13
|
|
|
14
14
|
const canGoBack = navigator.canGoBack();
|
|
@@ -159,6 +159,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
159
159
|
>
|
|
160
160
|
<View>
|
|
161
161
|
<View
|
|
162
|
+
onFocusCapture={[Function]}
|
|
162
163
|
onLayout={[Function]}
|
|
163
164
|
style={null}
|
|
164
165
|
>
|
|
@@ -174,6 +175,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
174
175
|
</View>
|
|
175
176
|
</View>
|
|
176
177
|
<View
|
|
178
|
+
onFocusCapture={[Function]}
|
|
177
179
|
onLayout={[Function]}
|
|
178
180
|
style={null}
|
|
179
181
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
2
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
3
3
|
|
|
4
4
|
import { withRiver } from "../../Decorators/RiverResolver";
|
|
5
5
|
import { withNavigator } from "../../Decorators/Navigator";
|
|
@@ -68,12 +68,33 @@ jest.mock(
|
|
|
68
68
|
})
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
+
jest.mock(
|
|
72
|
+
"@applicaster/zapp-react-native-utils/reactHooks/state/useRivers",
|
|
73
|
+
() => ({
|
|
74
|
+
useRivers: jest.fn(() => ({
|
|
75
|
+
rivers: [{ id: "testId", name: "Test River" }],
|
|
76
|
+
})),
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
|
|
71
80
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
72
81
|
isNavBarVisible: mockIsNavBarVisible,
|
|
73
82
|
useIsScreenActive: jest.fn().mockReturnValue(true),
|
|
83
|
+
useNavigation: jest.fn(() => ({
|
|
84
|
+
canGoBack: () => false,
|
|
85
|
+
currentRoute: "/river/testId",
|
|
86
|
+
activeRiver: { id: "testId" },
|
|
87
|
+
screenData: { id: "testId" },
|
|
88
|
+
data: { screen: { id: "testId" } },
|
|
89
|
+
})),
|
|
90
|
+
useRoute: jest.fn(() => ({
|
|
91
|
+
pathname: "/river/testId",
|
|
92
|
+
screenData: { id: "testId" },
|
|
93
|
+
})),
|
|
74
94
|
}));
|
|
75
95
|
|
|
76
96
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
97
|
+
...jest.requireActual("@applicaster/zapp-react-native-utils/reactHooks"),
|
|
77
98
|
useCurrentScreenData: jest.fn(() => ({
|
|
78
99
|
id: "testId",
|
|
79
100
|
})),
|
|
@@ -84,17 +105,6 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
|
84
105
|
id: "testId",
|
|
85
106
|
navigations: [{ id: "testId", category: "nav_bar" }],
|
|
86
107
|
})),
|
|
87
|
-
useNavigation: jest.fn(() => ({
|
|
88
|
-
canGoBack: () => false,
|
|
89
|
-
currentRoute: "/river/testId",
|
|
90
|
-
activeRiver: { id: "testId" },
|
|
91
|
-
screenData: { id: "testId" },
|
|
92
|
-
data: { screen: { id: "testId" } },
|
|
93
|
-
})),
|
|
94
|
-
useRoute: jest.fn(() => ({
|
|
95
|
-
pathname: "/river/testId",
|
|
96
|
-
screenData: { id: "testId" },
|
|
97
|
-
})),
|
|
98
108
|
useDimensions: jest.fn(() => ({
|
|
99
109
|
width: 1920,
|
|
100
110
|
height: 1080,
|
|
@@ -102,10 +112,11 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
|
102
112
|
useIsTablet: jest.fn(() => false),
|
|
103
113
|
}));
|
|
104
114
|
|
|
105
|
-
jest.mock("@applicaster/zapp-react-native-redux/hooks
|
|
115
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => {
|
|
106
116
|
const View = jest.requireActual("react-native").View;
|
|
107
117
|
|
|
108
118
|
return {
|
|
119
|
+
...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
|
|
109
120
|
usePickFromState: () => ({
|
|
110
121
|
plugins: [
|
|
111
122
|
{
|