@applicaster/zapp-react-native-utils 15.0.0-alpha.4515904047 → 15.0.0-alpha.4920020685
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/actionsExecutor/ActionExecutorContext.tsx +3 -6
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/adsUtils/__tests__/createVMAP.test.ts +419 -0
- package/adsUtils/index.ts +2 -2
- package/analyticsUtils/AnalyticPlayerListener.ts +5 -2
- package/analyticsUtils/README.md +1 -1
- package/analyticsUtils/analyticsMapper.ts +10 -2
- package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
- package/appUtils/HooksManager/index.ts +10 -10
- package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
- package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
- package/appUtils/accessibilityManager/const.ts +4 -0
- package/appUtils/accessibilityManager/hooks.ts +20 -13
- package/appUtils/accessibilityManager/index.ts +28 -1
- package/appUtils/accessibilityManager/utils.ts +59 -8
- package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
- package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
- package/appUtils/contextKeysManager/contextResolver.ts +51 -22
- package/appUtils/contextKeysManager/index.ts +65 -10
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +4 -0
- package/appUtils/focusManager/index.ios.ts +59 -3
- package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
- package/appUtils/focusManagerAux/utils/index.ts +19 -1
- package/appUtils/focusManagerAux/utils/utils.ios.ts +231 -0
- package/appUtils/keyCodes/keys/keys.web.ts +1 -4
- package/appUtils/orientationHelper.ts +2 -4
- package/appUtils/platform/platformUtils.ts +117 -18
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +94 -4
- package/appUtils/playerManager/OverlayObserver/utils.ts +32 -20
- package/appUtils/playerManager/conts.ts +21 -0
- package/appUtils/playerManager/player.ts +4 -0
- package/appUtils/playerManager/playerNative.ts +29 -16
- package/appUtils/playerManager/usePlayerState.tsx +14 -2
- package/arrayUtils/__tests__/allTruthy.test.ts +24 -0
- package/arrayUtils/__tests__/anyThruthy.test.ts +24 -0
- package/arrayUtils/index.ts +5 -0
- package/cellUtils/index.ts +32 -0
- package/cloudEventsUtils/__tests__/index.test.ts +529 -0
- package/cloudEventsUtils/index.ts +65 -1
- package/configurationUtils/__tests__/imageSrcFromMediaItem.test.ts +38 -0
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
- package/configurationUtils/index.ts +17 -11
- package/dateUtils/__tests__/dayjs.test.ts +330 -0
- package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
- package/errorUtils/__tests__/GeneralError.test.ts +97 -0
- package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
- package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
- package/errorUtils/__tests__/NetworkError.test.ts +202 -0
- package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
- package/errorUtils/__tests__/invariant.test.ts +112 -0
- package/focusManager/aux/index.ts +1 -1
- package/headersUtils/__tests__/headersUtils.test.js +11 -1
- package/headersUtils/index.ts +2 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +125 -11
- package/manifestUtils/keys.js +21 -0
- package/manifestUtils/platformIsTV.js +13 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +1 -0
- package/manifestUtils/tvAction/container/index.js +1 -1
- package/navigationUtils/index.ts +34 -21
- package/numberUtils/__tests__/toNumber.test.ts +12 -0
- package/numberUtils/__tests__/toPositiveNumber.test.ts +165 -0
- package/numberUtils/index.ts +19 -1
- package/package.json +4 -4
- package/playerUtils/usePlayerTTS.ts +8 -3
- package/pluginUtils/index.ts +4 -0
- package/reactHooks/advertising/index.ts +2 -2
- package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
- package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
- package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
- package/reactHooks/cell-click/__tests__/index.test.js +1 -3
- package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
- package/reactHooks/connection/__tests__/index.test.js +1 -1
- package/reactHooks/debugging/__tests__/index.test.js +4 -4
- package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
- package/reactHooks/device/useIsTablet.tsx +14 -19
- package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
- package/reactHooks/events/index.ts +20 -0
- package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
- package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
- package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +1 -1
- package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
- package/reactHooks/feed/useBatchLoading.ts +7 -1
- package/reactHooks/feed/useEntryScreenId.ts +2 -2
- package/reactHooks/feed/useFeedLoader.tsx +0 -9
- package/reactHooks/feed/useInflatedUrl.ts +57 -37
- package/reactHooks/feed/usePipesCacheReset.ts +3 -1
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
- package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +12 -8
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/index.test.tsx +1 -1
- package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
- package/reactHooks/layout/index.ts +1 -1
- package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
- package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
- package/reactHooks/navigation/__tests__/index.test.tsx +40 -9
- package/reactHooks/navigation/index.ts +27 -11
- package/reactHooks/navigation/useRoute.ts +11 -7
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
- package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
- package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
- package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
- package/reactHooks/resolvers/useCellResolver.ts +6 -2
- package/reactHooks/resolvers/useComponentResolver.ts +8 -2
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
- package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
- package/reactHooks/screen/useTargetScreenData.ts +4 -2
- package/reactHooks/state/useRefWithInitialValue.ts +10 -0
- package/reactHooks/state/useRivers.ts +1 -1
- package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
- package/reactHooks/usePluginConfiguration.ts +2 -2
- package/reactHooks/utils/__tests__/index.test.js +1 -1
- package/rectUtils/__tests__/index.test.ts +549 -0
- package/rectUtils/index.ts +2 -2
- package/screenPickerUtils/__tests__/index.test.ts +333 -0
- package/screenState/__tests__/index.test.ts +1 -1
- package/searchUtils/const.ts +7 -0
- package/searchUtils/index.ts +3 -0
- package/services/storageServiceSync.web.ts +1 -1
- package/stringUtils/index.ts +1 -1
- package/testUtils/index.tsx +30 -21
- package/time/__tests__/BackgroundTimer.test.ts +156 -0
- package/time/__tests__/Timer.test.ts +236 -0
- package/typeGuards/__tests__/isString.test.ts +21 -0
- package/typeGuards/index.ts +4 -0
- package/utils/__tests__/mapAccum.test.ts +73 -0
- package/utils/__tests__/mergeRight.test.ts +48 -0
- package/utils/__tests__/selectors.test.ts +124 -0
- package/utils/index.ts +20 -0
- package/utils/mapAccum.ts +23 -0
- package/utils/mergeRight.ts +5 -0
- package/utils/path.ts +6 -3
- package/utils/pathOr.ts +5 -1
- package/utils/selectors.ts +46 -0
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +90 -38
- package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
- package/zappFrameworkUtils/HookCallback/useCallbackActions.ts +1 -7
- package/reactHooks/componentsMap/index.ts +0 -55
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useNavigation, useRivers, useScreenContext } from "../../reactHooks";
|
|
2
2
|
import { createLogger } from "../../logger";
|
|
3
|
-
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useCallback, useMemo, useRef, useEffect } from "react";
|
|
4
4
|
|
|
5
5
|
export enum NavigationCallbackOptions {
|
|
6
6
|
DEFAULT = "default",
|
|
@@ -15,8 +15,9 @@ export enum ResultType {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type CallbackResult = hookCallbackArgs & {
|
|
18
|
-
options
|
|
18
|
+
options?: {
|
|
19
19
|
resultType?: ResultType;
|
|
20
|
+
navigator?: QuickBrickAppNavigator;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
|
|
@@ -36,7 +37,7 @@ type General = Record<string, unknown>;
|
|
|
36
37
|
|
|
37
38
|
const LogPrefix = "useCallbackNavigationAction:";
|
|
38
39
|
|
|
39
|
-
const { log_info, log_verbose,
|
|
40
|
+
const { log_info, log_verbose, log_debug } = createLogger({
|
|
40
41
|
subsystem: "hook-navigation-callback",
|
|
41
42
|
});
|
|
42
43
|
|
|
@@ -45,7 +46,7 @@ const legacyMappingKeys = {
|
|
|
45
46
|
actionType: "login_completion_action",
|
|
46
47
|
targetScreen: "navigate_to_login_screen",
|
|
47
48
|
},
|
|
48
|
-
"quick-brick-user-account-ui-component": {
|
|
49
|
+
"quick-brick-user-account-ui-component.login": {
|
|
49
50
|
actionType: "callbackAction",
|
|
50
51
|
},
|
|
51
52
|
"quick-brick-login-multi-login-providers.login": {
|
|
@@ -56,23 +57,40 @@ const legacyMappingKeys = {
|
|
|
56
57
|
actionType: "logout_completion_action",
|
|
57
58
|
targetScreen: "navigate_to_logout_screen",
|
|
58
59
|
},
|
|
60
|
+
"quick-brick-storefront": {
|
|
61
|
+
actionType: "purchase_completion_action",
|
|
62
|
+
targetScreen: "navigate_to_screen_after_purchase",
|
|
63
|
+
},
|
|
64
|
+
"zapp_login_plugin_oauth_tv_2_0.login": {
|
|
65
|
+
actionType: "login_completion_action",
|
|
66
|
+
targetScreen: "navigate_to_login_screen",
|
|
67
|
+
},
|
|
68
|
+
"zapp_login_plugin_oauth_tv_2_0.logout": {
|
|
69
|
+
actionType: "logout_completion_action",
|
|
70
|
+
targetScreen: "navigate_to_logout_screen",
|
|
71
|
+
},
|
|
59
72
|
};
|
|
60
73
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const NAV_ACTIONS = Object.values(NavigationCallbackOptions) as string[];
|
|
74
|
+
const NAV_ACTIONS = (
|
|
75
|
+
Object.values(NavigationCallbackOptions) as string[]
|
|
76
|
+
).filter((value) => value !== NavigationCallbackOptions.DEFAULT);
|
|
65
77
|
|
|
66
78
|
const isNavAction = (v: unknown): v is NavigationCallbackOptions =>
|
|
67
|
-
typeof v === "string" && NAV_ACTIONS.includes(v
|
|
79
|
+
typeof v === "string" && NAV_ACTIONS.includes(v);
|
|
68
80
|
|
|
69
81
|
export const getNavigationKeys = (
|
|
70
82
|
item?: ZappUIComponent | ZappRiver,
|
|
71
|
-
resultType: ResultType = null
|
|
83
|
+
resultType: ResultType | null = null
|
|
72
84
|
): NavKeys => {
|
|
73
85
|
const general = (item?.general ?? {}) as General;
|
|
74
|
-
|
|
75
|
-
const
|
|
86
|
+
|
|
87
|
+
const pluginIdentifier =
|
|
88
|
+
(item as any).identifier ?? item?.type ?? item?.component_type ?? "";
|
|
89
|
+
|
|
90
|
+
const legacy =
|
|
91
|
+
legacyMappingKeys[`${pluginIdentifier}.${resultType}`] ??
|
|
92
|
+
legacyMappingKeys[pluginIdentifier] ??
|
|
93
|
+
{};
|
|
76
94
|
|
|
77
95
|
const actionKey = resultType
|
|
78
96
|
? `${resultType}_${CALLBACK_NAVIGATION_KEY}`
|
|
@@ -82,29 +100,27 @@ export const getNavigationKeys = (
|
|
|
82
100
|
(general as General)[actionKey] ??
|
|
83
101
|
(legacy.actionType ? (general as General)[legacy.actionType] : undefined);
|
|
84
102
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const trimmed = rawAction.trim();
|
|
89
|
-
action = isNavAction(trimmed) ? trimmed : null;
|
|
90
|
-
}
|
|
103
|
+
const action: NavigationCallbackOptions | null = isNavAction(rawAction)
|
|
104
|
+
? rawAction
|
|
105
|
+
: null;
|
|
91
106
|
|
|
92
107
|
if (!action) return null;
|
|
93
108
|
|
|
94
109
|
let targetScreenId: string | null = null;
|
|
95
110
|
|
|
96
111
|
if (action === NavigationCallbackOptions.GO_TO_SCREEN) {
|
|
112
|
+
const screenKey = resultType
|
|
113
|
+
? `${resultType}_${CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY}`
|
|
114
|
+
: CALLBACK_NAVIGATION_GO_TO_SCREEN_KEY;
|
|
115
|
+
|
|
97
116
|
const screenId: string | null =
|
|
98
|
-
((general as General)[
|
|
117
|
+
((general as General)[screenKey] as string) ??
|
|
99
118
|
(legacy.targetScreen
|
|
100
119
|
? ((general as General)[legacy.targetScreen] as string)
|
|
101
120
|
: undefined);
|
|
102
121
|
|
|
103
122
|
if (screenId) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
targetScreenId =
|
|
107
|
-
trimmedTargetScreenId.length > 0 ? trimmedTargetScreenId : null;
|
|
123
|
+
targetScreenId = screenId.length > 0 ? screenId : null;
|
|
108
124
|
}
|
|
109
125
|
}
|
|
110
126
|
|
|
@@ -113,12 +129,20 @@ export const getNavigationKeys = (
|
|
|
113
129
|
|
|
114
130
|
export const useCallbackNavigationAction = (
|
|
115
131
|
item?: ZappUIComponent | ZappRiver
|
|
116
|
-
): ((
|
|
132
|
+
): ((
|
|
133
|
+
args: CallbackResult,
|
|
134
|
+
hookCallback?: hookCallback
|
|
135
|
+
) => void | undefined) => {
|
|
117
136
|
const navigation = useNavigation();
|
|
118
137
|
const rivers = useRivers();
|
|
119
|
-
const enabled = Boolean(item?.general?.[CALLBACK_NAVIGATION_KEY]);
|
|
120
138
|
const screenContext = useScreenContext();
|
|
121
139
|
|
|
140
|
+
const navigationRef = useRef(navigation);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
navigationRef.current = navigation;
|
|
144
|
+
}, [navigation]);
|
|
145
|
+
|
|
122
146
|
const overrideCallbackFromComponent = useMemo(() => {
|
|
123
147
|
log_verbose(`${LogPrefix}: overridden callbackAction by component`);
|
|
124
148
|
|
|
@@ -131,28 +155,56 @@ export const useCallbackNavigationAction = (
|
|
|
131
155
|
}
|
|
132
156
|
|
|
133
157
|
const callbackAction = useCallback<hookCallback>(
|
|
134
|
-
(args: CallbackResult) => {
|
|
158
|
+
(args: CallbackResult, hookCallback: hookCallback = null) => {
|
|
135
159
|
if (!args.success) {
|
|
136
|
-
|
|
160
|
+
log_debug(
|
|
161
|
+
`${LogPrefix} callback called with no success, use original callback`
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
hookCallback?.(args);
|
|
137
165
|
|
|
138
166
|
return;
|
|
139
167
|
}
|
|
140
168
|
|
|
141
169
|
if (args.cancelled) {
|
|
142
|
-
|
|
170
|
+
log_debug(
|
|
171
|
+
`${LogPrefix} callback called but cancelled, use original callback`
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
hookCallback?.(args);
|
|
143
175
|
|
|
144
176
|
return;
|
|
145
177
|
}
|
|
146
178
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
179
|
+
let data = getNavigationKeys(item, args.options?.resultType ?? null);
|
|
180
|
+
|
|
181
|
+
if (!data) {
|
|
182
|
+
const isScreen = !hookCallback;
|
|
183
|
+
|
|
184
|
+
if (isScreen && args.options?.resultType === ResultType.login) {
|
|
185
|
+
log_debug(
|
|
186
|
+
`${LogPrefix} no navigation data found, applying GO BACK for login screen`
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
data = {
|
|
190
|
+
action: NavigationCallbackOptions.GO_BACK,
|
|
191
|
+
targetScreenId: null,
|
|
192
|
+
};
|
|
193
|
+
} else {
|
|
194
|
+
hookCallback?.(args);
|
|
195
|
+
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
hookCallback?.({ ...args, success: false, cancelled: true });
|
|
201
|
+
const currentNavigation = navigationRef.current;
|
|
151
202
|
|
|
152
203
|
switch (data.action) {
|
|
153
204
|
case NavigationCallbackOptions.GO_BACK: {
|
|
154
|
-
if (
|
|
155
|
-
|
|
205
|
+
if (currentNavigation.canGoBack()) {
|
|
206
|
+
currentNavigation.goBack();
|
|
207
|
+
|
|
156
208
|
log_info(`${LogPrefix} performing 'GO BACK' action`);
|
|
157
209
|
} else {
|
|
158
210
|
log_info(`${LogPrefix} cannot perform 'GO BACK' action — ignoring`);
|
|
@@ -162,7 +214,7 @@ export const useCallbackNavigationAction = (
|
|
|
162
214
|
}
|
|
163
215
|
|
|
164
216
|
case NavigationCallbackOptions.GO_HOME: {
|
|
165
|
-
|
|
217
|
+
currentNavigation.goHome();
|
|
166
218
|
log_info(`${LogPrefix} performing 'GO HOME' action`);
|
|
167
219
|
break;
|
|
168
220
|
}
|
|
@@ -178,7 +230,7 @@ export const useCallbackNavigationAction = (
|
|
|
178
230
|
const screen = rivers[screenId];
|
|
179
231
|
|
|
180
232
|
if (screen) {
|
|
181
|
-
|
|
233
|
+
currentNavigation.replace(screen);
|
|
182
234
|
|
|
183
235
|
log_info(
|
|
184
236
|
`${LogPrefix} performing 'GO TO SCREEN' action to screen: ${screenId}`
|
|
@@ -195,8 +247,8 @@ export const useCallbackNavigationAction = (
|
|
|
195
247
|
}
|
|
196
248
|
}
|
|
197
249
|
},
|
|
198
|
-
[item,
|
|
250
|
+
[item, rivers]
|
|
199
251
|
);
|
|
200
252
|
|
|
201
|
-
return
|
|
253
|
+
return overrideCallbackFromComponent || callbackAction;
|
|
202
254
|
};
|
|
@@ -12,13 +12,7 @@ export const useCallbackActions = (
|
|
|
12
12
|
|
|
13
13
|
return useCallback(
|
|
14
14
|
async (data: CallbackResult) => {
|
|
15
|
-
|
|
16
|
-
hookCallback?.({ ...data, success: false, cancelled: true });
|
|
17
|
-
|
|
18
|
-
navigationAction(data);
|
|
19
|
-
} else {
|
|
20
|
-
hookCallback?.(data);
|
|
21
|
-
}
|
|
15
|
+
navigationAction(data, hookCallback);
|
|
22
16
|
},
|
|
23
17
|
[navigationAction, hookCallback]
|
|
24
18
|
);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
const layoutReducer = (state, { payload }) => {
|
|
4
|
-
return state.map((item, index, _state) => ({
|
|
5
|
-
height: index === payload.index ? payload.height : item.height,
|
|
6
|
-
y:
|
|
7
|
-
index > 0
|
|
8
|
-
? _state.slice(0, index).reduce((acc, value) => acc + value.height, 0)
|
|
9
|
-
: 0,
|
|
10
|
-
}));
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const useComponentsLayout = (count, onFinishLoadingVisible) => {
|
|
14
|
-
const [itemsLayout, dispatchItemLayout] = React.useReducer(
|
|
15
|
-
layoutReducer,
|
|
16
|
-
Array.from({ length: count }, () => ({ height: 0, y: 0 }))
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const notified = React.useRef(false);
|
|
20
|
-
const [listHeight, setListHeight] = React.useState<number>(0);
|
|
21
|
-
|
|
22
|
-
const onItemLayout = React.useCallback(
|
|
23
|
-
(index) => (event) => {
|
|
24
|
-
const { height } = event.nativeEvent.layout;
|
|
25
|
-
dispatchItemLayout({ payload: { index, height } });
|
|
26
|
-
},
|
|
27
|
-
[]
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const onListLayout = React.useCallback((event) => {
|
|
31
|
-
const { height } = event.nativeEvent.layout;
|
|
32
|
-
setListHeight(height);
|
|
33
|
-
}, []);
|
|
34
|
-
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
if (!notified.current) {
|
|
37
|
-
const finishLoadingVisible = !!itemsLayout.find(
|
|
38
|
-
(item) => item.y > listHeight
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
if (finishLoadingVisible) {
|
|
42
|
-
notified.current = true;
|
|
43
|
-
onFinishLoadingVisible?.();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, [itemsLayout, listHeight]);
|
|
47
|
-
|
|
48
|
-
return React.useMemo(
|
|
49
|
-
() => ({
|
|
50
|
-
onItemLayout,
|
|
51
|
-
onListLayout,
|
|
52
|
-
}),
|
|
53
|
-
[]
|
|
54
|
-
);
|
|
55
|
-
};
|