@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1740103407 → 16.0.0-alpha.1774022213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
- package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
- package/Components/AudioPlayer/tv/index.tsx +5 -1
- package/Components/Cell/Cell.tsx +3 -6
- package/Components/Cell/TvOSCellComponent.tsx +0 -1
- package/Components/CellRendererResolver/index.ts +1 -1
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +54 -0
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
- package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +188 -0
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
- package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
- package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
- package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +90 -0
- package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
- package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
- package/Components/GeneralContentScreen/index.ts +2 -0
- package/Components/LinkHandler/LinkHandler.tsx +2 -7
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +2 -4
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +36 -14
- package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -2
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/dataAdapter.ts +15 -5
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/MasterCell/index.tsx +30 -5
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
- package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
- package/Components/MasterCell/utils/index.ts +85 -46
- package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
- package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +392 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +772 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +728 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +1007 -0
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +205 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +113 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/NowPlayingHeaderSection.test.tsx +36 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +356 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +521 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +505 -50
- package/Components/ModalComponent/Button/index.tsx +5 -3
- package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
- package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
- package/Components/ModalComponent/Header/index.tsx +20 -7
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
- package/Components/ModalComponent/SortableList.tsx +156 -0
- package/Components/ModalComponent/SortableList.web.tsx +34 -0
- package/Components/ModalComponent/TextInputContent.tsx +135 -0
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +343 -0
- package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +169 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +18 -9
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +90 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
- package/Components/ModalComponent/presets/index.ts +27 -0
- package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
- package/Components/ModalComponent/presets/standardCell.tsx +41 -0
- package/Components/ModalComponent/presets/types.ts +35 -0
- package/Components/ModalComponent/showTextInput.ts +52 -0
- package/Components/ModalComponent/utils.ts +82 -21
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +111 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +18 -10
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +147 -204
- package/Components/River/River.tsx +4 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +148 -76
- package/Components/River/__tests__/componentsMap.test.js +8 -3
- package/Components/River/__tests__/resultCallback.test.tsx +47 -0
- package/Components/Screen/__tests__/Screen.test.tsx +24 -0
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +13 -4
- package/Components/Screen/navigationHandler.ts +8 -8
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +9 -3
- package/Components/VideoLive/__tests__/LiveImageManager.test.ts +59 -0
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/CachedDimensionsContext/index.ts +17 -2
- package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
- package/Contexts/ModalNavigationContext/index.tsx +2 -2
- package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
- package/Helpers/index.js +0 -39
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/assets/empty-Info.png +0 -0
- package/package.json +6 -5
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- package/Components/Screen/utils.ts +0 -16
- package/Helpers/Analytics/index.js +0 -95
- /package/Components/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
- /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { FlatList, StyleSheet, View } from "react-native";
|
|
3
|
+
import { SafeAreaView, EdgeMode, Edge } from "react-native-safe-area-context";
|
|
4
4
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
5
|
import { RiverItem } from "../RiverItem";
|
|
6
6
|
import { RiverFooter } from "../RiverFooter";
|
|
@@ -9,7 +9,7 @@ import { useScreenConfiguration } from "../useScreenConfiguration";
|
|
|
9
9
|
import { RefreshControl } from "../RefreshControl";
|
|
10
10
|
import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
useMarkPipesDataStale,
|
|
13
13
|
useProfilerLogging,
|
|
14
14
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
15
15
|
import { useLoadingState } from "./hooks/useLoadingState";
|
|
@@ -36,21 +36,29 @@ type Props = {
|
|
|
36
36
|
groupId?: string;
|
|
37
37
|
isScreenWrappedInContainer?: boolean;
|
|
38
38
|
riverComponents: ZappUIComponent[];
|
|
39
|
-
scrollViewExtraProps?:
|
|
39
|
+
scrollViewExtraProps?: {};
|
|
40
40
|
riverId?: string;
|
|
41
|
-
getStaticComponentFeed:
|
|
42
|
-
component: ZappUIComponent;
|
|
43
|
-
index: number;
|
|
44
|
-
}) => ZappFeed | Promise<ZappFeed>;
|
|
41
|
+
getStaticComponentFeed: any;
|
|
45
42
|
stickyHeaderIndices?: number[];
|
|
46
|
-
|
|
43
|
+
safeArea?:
|
|
44
|
+
| {
|
|
45
|
+
edges: Record<Edge, EdgeMode>;
|
|
46
|
+
mode: "padding" | "margin" | undefined;
|
|
47
|
+
}
|
|
48
|
+
| undefined;
|
|
47
49
|
};
|
|
48
50
|
|
|
51
|
+
const styles = StyleSheet.create({
|
|
52
|
+
container: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
49
57
|
const getNearestValue = (value, optionA, optionB) =>
|
|
50
58
|
Math.abs(value - optionA) < Math.abs(value - optionB) ? optionA : optionB;
|
|
51
59
|
|
|
52
60
|
const scrollIndicatorInsets = { right: 1 };
|
|
53
|
-
const keyExtractor =
|
|
61
|
+
const keyExtractor = (item) => item.id.toString();
|
|
54
62
|
|
|
55
63
|
function ComponentsMapComponent(props: Props) {
|
|
56
64
|
const {
|
|
@@ -62,14 +70,12 @@ function ComponentsMapComponent(props: Props) {
|
|
|
62
70
|
riverId,
|
|
63
71
|
getStaticComponentFeed,
|
|
64
72
|
stickyHeaderIndices,
|
|
65
|
-
|
|
73
|
+
safeArea,
|
|
66
74
|
} = props;
|
|
67
75
|
|
|
68
76
|
const flatListRef = React.useRef<FlatList | null>(null);
|
|
69
|
-
const scrollViewRef = React.useRef<ScrollView | null>(null);
|
|
70
77
|
const flatListWrapperRef = React.useRef<View | null>(null);
|
|
71
78
|
const hasUserScrolledRef = React.useRef(false);
|
|
72
|
-
const scrollEndReachedRef = React.useRef(false);
|
|
73
79
|
const screenConfig = useScreenConfiguration(riverId);
|
|
74
80
|
const screenData = useScreenData(riverId);
|
|
75
81
|
const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
|
|
@@ -78,7 +84,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
78
84
|
|
|
79
85
|
const riverComponents = React.useMemo(() => {
|
|
80
86
|
if (feed?.entry?.length < components.length) {
|
|
81
|
-
return
|
|
87
|
+
return components.slice(0, feed?.entry?.length);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
return components;
|
|
@@ -88,12 +94,12 @@ function ComponentsMapComponent(props: Props) {
|
|
|
88
94
|
|
|
89
95
|
const onLoadDone = React.useCallback(() => {
|
|
90
96
|
logTimestamp(riverId?.toString());
|
|
91
|
-
}, [logTimestamp
|
|
97
|
+
}, [logTimestamp]);
|
|
92
98
|
|
|
93
99
|
const { loadingState, onLoadFinished, onLoadFailed, shouldShowLoadingError } =
|
|
94
100
|
useLoadingState(riverComponents.length, onLoadDone);
|
|
95
101
|
|
|
96
|
-
const theme = useTheme();
|
|
102
|
+
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
97
103
|
|
|
98
104
|
const renderRiverItem = React.useCallback(
|
|
99
105
|
({ item, index }) => {
|
|
@@ -117,45 +123,21 @@ function ComponentsMapComponent(props: Props) {
|
|
|
117
123
|
</ScreenLoadingMeasurementsListItemWrapper>
|
|
118
124
|
);
|
|
119
125
|
},
|
|
120
|
-
[
|
|
121
|
-
feed,
|
|
122
|
-
getStaticComponentFeed,
|
|
123
|
-
groupId,
|
|
124
|
-
isScreenWrappedInContainer,
|
|
125
|
-
loadingState,
|
|
126
|
-
onLoadFailed,
|
|
127
|
-
onLoadFinished,
|
|
128
|
-
riverComponents.length,
|
|
129
|
-
riverId,
|
|
130
|
-
]
|
|
126
|
+
[feed, getStaticComponentFeed, onLoadFailed, onLoadFinished]
|
|
131
127
|
);
|
|
132
128
|
|
|
133
129
|
const screenStyle = React.useMemo(
|
|
134
130
|
() => ({
|
|
135
|
-
paddingTop: ifEmptyUseFallback(
|
|
136
|
-
screenConfig.paddingTop,
|
|
137
|
-
R.prop("screen_padding_top")(theme)
|
|
138
|
-
),
|
|
139
|
-
paddingBottom: ifEmptyUseFallback(
|
|
140
|
-
screenConfig.paddingBottom,
|
|
141
|
-
R.prop("screen_padding_bottom")(theme)
|
|
142
|
-
),
|
|
143
131
|
paddingLeft: ifEmptyUseFallback(
|
|
144
132
|
screenConfig.paddingLeft,
|
|
145
|
-
|
|
133
|
+
theme.screen_padding_left
|
|
146
134
|
),
|
|
147
135
|
paddingRight: ifEmptyUseFallback(
|
|
148
136
|
screenConfig.paddingRight,
|
|
149
|
-
|
|
137
|
+
theme.screen_padding_right
|
|
150
138
|
),
|
|
151
139
|
}),
|
|
152
|
-
[
|
|
153
|
-
screenConfig.paddingTop,
|
|
154
|
-
screenConfig.paddingBottom,
|
|
155
|
-
screenConfig.paddingLeft,
|
|
156
|
-
screenConfig.paddingRight,
|
|
157
|
-
theme,
|
|
158
|
-
]
|
|
140
|
+
[riverId]
|
|
159
141
|
);
|
|
160
142
|
|
|
161
143
|
const handleOnLayout = React.useCallback(
|
|
@@ -171,7 +153,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
171
153
|
[flatListHeight]
|
|
172
154
|
);
|
|
173
155
|
|
|
174
|
-
|
|
156
|
+
useMarkPipesDataStale(riverId, riverComponents);
|
|
175
157
|
|
|
176
158
|
const refreshControl = React.useMemo(
|
|
177
159
|
() => (pullToRefreshEnabled ? <RefreshControl /> : null),
|
|
@@ -190,50 +172,55 @@ function ComponentsMapComponent(props: Props) {
|
|
|
190
172
|
canMomentum.current = true;
|
|
191
173
|
}, []);
|
|
192
174
|
|
|
193
|
-
/*
|
|
194
|
-
const
|
|
195
|
-
(
|
|
196
|
-
|
|
175
|
+
/* onMomentumScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
176
|
+
const _onMomentumScrollEnd = React.useCallback(({ nativeEvent }) => {
|
|
177
|
+
if (!canMomentum.current) return;
|
|
178
|
+
canMomentum.current = false;
|
|
197
179
|
|
|
198
|
-
|
|
199
|
-
if (scrollState === 0 || scrollState === -headerHeight) return;
|
|
200
|
-
if (!flatListRef.current) return;
|
|
180
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
201
181
|
|
|
202
|
-
|
|
182
|
+
const offsetY = Math.max(0, nativeEvent.contentOffset.y);
|
|
203
183
|
|
|
204
|
-
|
|
184
|
+
if (
|
|
185
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
186
|
+
flatListRef.current
|
|
187
|
+
) {
|
|
188
|
+
const offset =
|
|
205
189
|
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
206
|
-
-headerHeight
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
190
|
+
-headerHeight
|
|
191
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
192
|
+
: Math.round(offsetY + scrollState);
|
|
193
|
+
|
|
194
|
+
flatListRef.current.scrollToOffset({
|
|
195
|
+
animated: true,
|
|
196
|
+
offset,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}, []);
|
|
211
200
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
201
|
+
/* onScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
202
|
+
const _onScrollEndDrag = React.useCallback(({ nativeEvent }) => {
|
|
203
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
216
204
|
|
|
217
|
-
|
|
218
|
-
const _onMomentumScrollEnd = React.useCallback(
|
|
219
|
-
({ nativeEvent }) => {
|
|
220
|
-
if (!canMomentum.current) return;
|
|
221
|
-
canMomentum.current = false;
|
|
222
|
-
snapToHeaderState(nativeEvent.contentOffset.y);
|
|
223
|
-
},
|
|
224
|
-
[snapToHeaderState]
|
|
225
|
-
);
|
|
205
|
+
const offsetY = Math.max(0, nativeEvent.contentOffset.y);
|
|
226
206
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
207
|
+
if (
|
|
208
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
209
|
+
flatListRef.current &&
|
|
210
|
+
nativeEvent.velocity.y === 0
|
|
211
|
+
) {
|
|
212
|
+
const offset =
|
|
213
|
+
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
214
|
+
-headerHeight
|
|
215
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
216
|
+
: Math.round(offsetY + scrollState);
|
|
217
|
+
|
|
218
|
+
flatListRef.current.scrollToOffset({
|
|
219
|
+
animated: true,
|
|
220
|
+
offset,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}, []);
|
|
237
224
|
|
|
238
225
|
const onScroll = React.useCallback((event) => {
|
|
239
226
|
hasUserScrolledRef.current = true;
|
|
@@ -257,42 +244,8 @@ function ComponentsMapComponent(props: Props) {
|
|
|
257
244
|
}
|
|
258
245
|
}, []);
|
|
259
246
|
|
|
260
|
-
const onScrollWithEndReached = React.useCallback(
|
|
261
|
-
(event) => {
|
|
262
|
-
onScroll(event);
|
|
263
|
-
|
|
264
|
-
if (!hasUserScrolledRef.current) return;
|
|
265
|
-
if (isScreenWrappedInContainer) return;
|
|
266
|
-
|
|
267
|
-
const {
|
|
268
|
-
nativeEvent: {
|
|
269
|
-
contentOffset: { y },
|
|
270
|
-
layoutMeasurement: { height },
|
|
271
|
-
contentSize: { height: contentHeight },
|
|
272
|
-
},
|
|
273
|
-
} = event;
|
|
274
|
-
|
|
275
|
-
const distanceFromEnd = contentHeight - y - height;
|
|
276
|
-
|
|
277
|
-
if (distanceFromEnd <= height * 0.5) {
|
|
278
|
-
if (!scrollEndReachedRef.current) {
|
|
279
|
-
scrollEndReachedRef.current = true;
|
|
280
|
-
emitScrollEndReached();
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
scrollEndReachedRef.current = false;
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
[onScroll, isScreenWrappedInContainer]
|
|
287
|
-
);
|
|
288
|
-
|
|
289
247
|
const contentContainerStyle = React.useMemo(
|
|
290
|
-
() =>
|
|
291
|
-
isScreenWrappedInContainer
|
|
292
|
-
? {
|
|
293
|
-
flexGrow: 1,
|
|
294
|
-
}
|
|
295
|
-
: screenStyle,
|
|
248
|
+
() => (isScreenWrappedInContainer ? {} : screenStyle),
|
|
296
249
|
[isScreenWrappedInContainer, screenStyle]
|
|
297
250
|
);
|
|
298
251
|
|
|
@@ -303,98 +256,89 @@ function ComponentsMapComponent(props: Props) {
|
|
|
303
256
|
// TODO: support both "isScreenWrappedInContainer" and hasScreenPicker().
|
|
304
257
|
// The Screen Picker in Mobile is completly different than the TV
|
|
305
258
|
// so the various offsets / margins in TV do not apply here.
|
|
306
|
-
// Fix for WebView rerender crashes on Android API 28+
|
|
307
|
-
// https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
|
|
308
|
-
const sharedScrollProps = {
|
|
309
|
-
overScrollMode: isAndroid ? ("never" as const) : ("auto" as const),
|
|
310
|
-
scrollIndicatorInsets,
|
|
311
|
-
onLayout: handleOnLayout,
|
|
312
|
-
contentContainerStyle,
|
|
313
|
-
refreshControl,
|
|
314
|
-
onScrollBeginDrag,
|
|
315
|
-
onMomentumScrollEnd: _onMomentumScrollEnd,
|
|
316
|
-
onScrollEndDrag: _onScrollEndDrag,
|
|
317
|
-
scrollEventThrottle: 16,
|
|
318
|
-
...scrollViewExtraProps,
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const listContent = useScrollView ? (
|
|
322
|
-
<ScrollView
|
|
323
|
-
testID="components-map-scroll-view"
|
|
324
|
-
// ViewportTracker clones this child and calls its `ref` as a function
|
|
325
|
-
// (childrenRef.current.ref(node)), so a callback ref is required here
|
|
326
|
-
// — an object ref would throw "ref is not a function".
|
|
327
|
-
ref={(ref) => {
|
|
328
|
-
scrollViewRef.current = ref;
|
|
329
|
-
}}
|
|
330
|
-
onScroll={onScrollWithEndReached}
|
|
331
|
-
{...sharedScrollProps}
|
|
332
|
-
>
|
|
333
|
-
{riverComponents.map((item, index) => (
|
|
334
|
-
<React.Fragment key={keyExtractor(item)}>
|
|
335
|
-
{renderRiverItem({ item, index })}
|
|
336
|
-
</React.Fragment>
|
|
337
|
-
))}
|
|
338
|
-
<RiverFooter
|
|
339
|
-
flatListHeight={flatListHeight}
|
|
340
|
-
loadingState={loadingState}
|
|
341
|
-
/>
|
|
342
|
-
</ScrollView>
|
|
343
|
-
) : (
|
|
344
|
-
<FlatList
|
|
345
|
-
testID="components-map-flat-list"
|
|
346
|
-
// ViewportTracker clones this child and calls its `ref` as a function
|
|
347
|
-
// (childrenRef.current.ref(node)), so a callback ref is required here
|
|
348
|
-
// — an object ref would throw "ref is not a function".
|
|
349
|
-
ref={(ref) => {
|
|
350
|
-
flatListRef.current = ref;
|
|
351
|
-
}}
|
|
352
|
-
extraData={feed}
|
|
353
|
-
stickyHeaderIndices={stickyHeaderIndices}
|
|
354
|
-
removeClippedSubviews={isAndroid}
|
|
355
|
-
initialNumToRender={3}
|
|
356
|
-
maxToRenderPerBatch={10}
|
|
357
|
-
windowSize={12}
|
|
358
|
-
keyExtractor={keyExtractor}
|
|
359
|
-
renderItem={renderRiverItem}
|
|
360
|
-
data={riverComponents}
|
|
361
|
-
ListFooterComponent={
|
|
362
|
-
<RiverFooter
|
|
363
|
-
flatListHeight={flatListHeight}
|
|
364
|
-
loadingState={loadingState}
|
|
365
|
-
/>
|
|
366
|
-
}
|
|
367
|
-
onScroll={onScroll}
|
|
368
|
-
onEndReached={
|
|
369
|
-
/* TODO: end-reached detection is inconsistent between the two paths:
|
|
370
|
-
the ScrollView branch uses manual pixel-offset math (onScrollWithEndReached)
|
|
371
|
-
with a scrollEndReachedRef debounce, while this FlatList relies on the
|
|
372
|
-
native onEndReached. Consider unifying the threshold/debounce behavior. */
|
|
373
|
-
/* When wrapped in a parent ScrollView (e.g. tabs),
|
|
374
|
-
this FlatList doesn't scroll so onEndReached can fire repeatedly;
|
|
375
|
-
skip it here and let the parent ScrollView emit scroll-end instead. */
|
|
376
|
-
isScreenWrappedInContainer
|
|
377
|
-
? undefined
|
|
378
|
-
: () => {
|
|
379
|
-
if (!hasUserScrolledRef.current) return;
|
|
380
|
-
emitScrollEndReached();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
{...sharedScrollProps}
|
|
384
|
-
/>
|
|
385
|
-
);
|
|
386
|
-
|
|
387
259
|
return (
|
|
388
|
-
|
|
389
|
-
// for measuring the list's position/height; it intentionally has no style.
|
|
390
|
-
<View ref={flatListWrapperRef}>
|
|
260
|
+
<View style={styles.container} ref={flatListWrapperRef}>
|
|
391
261
|
<ComponentsMapHeightContext.Provider value={flatListHeight}>
|
|
392
262
|
<ComponentsMapRefContext.Provider value={flatListWrapperRef}>
|
|
393
263
|
<ScreenLoadingMeasurements
|
|
394
264
|
riverId={riverId}
|
|
395
265
|
numberOfComponents={riverComponents.length}
|
|
396
266
|
>
|
|
397
|
-
<ViewportTracker>
|
|
267
|
+
<ViewportTracker>
|
|
268
|
+
<>
|
|
269
|
+
<FlatList
|
|
270
|
+
ListHeaderComponent={
|
|
271
|
+
<SafeAreaView
|
|
272
|
+
mode={safeArea?.mode ?? "margin"}
|
|
273
|
+
style={{
|
|
274
|
+
paddingTop: ifEmptyUseFallback(
|
|
275
|
+
screenConfig.paddingTop,
|
|
276
|
+
theme.screen_padding_top
|
|
277
|
+
),
|
|
278
|
+
height: StyleSheet.hairlineWidth,
|
|
279
|
+
}}
|
|
280
|
+
edges={{ top: safeArea?.edges?.top ?? "off" }}
|
|
281
|
+
/>
|
|
282
|
+
}
|
|
283
|
+
testID="components-map-flat-list"
|
|
284
|
+
ref={(ref) => {
|
|
285
|
+
flatListRef.current = ref;
|
|
286
|
+
}}
|
|
287
|
+
// Fix for WebView rerender crashes on Android API 28+
|
|
288
|
+
// https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
|
|
289
|
+
overScrollMode={isAndroid ? "never" : "auto"}
|
|
290
|
+
scrollIndicatorInsets={scrollIndicatorInsets}
|
|
291
|
+
extraData={feed}
|
|
292
|
+
stickyHeaderIndices={stickyHeaderIndices}
|
|
293
|
+
removeClippedSubviews={isAndroid}
|
|
294
|
+
onLayout={handleOnLayout}
|
|
295
|
+
initialNumToRender={3}
|
|
296
|
+
maxToRenderPerBatch={10}
|
|
297
|
+
windowSize={12}
|
|
298
|
+
keyExtractor={keyExtractor}
|
|
299
|
+
renderItem={renderRiverItem}
|
|
300
|
+
data={riverComponents}
|
|
301
|
+
contentContainerStyle={contentContainerStyle}
|
|
302
|
+
ListFooterComponent={
|
|
303
|
+
<>
|
|
304
|
+
<RiverFooter
|
|
305
|
+
flatListHeight={flatListHeight}
|
|
306
|
+
loadingState={loadingState}
|
|
307
|
+
/>
|
|
308
|
+
<SafeAreaView
|
|
309
|
+
mode={safeArea?.mode ?? "margin"}
|
|
310
|
+
style={{
|
|
311
|
+
paddingBottom: ifEmptyUseFallback(
|
|
312
|
+
screenConfig.paddingBottom,
|
|
313
|
+
theme.screen_padding_bottom
|
|
314
|
+
),
|
|
315
|
+
height: StyleSheet.hairlineWidth,
|
|
316
|
+
}}
|
|
317
|
+
edges={{ bottom: safeArea?.edges?.bottom ?? "off" }}
|
|
318
|
+
/>
|
|
319
|
+
</>
|
|
320
|
+
}
|
|
321
|
+
refreshControl={refreshControl}
|
|
322
|
+
onScrollBeginDrag={onScrollBeginDrag}
|
|
323
|
+
onScroll={onScroll}
|
|
324
|
+
onMomentumScrollEnd={_onMomentumScrollEnd}
|
|
325
|
+
onScrollEndDrag={_onScrollEndDrag}
|
|
326
|
+
scrollEventThrottle={16}
|
|
327
|
+
{...scrollViewExtraProps}
|
|
328
|
+
onEndReached={
|
|
329
|
+
/* When wrapped in a parent ScrollView (e.g. tabs),
|
|
330
|
+
this FlatList doesn't scroll so onEndReached can fire repeatedly;
|
|
331
|
+
skip it here and let the parent ScrollView emit scroll-end instead. */
|
|
332
|
+
isScreenWrappedInContainer
|
|
333
|
+
? undefined
|
|
334
|
+
: () => {
|
|
335
|
+
if (!hasUserScrolledRef.current) return;
|
|
336
|
+
emitScrollEndReached();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/>
|
|
340
|
+
</>
|
|
341
|
+
</ViewportTracker>
|
|
398
342
|
</ScreenLoadingMeasurements>
|
|
399
343
|
</ComponentsMapRefContext.Provider>
|
|
400
344
|
</ComponentsMapHeightContext.Provider>
|
|
@@ -403,6 +347,5 @@ function ComponentsMapComponent(props: Props) {
|
|
|
403
347
|
}
|
|
404
348
|
|
|
405
349
|
export const ComponentsMap = React.memo(
|
|
406
|
-
withComponentsMapProvider(ComponentsMapComponent)
|
|
407
|
-
R.equals
|
|
350
|
+
withComponentsMapProvider(ComponentsMapComponent)
|
|
408
351
|
);
|
|
@@ -20,6 +20,8 @@ type Props = ZappScreenProps & {
|
|
|
20
20
|
setIsScreenWrappedInContainer: (isInsideContainer: boolean) => void;
|
|
21
21
|
screenContext: ZappRiver;
|
|
22
22
|
river: ZappRiver;
|
|
23
|
+
/** Result channel for screens presented as a modal; forwarded to the resolved screen. */
|
|
24
|
+
resultCallback?: hookCallback;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export class RiverComponent extends React.Component<Props> {
|
|
@@ -64,6 +66,7 @@ export class RiverComponent extends React.Component<Props> {
|
|
|
64
66
|
isInsideContainer,
|
|
65
67
|
groupId,
|
|
66
68
|
scrollViewExtraProps,
|
|
69
|
+
resultCallback,
|
|
67
70
|
} = this.props;
|
|
68
71
|
|
|
69
72
|
const { id, type } = river;
|
|
@@ -77,6 +80,7 @@ export class RiverComponent extends React.Component<Props> {
|
|
|
77
80
|
})}
|
|
78
81
|
screenId={id}
|
|
79
82
|
screenType={type}
|
|
83
|
+
resultCallback={resultCallback}
|
|
80
84
|
/>
|
|
81
85
|
);
|
|
82
86
|
}
|