@onekeyfe/react-native-pager-view 6.7.0-31 → 6.7.0-33
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.
|
@@ -87,6 +87,8 @@ internal class CollapsiblePagerAdapter : RecyclerView.Adapter<ViewPagerViewHolde
|
|
|
87
87
|
*/
|
|
88
88
|
// OneKey patch: Match the standard pager's nested horizontal gesture host.
|
|
89
89
|
// Original: class CollapsiblePagerHost(context: Context) : FrameLayout(context), NestedScrollingParent3 {
|
|
90
|
+
// Kept for react-native-bottom-tabs, which calls `tryScrollToTop` by name on a tab double press.
|
|
91
|
+
@androidx.annotation.Keep
|
|
90
92
|
class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), NestedScrollingParent3 {
|
|
91
93
|
private enum class HeaderGestureOwner {
|
|
92
94
|
NONE,
|
|
@@ -1130,11 +1132,22 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
|
|
|
1130
1132
|
cancelPagerTop()
|
|
1131
1133
|
}
|
|
1132
1134
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1135
|
+
@androidx.annotation.Keep
|
|
1136
|
+
fun scrollToTop(target: Int, animated: Boolean) {
|
|
1137
|
+
tryScrollToTop(target, animated)
|
|
1136
1138
|
}
|
|
1137
1139
|
|
|
1140
|
+
@androidx.annotation.Keep
|
|
1141
|
+
fun tryScrollToTop(target: Int, animated: Boolean): Boolean {
|
|
1142
|
+
if (target !in 0..1) return false
|
|
1143
|
+
return scrollHeaderToOffset(if (target == 1) headerHeightPx else 0, animated)
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// The header offset is stored apart from the body, so a collapsed header can sit
|
|
1147
|
+
// above a body that is already at its top.
|
|
1148
|
+
@androidx.annotation.Keep
|
|
1149
|
+
fun isAwayFromPageTop(): Boolean = headerOffsetPx > 0
|
|
1150
|
+
|
|
1138
1151
|
internal fun scrollHeaderBy(delta: Double) {
|
|
1139
1152
|
if (!delta.isFinite()) return
|
|
1140
1153
|
val density = resources.displayMetrics.density.toDouble()
|
|
@@ -1150,13 +1163,13 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
|
|
|
1150
1163
|
scrollHeaderToOffset(targetPx, false)
|
|
1151
1164
|
}
|
|
1152
1165
|
|
|
1153
|
-
private fun scrollHeaderToOffset(logicalOffset: Int, animated: Boolean) {
|
|
1166
|
+
private fun scrollHeaderToOffset(logicalOffset: Int, animated: Boolean): Boolean {
|
|
1154
1167
|
if (pager.scrollState != ViewPager2.SCROLL_STATE_IDLE || transitionHeaderOffsets != null ||
|
|
1155
|
-
syntheticPageRestore || selectedPage !in 0 until adapter.itemCount || !isAttachedToWindow) return
|
|
1156
|
-
val view = observedRecyclerView ?: observedOwnedScroller ?: observedNativeScroller ?: return
|
|
1168
|
+
syntheticPageRestore || selectedPage !in 0 until adapter.itemCount || !isAttachedToWindow) return false
|
|
1169
|
+
val view = observedRecyclerView ?: observedOwnedScroller ?: observedNativeScroller ?: return false
|
|
1157
1170
|
val key = currentPageKey()
|
|
1158
1171
|
val ownerKey = observedRecyclerKey ?: observedOwnedScrollerKey ?: observedNativeScrollerKey
|
|
1159
|
-
if (ownerKey != key || !view.isAttachedToWindow || primaryScrollableForPage(selectedPage) !== view) return
|
|
1172
|
+
if (ownerKey != key || !view.isAttachedToWindow || primaryScrollableForPage(selectedPage) !== view) return false
|
|
1160
1173
|
// Finish old child notifications before installing the new Pager-owned target.
|
|
1161
1174
|
cancelPagerTop()
|
|
1162
1175
|
if (view is RecyclerView) {
|
|
@@ -1203,6 +1216,7 @@ class CollapsiblePagerHost(context: Context) : NestedScrollableHost(context), Ne
|
|
|
1203
1216
|
}
|
|
1204
1217
|
} finally { dispatchingPagerTop = false }
|
|
1205
1218
|
finishPagerTopIfSettled()
|
|
1219
|
+
return true
|
|
1206
1220
|
}
|
|
1207
1221
|
|
|
1208
1222
|
private fun hasExplicitTopCommand(view: View, key: String): Boolean {
|
package/docs/SPEC.md
CHANGED
|
@@ -264,6 +264,22 @@ intent. Real vertical consumption, a newer valid command, or owner detachment
|
|
|
264
264
|
releases the target. Existing NativeList and NativeScroller public coordinates
|
|
265
265
|
are unchanged. The same page-top/sticky-top destinations are available without smooth-header mode.
|
|
266
266
|
|
|
267
|
+
On Android, `CollapsiblePagerHost.tryScrollToTop(target, animated)` and
|
|
268
|
+
`isAwayFromPageTop()` are public and kept from minification because
|
|
269
|
+
`react-native-bottom-tabs` calls them by name on a tab double press, as neither
|
|
270
|
+
package depends on the other. `tryScrollToTop` returns true only after the
|
|
271
|
+
existing page-top command accepts a stable, attached current owner; invalid
|
|
272
|
+
targets, horizontal transitions, restoration and missing/stale owners return
|
|
273
|
+
false without queueing a command. Acceptance does not mean animation completion.
|
|
274
|
+
`isAwayFromPageTop` is true while the header offset is above zero, whatever the
|
|
275
|
+
body offset. iOS exposes the same `tryScrollToTop:animated:` Boolean result and
|
|
276
|
+
`isAwayFromPageTop` selector. Renaming either breaks that caller silently.
|
|
277
|
+
The existing Fabric `scrollToTop` command remains void on both platforms and
|
|
278
|
+
uses the same acceptance path; JavaScript commands and public refs are unchanged.
|
|
279
|
+
BottomTabs and Pager native sources must ship together for this entry point.
|
|
280
|
+
The acceptance-returning entry point is implemented in source; runtime
|
|
281
|
+
acceptance during horizontal transitions and owner loss remains pending.
|
|
282
|
+
|
|
267
283
|
## Current-page partial header command
|
|
268
284
|
|
|
269
285
|
`scrollHeaderBy(delta: number)` moves the current page's shared collapsible
|
|
@@ -6784,8 +6784,20 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
|
|
|
6784
6784
|
|
|
6785
6785
|
- (void)scrollToTop:(NSInteger)target animated:(BOOL)animated
|
|
6786
6786
|
{
|
|
6787
|
-
|
|
6788
|
-
|
|
6787
|
+
[self tryScrollToTop:target animated:animated];
|
|
6788
|
+
}
|
|
6789
|
+
|
|
6790
|
+
- (BOOL)tryScrollToTop:(NSInteger)target animated:(BOOL)animated
|
|
6791
|
+
{
|
|
6792
|
+
if (target != 0 && target != 1) return NO;
|
|
6793
|
+
return [self scrollHeaderToOffset:(target == 1 ? _headerHeight : 0) animated:animated];
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6796
|
+
// The header offset is stored apart from the body, so a collapsed header can sit
|
|
6797
|
+
// above a body that is already at its top.
|
|
6798
|
+
- (BOOL)isAwayFromPageTop
|
|
6799
|
+
{
|
|
6800
|
+
return _headerOffset > 0.5;
|
|
6789
6801
|
}
|
|
6790
6802
|
|
|
6791
6803
|
- (void)scrollHeaderBy:(double)delta
|
|
@@ -6800,7 +6812,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
|
|
|
6800
6812
|
[self scrollHeaderToOffset:MIN(MAX(offset, 0), _headerHeight) animated:NO];
|
|
6801
6813
|
}
|
|
6802
6814
|
|
|
6803
|
-
- (
|
|
6815
|
+
- (BOOL)scrollHeaderToOffset:(CGFloat)logicalTarget animated:(BOOL)animated
|
|
6804
6816
|
{
|
|
6805
6817
|
[self cancelTopInsetReboundCheck];
|
|
6806
6818
|
UIScrollView *scrollView = _observedScrollView;
|
|
@@ -6808,7 +6820,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
|
|
|
6808
6820
|
if (_isBeingRecycled || _transitioning || _isPagerDragging ||
|
|
6809
6821
|
_transitionPageOffsets != nil || _syntheticPageRestore || scrollView == nil || scrollView.window == nil ||
|
|
6810
6822
|
key == nil || ![key isEqualToString:self.currentPageKey] || _observedPageIndex != _currentIndex ||
|
|
6811
|
-
_observedPageGeneration != _generation || self.window == nil) return;
|
|
6823
|
+
_observedPageGeneration != _generation || self.window == nil) return NO;
|
|
6812
6824
|
[self cancelPagerTop];
|
|
6813
6825
|
// Old List phase2 notifications must run before the new target owns this page.
|
|
6814
6826
|
[NSNotificationCenter.defaultCenter postNotificationName:@"OneKeyNativeListCancelScrollCommand" object:scrollView];
|
|
@@ -6838,6 +6850,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
|
|
|
6838
6850
|
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, physicalTarget) animated:animated];
|
|
6839
6851
|
_dispatchingPagerTop = NO;
|
|
6840
6852
|
[self finishPagerTopIfReached];
|
|
6853
|
+
return YES;
|
|
6841
6854
|
}
|
|
6842
6855
|
|
|
6843
6856
|
- (void)setPage:(NSInteger)index
|