@applicaster/zapp-react-native-ui-components 13.0.0-alpha.1124981321 → 13.0.0-alpha.1173186260
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 -4
- 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 -1
- package/Components/BaseFocusable/index.tsx +1 -2
- package/Components/Cell/Cell.tsx +4 -13
- package/Components/Cell/CellWithFocusable.tsx +50 -59
- package/Components/Cell/CellWrapper.tsx +18 -0
- package/Components/Cell/TvOSCellComponent.tsx +20 -22
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/Cell/index.js +3 -1
- package/Components/Cell/styles.ts +17 -0
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/CellRendererResolver/index.ts +2 -1
- 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 +14 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/FocusableTvOS.tsx +5 -1
- 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/FocusableList/index.tsx +26 -9
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +4 -2
- package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
- package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
- package/Components/Layout/TV/LayoutBackground.tsx +28 -0
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/ScreenContainer.tsx +8 -2
- 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 +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
- package/Components/Layout/TV/__tests__/index.test.tsx +8 -2
- package/Components/Layout/TV/index.tsx +6 -20
- package/Components/Layout/TV/index.web.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +4 -3
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
- 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 +8 -134
- package/Components/ModalComponent/BottomSheetModalContent.tsx +59 -43
- package/Components/ModalComponent/Button/Item.tsx +6 -5
- package/Components/ModalComponent/Button/assets.ts +1 -1
- package/Components/ModalComponent/Button/index.tsx +45 -62
- package/Components/ModalComponent/Header/index.tsx +12 -11
- package/Components/ModalComponent/utils.ts +55 -7
- 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 +42 -15
- 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 +39 -3
- package/Components/River/TV/index.tsx +6 -1
- 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 +3 -4
- 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/__tests__/index.web.test.tsx +26 -0
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/__tests__/Screen.test.tsx +22 -14
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -2
- package/Components/Screen/hooks.ts +3 -6
- package/Components/Screen/index.tsx +4 -4
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +5 -3
- package/Components/TextInputTv/index.tsx +2 -1
- package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +1 -1
- 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 +12 -68
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +7 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +46 -30
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +45 -21
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +12 -6
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
- package/Components/VideoModal/ModalAnimation/const.ts +5 -0
- package/Components/VideoModal/ModalAnimation/index.ts +2 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +30 -0
- package/Components/VideoModal/PlayerDetails.tsx +18 -10
- package/Components/VideoModal/PlayerWrapper.tsx +37 -24
- package/Components/VideoModal/VideoModal.tsx +19 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
- package/Components/VideoModal/utils.ts +3 -4
- 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 +4 -17
- 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 +49 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +3 -10
- 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__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +4 -30
- package/package.json +7 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
- package/Components/Cell/CellStyles/Hero/index.js +0 -111
- package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
- package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
- package/Components/Cell/CellStyles/colors.js +0 -40
- package/Components/Cell/CellStyles/index.js +0 -15
- 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
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { useEffect, useReducer } from "react";
|
|
2
3
|
// @ts-ignore
|
|
3
|
-
import { View, ViewStyle
|
|
4
|
+
import { TVMenuControl, View, ViewStyle } from "react-native";
|
|
4
5
|
import * as R from "ramda";
|
|
5
6
|
import uuid from "uuid/v4";
|
|
6
7
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
|
|
7
8
|
import {
|
|
8
9
|
isApplePlatform,
|
|
9
|
-
platformSelect,
|
|
10
10
|
isTV,
|
|
11
|
+
platformSelect,
|
|
12
|
+
isAndroidTVPlatform,
|
|
11
13
|
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
12
14
|
|
|
13
15
|
import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
|
|
14
|
-
import { useEffect, useReducer } from "react";
|
|
15
16
|
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
16
17
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
17
18
|
import {
|
|
@@ -29,10 +30,10 @@ import {
|
|
|
29
30
|
import { ProgramInfo } from "./ProgramInfo";
|
|
30
31
|
import { AudioPlayer } from "../AudioPlayer";
|
|
31
32
|
import {
|
|
32
|
-
playerContainerLogger,
|
|
33
33
|
log_debug,
|
|
34
34
|
log_info,
|
|
35
35
|
log_warning,
|
|
36
|
+
playerContainerLogger,
|
|
36
37
|
} from "./logger";
|
|
37
38
|
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
38
39
|
import { useSetNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
@@ -53,8 +54,8 @@ import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtil
|
|
|
53
54
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
54
55
|
|
|
55
56
|
import {
|
|
56
|
-
useModalAnimationContext,
|
|
57
57
|
PlayerAnimationStateEnum,
|
|
58
|
+
useModalAnimationContext,
|
|
58
59
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
59
60
|
|
|
60
61
|
type Props = {
|
|
@@ -93,6 +94,20 @@ export type PlayNextData = {
|
|
|
93
94
|
|
|
94
95
|
const focusableBottomContainerId = "player-container-bottom";
|
|
95
96
|
|
|
97
|
+
const isAndroidTV = isAndroidTVPlatform();
|
|
98
|
+
|
|
99
|
+
const withBorderHack = () => {
|
|
100
|
+
if (isAndroidTV) {
|
|
101
|
+
/* @HACK: see GH#7269 */
|
|
102
|
+
return {
|
|
103
|
+
borderWidth: 1,
|
|
104
|
+
borderColor: "transparent",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {};
|
|
109
|
+
};
|
|
110
|
+
|
|
96
111
|
// Styles
|
|
97
112
|
const webStyles = {
|
|
98
113
|
focusableGroup: {
|
|
@@ -335,9 +350,9 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
335
350
|
|
|
336
351
|
const resumeTime = Number(item?.extensions?.resumeTime);
|
|
337
352
|
|
|
338
|
-
//
|
|
353
|
+
// Сhecking that the player itself knows where to start playing, and there is no need to call seekTo after returning from the Сhromecast
|
|
339
354
|
if (
|
|
340
|
-
|
|
355
|
+
!playerManager.getActivePlayer()?.hasResumePosition() &&
|
|
341
356
|
!isNaN(resumeTime)
|
|
342
357
|
) {
|
|
343
358
|
player?.seekTo(resumeTime);
|
|
@@ -514,6 +529,12 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
514
529
|
useEffect(() => {
|
|
515
530
|
playerEvent("source_changed", { item });
|
|
516
531
|
|
|
532
|
+
return () => {
|
|
533
|
+
playerEvent("player_did_close", { item });
|
|
534
|
+
};
|
|
535
|
+
}, [item?.id, Player]);
|
|
536
|
+
|
|
537
|
+
useEffect(() => {
|
|
517
538
|
if (!isModal) {
|
|
518
539
|
showNavBar(false);
|
|
519
540
|
}
|
|
@@ -523,13 +544,11 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
523
544
|
}
|
|
524
545
|
|
|
525
546
|
return () => {
|
|
526
|
-
playerEvent("player_did_close", { item });
|
|
527
|
-
|
|
528
547
|
if (!isModal) {
|
|
529
548
|
showNavBar(true);
|
|
530
549
|
}
|
|
531
550
|
};
|
|
532
|
-
}, [showNavBar,
|
|
551
|
+
}, [showNavBar, isModal, Player]);
|
|
533
552
|
|
|
534
553
|
useEffect(() => {
|
|
535
554
|
if (prevItemId && !R.equals(prevItemId, item?.id)) {
|
|
@@ -578,7 +597,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
578
597
|
);
|
|
579
598
|
}
|
|
580
599
|
|
|
581
|
-
if (screen_background_color) {
|
|
600
|
+
if (screen_background_color && mode !== VideoModalMode.FULLSCREEN) {
|
|
582
601
|
updatedStyles.playerScreen.backgroundColor = screen_background_color;
|
|
583
602
|
}
|
|
584
603
|
|
|
@@ -596,6 +615,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
596
615
|
tv_component_container_height,
|
|
597
616
|
screen_background_color,
|
|
598
617
|
isInlineTV,
|
|
618
|
+
mode,
|
|
599
619
|
]);
|
|
600
620
|
|
|
601
621
|
const applePlayerProps = {
|
|
@@ -640,7 +660,14 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
640
660
|
testID={"player-screen-container"}
|
|
641
661
|
>
|
|
642
662
|
{/* Player container */}
|
|
643
|
-
<View
|
|
663
|
+
<View
|
|
664
|
+
style={[
|
|
665
|
+
styles.playerWrapper,
|
|
666
|
+
// eslint-disable-next-line react-native/no-inline-styles, react-native/no-color-literals
|
|
667
|
+
withBorderHack(),
|
|
668
|
+
]}
|
|
669
|
+
testID={"player-wrapper"}
|
|
670
|
+
>
|
|
644
671
|
<PlayerFocusableWrapperView
|
|
645
672
|
nextFocusDown={context.bottomFocusableId}
|
|
646
673
|
>
|
|
@@ -683,10 +710,10 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
683
710
|
|
|
684
711
|
{renderRestPlayers(restPlayerProps)}
|
|
685
712
|
|
|
686
|
-
{state.error
|
|
713
|
+
{state.error ? <ErrorDisplay error={state.error} /> : null}
|
|
687
714
|
</View>
|
|
688
715
|
{/* Components container */}
|
|
689
|
-
{isInlineTV && context.showComponentsContainer
|
|
716
|
+
{isInlineTV && context.showComponentsContainer ? (
|
|
690
717
|
<View
|
|
691
718
|
style={styles.inlineRiver}
|
|
692
719
|
testID={"inline-river-component-wrapper"}
|
|
@@ -717,7 +744,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
717
744
|
)}
|
|
718
745
|
</ComponentFocusableWrapperView>
|
|
719
746
|
</View>
|
|
720
|
-
)}
|
|
747
|
+
) : null}
|
|
721
748
|
</View>
|
|
722
749
|
</FocusableGroup>
|
|
723
750
|
</TVEventHandlerComponent>
|
|
@@ -114,12 +114,12 @@ function ProgramInfoComponent({
|
|
|
114
114
|
return (
|
|
115
115
|
<View style={container}>
|
|
116
116
|
<View style={programStyles.programInfo.container}>
|
|
117
|
-
{logo
|
|
117
|
+
{logo ? (
|
|
118
118
|
<Image
|
|
119
119
|
source={{ uri: logo }}
|
|
120
120
|
style={programStyles.programInfo.logo}
|
|
121
121
|
/>
|
|
122
|
-
)}
|
|
122
|
+
) : null}
|
|
123
123
|
{!isAudioContent && transportInfo}
|
|
124
124
|
</View>
|
|
125
125
|
</View>
|
|
@@ -34,6 +34,7 @@ type Props = {
|
|
|
34
34
|
getStaticComponentFeed: any;
|
|
35
35
|
pullToRefreshPipesV1RefreshingStateUpdater: () => boolean;
|
|
36
36
|
refreshingPipesV1?: boolean;
|
|
37
|
+
stickyHeaderIndices?: number[];
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
const styles = StyleSheet.create({
|
|
@@ -61,6 +62,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
61
62
|
// TODO: Remove when pipes v1 is deprecated.
|
|
62
63
|
pullToRefreshPipesV1RefreshingStateUpdater,
|
|
63
64
|
refreshingPipesV1,
|
|
65
|
+
stickyHeaderIndices,
|
|
64
66
|
} = props;
|
|
65
67
|
|
|
66
68
|
const flatListRef = React.useRef<FlatList | null>(null);
|
|
@@ -70,21 +72,6 @@ function ComponentsMapComponent(props: Props) {
|
|
|
70
72
|
|
|
71
73
|
const [flatListHeight, setFlatListHeight] = React.useState(null);
|
|
72
74
|
|
|
73
|
-
const {
|
|
74
|
-
isAnyLoading,
|
|
75
|
-
isAllLoaded,
|
|
76
|
-
waitForAllComponents,
|
|
77
|
-
onLoadFinished,
|
|
78
|
-
onLoadFailed,
|
|
79
|
-
shouldShowLoadingError,
|
|
80
|
-
isAnyLoaded,
|
|
81
|
-
arePreviousComponentsLoaded,
|
|
82
|
-
} = useLoadingState(feed?.entry?.length || components.length);
|
|
83
|
-
|
|
84
|
-
const theme = useTheme();
|
|
85
|
-
|
|
86
|
-
const logTimestamp = useProfilerLogging();
|
|
87
|
-
|
|
88
75
|
const riverComponents = React.useMemo(() => {
|
|
89
76
|
if (feed?.entry?.length < components.length) {
|
|
90
77
|
return R.slice(0, feed?.entry?.length, components);
|
|
@@ -93,55 +80,42 @@ function ComponentsMapComponent(props: Props) {
|
|
|
93
80
|
return components;
|
|
94
81
|
}, [components, feed]);
|
|
95
82
|
|
|
83
|
+
const logTimestamp = useProfilerLogging();
|
|
84
|
+
|
|
85
|
+
const onLoadDone = React.useCallback(() => {
|
|
86
|
+
logTimestamp(riverId?.toString());
|
|
87
|
+
}, [logTimestamp]);
|
|
88
|
+
|
|
89
|
+
const { loadingState, onLoadFinished, onLoadFailed, shouldShowLoadingError } =
|
|
90
|
+
useLoadingState(riverComponents.length, onLoadDone);
|
|
91
|
+
|
|
92
|
+
const theme = useTheme();
|
|
93
|
+
|
|
96
94
|
const renderRiverItem = React.useCallback(
|
|
97
95
|
({ item, index }) => {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
const riverItemProps = {
|
|
97
|
+
riverId,
|
|
98
|
+
item,
|
|
99
|
+
index,
|
|
100
|
+
isScreenWrappedInContainer,
|
|
101
|
+
feed,
|
|
102
|
+
groupId,
|
|
103
|
+
onLoadFailed,
|
|
104
|
+
onLoadFinished,
|
|
105
|
+
getStaticComponentFeed,
|
|
106
|
+
isLast: isLast(index, riverComponents.length),
|
|
107
|
+
loadingState,
|
|
102
108
|
};
|
|
103
109
|
|
|
104
110
|
return (
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
{...{
|
|
109
|
-
readyToBeDisplayed,
|
|
110
|
-
riverId,
|
|
111
|
-
item,
|
|
112
|
-
index,
|
|
113
|
-
isScreenWrappedInContainer,
|
|
114
|
-
feed,
|
|
115
|
-
groupId,
|
|
116
|
-
onLoadFailed,
|
|
117
|
-
onLoadFinished,
|
|
118
|
-
getStaticComponentFeed,
|
|
119
|
-
isLast: isLast(index, riverComponents.length),
|
|
120
|
-
}}
|
|
121
|
-
/>
|
|
122
|
-
</ScreenLoadingMeasurementsListItemWrapper>
|
|
123
|
-
</View>
|
|
111
|
+
<ScreenLoadingMeasurementsListItemWrapper index={index}>
|
|
112
|
+
<RiverItem {...riverItemProps} />
|
|
113
|
+
</ScreenLoadingMeasurementsListItemWrapper>
|
|
124
114
|
);
|
|
125
115
|
},
|
|
126
|
-
[
|
|
127
|
-
feed,
|
|
128
|
-
getStaticComponentFeed,
|
|
129
|
-
arePreviousComponentsLoaded,
|
|
130
|
-
onLoadFailed,
|
|
131
|
-
onLoadFinished,
|
|
132
|
-
]
|
|
116
|
+
[feed, getStaticComponentFeed, onLoadFailed, onLoadFinished]
|
|
133
117
|
);
|
|
134
118
|
|
|
135
|
-
const renderFooter = React.useCallback(() => {
|
|
136
|
-
return (
|
|
137
|
-
<RiverFooter
|
|
138
|
-
visible={isAnyLoading}
|
|
139
|
-
flatListHeight={flatListHeight}
|
|
140
|
-
isAnyLoaded={isAnyLoaded || waitForAllComponents}
|
|
141
|
-
/>
|
|
142
|
-
);
|
|
143
|
-
}, [flatListHeight, isAnyLoading, isAnyLoaded]);
|
|
144
|
-
|
|
145
119
|
const screenStyle = React.useMemo(
|
|
146
120
|
() => ({
|
|
147
121
|
paddingTop: ifEmptyUseFallback(
|
|
@@ -179,12 +153,6 @@ function ComponentsMapComponent(props: Props) {
|
|
|
179
153
|
|
|
180
154
|
usePipesCacheReset(riverId, riverComponents);
|
|
181
155
|
|
|
182
|
-
React.useEffect(() => {
|
|
183
|
-
if (isAllLoaded) {
|
|
184
|
-
logTimestamp(riverId?.toString());
|
|
185
|
-
}
|
|
186
|
-
}, [isAllLoaded]);
|
|
187
|
-
|
|
188
156
|
const refreshControl = React.useMemo(
|
|
189
157
|
() =>
|
|
190
158
|
pullToRefreshEnabled ? (
|
|
@@ -280,6 +248,11 @@ function ComponentsMapComponent(props: Props) {
|
|
|
280
248
|
}
|
|
281
249
|
}, []);
|
|
282
250
|
|
|
251
|
+
const contentContainerStyle = React.useMemo(
|
|
252
|
+
() => (isScreenWrappedInContainer ? {} : screenStyle),
|
|
253
|
+
[isScreenWrappedInContainer, screenStyle]
|
|
254
|
+
);
|
|
255
|
+
|
|
283
256
|
if (shouldShowLoadingError) {
|
|
284
257
|
return <RiverError />;
|
|
285
258
|
}
|
|
@@ -291,7 +264,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
291
264
|
<View style={styles.container}>
|
|
292
265
|
<ScreenLoadingMeasurements
|
|
293
266
|
riverId={riverId}
|
|
294
|
-
numberOfComponents={
|
|
267
|
+
numberOfComponents={riverComponents.length}
|
|
295
268
|
>
|
|
296
269
|
<ViewportTracker>
|
|
297
270
|
<FlatList
|
|
@@ -303,6 +276,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
303
276
|
overScrollMode={Platform.OS === "android" ? "never" : "auto"}
|
|
304
277
|
scrollIndicatorInsets={scrollIndicatorInsets}
|
|
305
278
|
extraData={feed}
|
|
279
|
+
stickyHeaderIndices={stickyHeaderIndices}
|
|
306
280
|
onLayout={handleOnLayout}
|
|
307
281
|
removeClippedSubviews
|
|
308
282
|
initialNumToRender={3}
|
|
@@ -312,10 +286,13 @@ function ComponentsMapComponent(props: Props) {
|
|
|
312
286
|
keyExtractor={keyExtractor}
|
|
313
287
|
renderItem={renderRiverItem}
|
|
314
288
|
data={riverComponents}
|
|
315
|
-
contentContainerStyle={
|
|
316
|
-
|
|
289
|
+
contentContainerStyle={contentContainerStyle}
|
|
290
|
+
ListFooterComponent={
|
|
291
|
+
<RiverFooter
|
|
292
|
+
flatListHeight={flatListHeight}
|
|
293
|
+
loadingState={loadingState}
|
|
294
|
+
/>
|
|
317
295
|
}
|
|
318
|
-
ListFooterComponent={renderFooter}
|
|
319
296
|
refreshControl={refreshControl}
|
|
320
297
|
onScrollBeginDrag={onScrollBeginDrag}
|
|
321
298
|
onScroll={onScroll}
|
|
@@ -1,50 +1,86 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const anyFalse = R.any(R.equals(false));
|
|
6
|
-
const anyTrue = R.any(R.equals(true));
|
|
2
|
+
import { isNil, set, lensIndex, T, slice } from "ramda";
|
|
3
|
+
import { BehaviorSubject } from "rxjs";
|
|
4
|
+
import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
|
|
7
5
|
|
|
8
6
|
const reducer = (state, { payload }) => {
|
|
9
|
-
if (!
|
|
10
|
-
return
|
|
7
|
+
if (!isNil(payload) && !state[payload]) {
|
|
8
|
+
return set(lensIndex(payload), true)(state);
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
return state;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
type LoadingState = {
|
|
15
|
+
index: number;
|
|
16
|
+
done: boolean;
|
|
19
17
|
waitForAllComponents: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Return = {
|
|
21
|
+
loadingState: BehaviorSubject<LoadingState>;
|
|
20
22
|
onLoadFinished: (index: number) => void;
|
|
21
23
|
onLoadFailed: ({ error, index }: { error: Error; index: number }) => void;
|
|
22
24
|
shouldShowLoadingError: boolean;
|
|
23
|
-
isAnyLoaded: boolean;
|
|
24
25
|
arePreviousComponentsLoaded: (index: number) => boolean;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
type Action = { payload: { index: number } };
|
|
28
|
-
|
|
29
|
-
type Loaded = true;
|
|
30
|
-
type Loading = false;
|
|
31
|
-
|
|
32
|
-
type LoadingState = Array<Loaded | Loading>;
|
|
33
|
-
|
|
34
28
|
// TODO: Take this value from Zapp configuration, when feature is added to GeneralScreen
|
|
35
29
|
const SHOULD_FAIL_ON_COMPONENT_LOADING = false;
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
const createLoadingStateObservable = (count: number) =>
|
|
32
|
+
new BehaviorSubject<LoadingState>({
|
|
33
|
+
index: -1,
|
|
34
|
+
done: count === 0,
|
|
35
|
+
waitForAllComponents: SHOULD_FAIL_ON_COMPONENT_LOADING,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const useLoadingState = (
|
|
39
|
+
count: number,
|
|
40
|
+
onLoadDone: () => void
|
|
41
|
+
): Return => {
|
|
42
|
+
const componentStateRef = React.useRef(new Array(count).fill(false));
|
|
38
43
|
const [loadingError, setLoadingError] = React.useState(null);
|
|
39
44
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
const loadingState = useRefWithInitialValue<BehaviorSubject<LoadingState>>(
|
|
46
|
+
() => createLoadingStateObservable(count)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const arePreviousComponentsLoaded = React.useCallback((index) => {
|
|
50
|
+
if (index === 0) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
const componentsBefore = slice(0, index, componentStateRef.current);
|
|
55
|
+
|
|
56
|
+
return componentsBefore.every(T);
|
|
46
57
|
}, []);
|
|
47
58
|
|
|
59
|
+
const dispatch = React.useCallback(({ payload }) => {
|
|
60
|
+
const newState = reducer(componentStateRef.current, { payload });
|
|
61
|
+
componentStateRef.current = newState;
|
|
62
|
+
const isDone = arePreviousComponentsLoaded(count - 1);
|
|
63
|
+
|
|
64
|
+
const state = loadingState.current.getValue();
|
|
65
|
+
|
|
66
|
+
const newLoadingState = {
|
|
67
|
+
...state,
|
|
68
|
+
index: state.index < payload ? payload : state.index,
|
|
69
|
+
done: isDone,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
loadingState.current.next(newLoadingState);
|
|
73
|
+
|
|
74
|
+
if (isDone) {
|
|
75
|
+
onLoadDone();
|
|
76
|
+
}
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
const handleComponentLoaded = React.useCallback(
|
|
80
|
+
(index) => dispatch({ payload: index }),
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
83
|
+
|
|
48
84
|
const handleComponentLoadErrorWhenNeedToFail = React.useCallback(
|
|
49
85
|
({ error }) => {
|
|
50
86
|
if (error !== loadingError) {
|
|
@@ -55,35 +91,26 @@ export const useLoadingState = (count: number): Return => {
|
|
|
55
91
|
);
|
|
56
92
|
|
|
57
93
|
const handleComponentLoadErrorWhenNoNeedToFail = React.useCallback(
|
|
58
|
-
({ index }) =>
|
|
59
|
-
handleComponentLoaded(index);
|
|
60
|
-
},
|
|
94
|
+
({ index }) => handleComponentLoaded(index),
|
|
61
95
|
[]
|
|
62
96
|
);
|
|
63
97
|
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
[
|
|
98
|
+
return React.useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
loadingState: loadingState.current,
|
|
101
|
+
onLoadFinished: handleComponentLoaded,
|
|
102
|
+
onLoadFailed: SHOULD_FAIL_ON_COMPONENT_LOADING
|
|
103
|
+
? handleComponentLoadErrorWhenNeedToFail
|
|
104
|
+
: handleComponentLoadErrorWhenNoNeedToFail,
|
|
105
|
+
shouldShowLoadingError: SHOULD_FAIL_ON_COMPONENT_LOADING && loadingError,
|
|
106
|
+
arePreviousComponentsLoaded,
|
|
107
|
+
}),
|
|
108
|
+
[
|
|
109
|
+
loadingError,
|
|
110
|
+
handleComponentLoaded,
|
|
111
|
+
handleComponentLoadErrorWhenNeedToFail,
|
|
112
|
+
handleComponentLoadErrorWhenNoNeedToFail,
|
|
113
|
+
arePreviousComponentsLoaded,
|
|
114
|
+
]
|
|
75
115
|
);
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
isAnyLoading: anyFalse(componentsState),
|
|
79
|
-
isAllLoaded: allTrue(componentsState),
|
|
80
|
-
onLoadFinished: handleComponentLoaded,
|
|
81
|
-
onLoadFailed: SHOULD_FAIL_ON_COMPONENT_LOADING
|
|
82
|
-
? handleComponentLoadErrorWhenNeedToFail
|
|
83
|
-
: handleComponentLoadErrorWhenNoNeedToFail,
|
|
84
|
-
shouldShowLoadingError: SHOULD_FAIL_ON_COMPONENT_LOADING && loadingError,
|
|
85
|
-
isAnyLoaded: anyTrue(componentsState),
|
|
86
|
-
waitForAllComponents: SHOULD_FAIL_ON_COMPONENT_LOADING,
|
|
87
|
-
arePreviousComponentsLoaded,
|
|
88
|
-
};
|
|
89
116
|
};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
3
|
import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
|
|
4
|
+
import type { Subject } from "rxjs";
|
|
5
|
+
import { useStateFromSubscribe } from "@applicaster/zapp-react-native-utils/reactHooks/state/useStateFromSubscribe";
|
|
6
|
+
|
|
7
|
+
type LoadingState = {
|
|
8
|
+
waitForAllComponents: boolean;
|
|
9
|
+
index: number;
|
|
10
|
+
done: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type State = {
|
|
14
|
+
visible: boolean;
|
|
15
|
+
isAnyLoaded: boolean;
|
|
16
|
+
};
|
|
4
17
|
|
|
5
18
|
type Props = {
|
|
6
|
-
visible?: boolean;
|
|
7
19
|
flatListHeight?: number;
|
|
8
|
-
|
|
20
|
+
loadingState: Subject<LoadingState>;
|
|
9
21
|
};
|
|
10
22
|
|
|
11
23
|
const FOOTER_COMPONENT_HEIGHT = 200;
|
|
@@ -19,17 +31,35 @@ const footerStyles = StyleSheet.create({
|
|
|
19
31
|
});
|
|
20
32
|
|
|
21
33
|
function RiverFooterComponent(props: Props) {
|
|
22
|
-
const {
|
|
34
|
+
const { flatListHeight, loadingState } = props;
|
|
35
|
+
|
|
36
|
+
const { visible, isAnyLoaded } = useStateFromSubscribe<LoadingState, State>(
|
|
37
|
+
loadingState,
|
|
38
|
+
useCallback(
|
|
39
|
+
({ index, done, waitForAllComponents }, setState) =>
|
|
40
|
+
setState(() => ({
|
|
41
|
+
visible: !done,
|
|
42
|
+
isAnyLoaded: index >= 0 || waitForAllComponents,
|
|
43
|
+
})),
|
|
44
|
+
[]
|
|
45
|
+
),
|
|
46
|
+
{
|
|
47
|
+
visible: true,
|
|
48
|
+
isAnyLoaded: false,
|
|
49
|
+
}
|
|
50
|
+
);
|
|
23
51
|
|
|
24
52
|
if (!visible) return null;
|
|
25
53
|
|
|
26
54
|
return (
|
|
27
55
|
<View
|
|
28
|
-
renderToHardwareTextureAndroid
|
|
29
|
-
style={
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
renderToHardwareTextureAndroid
|
|
57
|
+
style={[
|
|
58
|
+
footerStyles.container,
|
|
59
|
+
{
|
|
60
|
+
height: isAnyLoaded ? FOOTER_COMPONENT_HEIGHT : flatListHeight,
|
|
61
|
+
},
|
|
62
|
+
]}
|
|
33
63
|
>
|
|
34
64
|
<Spinner size={isAnyLoaded ? "small" : "large"} />
|
|
35
65
|
</View>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
import { isGroup } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
3
4
|
|
|
4
5
|
import { applyDecorators } from "../../Decorators";
|
|
5
6
|
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
import { riverLogger } from "./logger";
|
|
12
13
|
import { tvPluginsWithCellRenderer } from "../../const";
|
|
13
14
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
15
|
+
import type { BehaviorSubject } from "rxjs";
|
|
14
16
|
|
|
15
17
|
export type RiverItemType = {
|
|
16
18
|
item: ZappUIComponent;
|
|
@@ -24,6 +26,7 @@ export type RiverItemType = {
|
|
|
24
26
|
getStaticComponentFeed: GeneralContentScreenProps["getStaticComponentFeed"];
|
|
25
27
|
readyToBeDisplayed?: boolean;
|
|
26
28
|
isLast: boolean;
|
|
29
|
+
loadingState: BehaviorSubject<{ index: number }>;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
function getFeedUrl(feed: ZappFeed, index: number) {
|
|
@@ -36,6 +39,33 @@ function getFeedUrl(feed: ZappFeed, index: number) {
|
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
/**
|
|
43
|
+
* useLoadingState for RiverItemComponent
|
|
44
|
+
* takes currentIndex and loadingState as arguments
|
|
45
|
+
**/
|
|
46
|
+
const useLoadingState = (
|
|
47
|
+
currentIndex: number,
|
|
48
|
+
loadingState: RiverItemType["loadingState"]
|
|
49
|
+
) => {
|
|
50
|
+
const [readyToBeDisplayed, setReadyToBeDisplayed] = React.useState(
|
|
51
|
+
loadingState.getValue().index + 1 === currentIndex
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const subscription = loadingState.subscribe(({ index }) => {
|
|
56
|
+
if (index + 1 === currentIndex) {
|
|
57
|
+
setReadyToBeDisplayed(true);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
subscription.unsubscribe();
|
|
63
|
+
};
|
|
64
|
+
}, [loadingState, currentIndex]);
|
|
65
|
+
|
|
66
|
+
return readyToBeDisplayed;
|
|
67
|
+
};
|
|
68
|
+
|
|
39
69
|
function RiverItemComponent(props: RiverItemType) {
|
|
40
70
|
const {
|
|
41
71
|
item,
|
|
@@ -47,10 +77,12 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
47
77
|
onLoadFinished,
|
|
48
78
|
onLoadFailed,
|
|
49
79
|
getStaticComponentFeed,
|
|
50
|
-
readyToBeDisplayed,
|
|
51
80
|
isLast,
|
|
81
|
+
loadingState,
|
|
52
82
|
} = props;
|
|
53
83
|
|
|
84
|
+
const readyToBeDisplayed = useLoadingState(index, loadingState);
|
|
85
|
+
|
|
54
86
|
const feedUrl = getFeedUrl(feed, index);
|
|
55
87
|
|
|
56
88
|
const Component = useComponentResolver(
|
|
@@ -81,7 +113,7 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
81
113
|
jsOnly: true,
|
|
82
114
|
});
|
|
83
115
|
|
|
84
|
-
if (!CellRenderer && item
|
|
116
|
+
if (!CellRenderer && !isGroup(item)) {
|
|
85
117
|
riverLogger.warning({
|
|
86
118
|
message: "Cell Renderer is null - will fallback to default cell",
|
|
87
119
|
data: { item, CellRenderer },
|
|
@@ -90,6 +122,10 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
90
122
|
}
|
|
91
123
|
}, []);
|
|
92
124
|
|
|
125
|
+
if (!readyToBeDisplayed) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
93
129
|
if (Component === null || typeof Component === "undefined") {
|
|
94
130
|
riverLogger.warning({
|
|
95
131
|
message: `Component ${item.component_type} is null - skipping rendering`,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { compose } from "ramda";
|
|
1
2
|
import { River as RiverComponent } from "./River";
|
|
2
3
|
import { withTvEventHandler } from "./withTVEventHandler";
|
|
4
|
+
import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
|
|
3
5
|
|
|
4
|
-
export const River =
|
|
6
|
+
export const River = compose(
|
|
7
|
+
withTvEventHandler,
|
|
8
|
+
withComponentsMapOffsetContext
|
|
9
|
+
)(RiverComponent);
|