@applicaster/zapp-react-native-ui-components 14.0.10 → 14.0.11
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.
|
@@ -23,6 +23,7 @@ import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
|
23
23
|
import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
|
|
24
24
|
import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
25
25
|
import { useShallow } from "zustand/react/shallow";
|
|
26
|
+
import { emitScrollEndReached } from "@applicaster/zapp-react-native-ui-components/events";
|
|
26
27
|
|
|
27
28
|
import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
28
29
|
import { ComponentsMapHeightContext } from "./ContextProviders/ComponentsMapHeightContext";
|
|
@@ -73,6 +74,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
73
74
|
|
|
74
75
|
const flatListRef = React.useRef<FlatList | null>(null);
|
|
75
76
|
const flatListWrapperRef = React.useRef<View | null>(null);
|
|
77
|
+
const hasUserScrolledRef = React.useRef(false);
|
|
76
78
|
const screenConfig = useScreenConfiguration(riverId);
|
|
77
79
|
const screenData = useScreenData(riverId);
|
|
78
80
|
const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
|
|
@@ -236,6 +238,8 @@ function ComponentsMapComponent(props: Props) {
|
|
|
236
238
|
}, []);
|
|
237
239
|
|
|
238
240
|
const onScroll = React.useCallback((event) => {
|
|
241
|
+
hasUserScrolledRef.current = true;
|
|
242
|
+
|
|
239
243
|
const {
|
|
240
244
|
nativeEvent: {
|
|
241
245
|
contentOffset: { y },
|
|
@@ -308,6 +312,17 @@ function ComponentsMapComponent(props: Props) {
|
|
|
308
312
|
onScrollEndDrag={_onScrollEndDrag}
|
|
309
313
|
scrollEventThrottle={16}
|
|
310
314
|
{...scrollViewExtraProps}
|
|
315
|
+
/* When wrapped in a parent ScrollView (e.g. tabs),
|
|
316
|
+
this FlatList doesn't scroll so onEndReached can fire repeatedly;
|
|
317
|
+
skip it here and let the parent ScrollView emit scroll-end instead. */
|
|
318
|
+
onEndReached={
|
|
319
|
+
isScreenWrappedInContainer
|
|
320
|
+
? undefined
|
|
321
|
+
: () => {
|
|
322
|
+
if (!hasUserScrolledRef.current) return;
|
|
323
|
+
emitScrollEndReached();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
311
326
|
/>
|
|
312
327
|
</ViewportTracker>
|
|
313
328
|
</ScreenLoadingMeasurements>
|
|
@@ -137,6 +137,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
137
137
|
keyExtractor={[Function]}
|
|
138
138
|
maxToRenderPerBatch={10}
|
|
139
139
|
onContentSizeChange={[Function]}
|
|
140
|
+
onEndReached={[Function]}
|
|
140
141
|
onLayout={[Function]}
|
|
141
142
|
onMomentumScrollBegin={[Function]}
|
|
142
143
|
onMomentumScrollEnd={[Function]}
|
package/events/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
import { throttleTime } from "rxjs/operators";
|
|
3
|
+
|
|
4
|
+
const SCROLL_END_THROTTLE_MS = 1000;
|
|
5
|
+
const scrollEndReachedSubject = new Subject<void>();
|
|
6
|
+
|
|
7
|
+
/* Throttle so we only emit at most once per second; RN often fires onEndReached repeatedly (e.g. on Android) when near the bottom. */
|
|
8
|
+
export const scrollEndReached$ = scrollEndReachedSubject.pipe(
|
|
9
|
+
throttleTime(SCROLL_END_THROTTLE_MS)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
/* Call from scroll container (ComponentsMap or Tabs) when scroll reaches end. */
|
|
13
|
+
export const emitScrollEndReached = (): void => {
|
|
14
|
+
scrollEndReachedSubject.next();
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.11",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "14.0.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "14.0.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "14.0.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "14.0.
|
|
31
|
+
"@applicaster/applicaster-types": "14.0.11",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "14.0.11",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "14.0.11",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "14.0.11",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"url": "^0.11.0",
|