@onekeyfe/react-native-pager-view 3.0.157-alpha.258 → 3.0.157-alpha.273
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/README.md +4 -0
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerHost.kt +69 -27
- package/android/src/main/java/com/reactnativepagerview/NativeScrollerPendingRestore.kt +26 -0
- package/android/src/main/java/com/reactnativepagerview/NativeScrollerView.kt +37 -10
- package/android/src/main/java/com/reactnativepagerview/NativeScrollerViewManager.kt +16 -1
- package/android/src/test/java/com/reactnativepagerview/NativeScrollerPendingRestoreTest.kt +31 -0
- package/docs/SPEC.md +59 -4
- package/ios/RNCCollapsiblePagerViewComponentView.mm +52 -2
- package/ios/tests/RNCCollapsiblePagerPressCancellationTests.mm +470 -4
- package/ios/tests/RNCCollapsiblePagerRefreshControlTests.mm +69 -0
- package/lib/module/CollapsiblePagerView.js +10 -1
- package/lib/typescript/src/CollapsiblePagerView.d.ts +1 -0
- package/package.json +2 -2
- package/src/CollapsiblePagerView.tsx +11 -1
|
@@ -30,6 +30,10 @@ export class CollapsiblePagerView extends React.PureComponent {
|
|
|
30
30
|
lastMountSignature = null;
|
|
31
31
|
nativeTabCommandId = 0;
|
|
32
32
|
latestNativeTabTarget = null;
|
|
33
|
+
|
|
34
|
+
// Target of the last tab command native has received and not yet reported
|
|
35
|
+
// as selected. Commands superseded before their frame never reach native.
|
|
36
|
+
dispatchedNativeTabTarget = null;
|
|
33
37
|
latestNativeSelectedPage = this.state.selectedPage;
|
|
34
38
|
nativePagerScrollState = "idle";
|
|
35
39
|
nativeTabCommandQueuedDuringScroll = false;
|
|
@@ -89,6 +93,7 @@ export class CollapsiblePagerView extends React.PureComponent {
|
|
|
89
93
|
if (commandId !== this.nativeTabCommandId || !this.nativeRef) {
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
96
|
+
this.dispatchedNativeTabTarget = position;
|
|
92
97
|
if (animated) {
|
|
93
98
|
CollapsiblePagerViewNativeCommands.setPage(this.nativeRef, position);
|
|
94
99
|
} else {
|
|
@@ -136,6 +141,7 @@ export class CollapsiblePagerView extends React.PureComponent {
|
|
|
136
141
|
const transitionComplete = pendingTarget === position;
|
|
137
142
|
if (transitionComplete) {
|
|
138
143
|
this.latestNativeTabTarget = null;
|
|
144
|
+
this.dispatchedNativeTabTarget = null;
|
|
139
145
|
this.nativeTabCommandQueuedDuringScroll = false;
|
|
140
146
|
}
|
|
141
147
|
this.setState({
|
|
@@ -154,6 +160,7 @@ export class CollapsiblePagerView extends React.PureComponent {
|
|
|
154
160
|
if (scrollState === "idle" && this.latestNativeTabTarget !== null && this.latestNativeTabTarget !== this.latestNativeSelectedPage && !queuedDuringPreviousScroll) {
|
|
155
161
|
++this.nativeTabCommandId;
|
|
156
162
|
this.latestNativeTabTarget = null;
|
|
163
|
+
this.dispatchedNativeTabTarget = null;
|
|
157
164
|
this.setState({
|
|
158
165
|
transientRetainedPages: []
|
|
159
166
|
}, this.notifyMountedPagesChanged);
|
|
@@ -166,7 +173,9 @@ export class CollapsiblePagerView extends React.PureComponent {
|
|
|
166
173
|
onNativeTabPress = event => {
|
|
167
174
|
const position = pageIndex(event.nativeEvent.position);
|
|
168
175
|
if (position !== null && position >= 0 && position < this.pages().length && (position !== this.state.selectedPage || this.latestNativeTabTarget !== null)) {
|
|
169
|
-
|
|
176
|
+
// Selection state lags an in-flight transition until native reports it.
|
|
177
|
+
const currentPage = this.dispatchedNativeTabTarget ?? this.state.selectedPage;
|
|
178
|
+
this.dispatchNativeTabPageCommand(position, this.props.nativeTabPressAnimationEnabled ?? Math.abs(position - currentPage) <= 1);
|
|
170
179
|
}
|
|
171
180
|
this.props.onNativeTabPress?.(event);
|
|
172
181
|
};
|
|
@@ -105,6 +105,7 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
105
105
|
private lastMountSignature;
|
|
106
106
|
private nativeTabCommandId;
|
|
107
107
|
private latestNativeTabTarget;
|
|
108
|
+
private dispatchedNativeTabTarget;
|
|
108
109
|
private latestNativeSelectedPage;
|
|
109
110
|
private nativePagerScrollState;
|
|
110
111
|
private nativeTabCommandQueuedDuringScroll;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-pager-view",
|
|
3
|
-
"version": "3.0.157-alpha.
|
|
3
|
+
"version": "3.0.157-alpha.273",
|
|
4
4
|
"description": "React Native wrapper for Android and iOS ViewPager",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"typescript": "^5.9.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@onekeyfe/react-native-native-logger": "3.0.157-alpha.
|
|
72
|
+
"@onekeyfe/react-native-native-logger": "3.0.157-alpha.273",
|
|
73
73
|
"react": "*",
|
|
74
74
|
"react-native": "*"
|
|
75
75
|
},
|
|
@@ -190,6 +190,10 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
190
190
|
|
|
191
191
|
private latestNativeTabTarget: number | null = null;
|
|
192
192
|
|
|
193
|
+
// Target of the last tab command native has received and not yet reported
|
|
194
|
+
// as selected. Commands superseded before their frame never reach native.
|
|
195
|
+
private dispatchedNativeTabTarget: number | null = null;
|
|
196
|
+
|
|
193
197
|
private latestNativeSelectedPage = this.state.selectedPage;
|
|
194
198
|
|
|
195
199
|
private nativePagerScrollState: OnPageScrollStateChangedEventData["pageScrollState"] =
|
|
@@ -282,6 +286,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
282
286
|
if (commandId !== this.nativeTabCommandId || !this.nativeRef) {
|
|
283
287
|
return;
|
|
284
288
|
}
|
|
289
|
+
this.dispatchedNativeTabTarget = position;
|
|
285
290
|
if (animated) {
|
|
286
291
|
CollapsiblePagerViewNativeCommands.setPage(
|
|
287
292
|
this.nativeRef,
|
|
@@ -354,6 +359,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
354
359
|
const transitionComplete = pendingTarget === position;
|
|
355
360
|
if (transitionComplete) {
|
|
356
361
|
this.latestNativeTabTarget = null;
|
|
362
|
+
this.dispatchedNativeTabTarget = null;
|
|
357
363
|
this.nativeTabCommandQueuedDuringScroll = false;
|
|
358
364
|
}
|
|
359
365
|
this.setState(
|
|
@@ -386,6 +392,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
386
392
|
) {
|
|
387
393
|
++this.nativeTabCommandId;
|
|
388
394
|
this.latestNativeTabTarget = null;
|
|
395
|
+
this.dispatchedNativeTabTarget = null;
|
|
389
396
|
this.setState(
|
|
390
397
|
{ transientRetainedPages: [] },
|
|
391
398
|
this.notifyMountedPagesChanged
|
|
@@ -408,10 +415,13 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
408
415
|
(position !== this.state.selectedPage ||
|
|
409
416
|
this.latestNativeTabTarget !== null)
|
|
410
417
|
) {
|
|
418
|
+
// Selection state lags an in-flight transition until native reports it.
|
|
419
|
+
const currentPage =
|
|
420
|
+
this.dispatchedNativeTabTarget ?? this.state.selectedPage;
|
|
411
421
|
this.dispatchNativeTabPageCommand(
|
|
412
422
|
position,
|
|
413
423
|
this.props.nativeTabPressAnimationEnabled ??
|
|
414
|
-
Math.abs(position -
|
|
424
|
+
Math.abs(position - currentPage) <= 1
|
|
415
425
|
);
|
|
416
426
|
}
|
|
417
427
|
this.props.onNativeTabPress?.(event);
|