@onekeyfe/react-native-pager-view 6.7.0-alpha.475 → 6.8.0-10

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.
@@ -201,11 +201,27 @@ struct RNCScrollCandidateResolution {
201
201
  @property (nonatomic, assign) BOOL ownsTransitionHosts;
202
202
  @property (nonatomic, strong) UIView *ownedTopHost;
203
203
  @property (nonatomic, strong) UIView *ownedStickyHost;
204
+ @property (nonatomic, strong) UIScrollView *standInScrollView;
204
205
  @end
205
206
 
206
207
  @implementation RNCCollapsiblePagerTransitionEdgeOwner
207
208
  @end
208
209
 
210
+ // OneKey patch: overlay content (popover, sheet, dialog) stays mounted inside
211
+ // its host view until the overlay window presents it, so a host can sit in a
212
+ // page's subtree. That content is never the page's scroller: adopting its
213
+ // scroll view applies the collapsed-header offset to it, and the sheet then
214
+ // opens scrolled past its content.
215
+ static BOOL RNCIsNativeOverlayHost(UIView *view)
216
+ {
217
+ // Looked up by name: the overlay package is optional here. Main thread only.
218
+ static Class overlayHostClass = Nil;
219
+ if (overlayHostClass == Nil) {
220
+ overlayHostClass = NSClassFromString(@"RCTNativeOverlayComponentView");
221
+ }
222
+ return overlayHostClass != Nil && [view isKindOfClass:overlayHostClass];
223
+ }
224
+
209
225
  static UIView *RNCScrollComponentView(UIScrollView *scrollView)
210
226
  {
211
227
  for (UIView *view = scrollView; view != nil; view = view.superview) {
@@ -492,6 +508,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
492
508
  CGFloat _contentPaddingVertical;
493
509
  BOOL _segmented;
494
510
  BOOL _textVariant;
511
+ BOOL _pillVariant;
495
512
  NSDictionary *_config;
496
513
  RNCPagerToolbarButton *_toolbarButton;
497
514
  NSString *_toolbarKey;
@@ -677,6 +694,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
677
694
  BOOL wasSegmented = _segmented;
678
695
  _segmented = [variant isEqualToString:@"segmented"];
679
696
  _textVariant = [variant isEqualToString:@"text"];
697
+ _pillVariant = [variant isEqualToString:@"pill"];
680
698
  _contentPaddingHorizontal = MAX(0, contentPaddingHorizontal);
681
699
  _contentPaddingVertical = MAX(0, contentPaddingVertical);
682
700
  _itemSpacing = MAX(0, itemSpacing);
@@ -749,15 +767,39 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
749
767
  RNCLogNativeTabScrollBoundary(@"primary", @"end", scrollView, _scrollStartOffsetX);
750
768
  }
751
769
 
770
+ - (CGFloat)itemPaddingHorizontal
771
+ {
772
+ id value = _config[@"itemPaddingHorizontal"];
773
+ if ([value isKindOfClass:NSNumber.class] && std::isfinite([value doubleValue]) && [value doubleValue] >= 0) {
774
+ return [value doubleValue];
775
+ }
776
+ return _textVariant ? 10 : (_pillVariant ? 14 : 8);
777
+ }
778
+
779
+ // The tab row and toolbar share a centered band no wider than contentMaxWidth;
780
+ // the bar background still covers the full width.
781
+ - (CGRect)contentRowFrame
782
+ {
783
+ CGFloat width = CGRectGetWidth(self.bounds);
784
+ id value = _config[@"contentMaxWidth"];
785
+ if ([value isKindOfClass:NSNumber.class] && std::isfinite([value doubleValue]) && [value doubleValue] > 0 &&
786
+ [value doubleValue] < width) {
787
+ CGFloat rowWidth = [value doubleValue];
788
+ return CGRectMake(floor((width - rowWidth) / 2), 0, rowWidth, CGRectGetHeight(self.bounds));
789
+ }
790
+ return self.bounds;
791
+ }
792
+
752
793
  - (void)layoutSubviews
753
794
  {
754
795
  [super layoutSubviews];
755
796
  CGFloat reserved = _toolbarReservedWidth;
797
+ CGRect row = [self contentRowFrame];
756
798
  [self bringSubviewToFront:_toolbarButton];
757
- _scrollView.frame = CGRectMake(_leftToRight ? 0 : reserved, 0,
758
- MAX(0, CGRectGetWidth(self.bounds) - reserved), CGRectGetHeight(self.bounds));
799
+ _scrollView.frame = CGRectMake(CGRectGetMinX(row) + (_leftToRight ? 0 : reserved), 0,
800
+ MAX(0, CGRectGetWidth(row) - reserved), CGRectGetHeight(self.bounds));
759
801
  CGFloat inset = _toolbarTrailingInset - (_toolbarSize - _toolbarContentWidth) / 2;
760
- _toolbarButton.frame = CGRectMake(_leftToRight ? CGRectGetWidth(self.bounds) - inset - _toolbarSize : inset,
802
+ _toolbarButton.frame = CGRectMake(_leftToRight ? CGRectGetMaxX(row) - inset - _toolbarSize : CGRectGetMinX(row) + inset,
761
803
  (CGRectGetHeight(self.bounds) - _toolbarSize) / 2, _toolbarSize, _toolbarSize);
762
804
  if (_segmented) {
763
805
  CGFloat width = CGRectGetWidth(_scrollView.bounds);
@@ -796,7 +838,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
796
838
  UIFont *activeFont = self.activeTabFont;
797
839
  textWidth = MAX(textWidth, ceil([title sizeWithAttributes:@{NSFontAttributeName: activeFont}].width));
798
840
  }
799
- CGFloat buttonWidth = MAX(44, textWidth + (_textVariant ? 20 : 16));
841
+ CGFloat buttonWidth = MAX(44, textWidth + 2 * self.itemPaddingHorizontal);
800
842
  [widths addObject:@(buttonWidth)];
801
843
  itemsWidth += buttonWidth;
802
844
  }
@@ -812,6 +854,14 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
812
854
  [_buttons enumerateObjectsUsingBlock:^(UIButton *button, NSUInteger index, BOOL *stop) {
813
855
  CGFloat buttonWidth = widths[index].doubleValue;
814
856
  if (!self->_leftToRight) x -= buttonWidth;
857
+ if (self->_pillVariant) {
858
+ CGFloat insetY = MIN(self->_contentPaddingVertical, self->_barHeight / 2);
859
+ button.frame = CGRectMake(x, insetY, buttonWidth, MAX(0, self->_barHeight - 2 * insetY));
860
+ [self->_indicatorFrames addObject:[NSValue valueWithCGRect:button.frame]];
861
+ if (self->_leftToRight) x += buttonWidth + self->_itemSpacing;
862
+ else x -= self->_itemSpacing;
863
+ return;
864
+ }
815
865
  button.frame = CGRectMake(x, 0, buttonWidth, self->_barHeight);
816
866
  NSString *title = [button titleForState:UIControlStateNormal] ?: @"";
817
867
  CGFloat textWidth = ceil([title sizeWithAttributes:@{NSFontAttributeName: font}].width);
@@ -887,7 +937,14 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
887
937
  [self updateToolbarForKey:key];
888
938
  [self setNeedsLayout];
889
939
  }
890
- - (BOOL)usesControlledTextProgress { return _textVariant && [_config[@"controlled"] boolValue]; }
940
+ - (BOOL)pillAnimationDisabled
941
+ {
942
+ id value = _config[@"indicatorAnimationEnabled"];
943
+ return _pillVariant && [value isKindOfClass:NSNumber.class] && ![value boolValue];
944
+ }
945
+ - (BOOL)usesControlledTextProgress {
946
+ return (_textVariant || (_pillVariant && !self.pillAnimationDisabled)) && [_config[@"controlled"] boolValue];
947
+ }
891
948
  - (void)setLegacyToolbarVisible:(BOOL)visible {
892
949
  _toolbarButton.enabled = visible;
893
950
  _toolbarButton.userInteractionEnabled = visible;
@@ -1323,6 +1380,16 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
1323
1380
  NSInteger count = _buttons.count;
1324
1381
  if (count == 0 || _indicatorFrames.count != count) return;
1325
1382
  CGFloat progress = RNCClamp(_progress, 0, count - 1);
1383
+ BOOL snapToSelection = self.pillAnimationDisabled;
1384
+ if (snapToSelection) {
1385
+ // The pill and label colors jump to the selection instead of following progress.
1386
+ NSInteger snapped = (NSInteger)round(progress);
1387
+ if ([_config[@"controlled"] boolValue]) {
1388
+ NSUInteger selected = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:self->_config[@"selectedKey"]]; }];
1389
+ if (selected != NSNotFound) snapped = (NSInteger)selected;
1390
+ }
1391
+ progress = RNCClamp(snapped, 0, count - 1);
1392
+ }
1326
1393
  NSInteger lower = (NSInteger)floor(progress);
1327
1394
  NSInteger upper = MIN(lower + 1, count - 1);
1328
1395
  CGFloat fraction = progress - lower;
@@ -1334,6 +1401,16 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
1334
1401
  CGRectGetWidth(fromFrame) + (CGRectGetWidth(toFrame) - CGRectGetWidth(fromFrame)) * fraction,
1335
1402
  _segmented ? CGRectGetHeight(fromFrame) : _indicatorHeight
1336
1403
  );
1404
+ if (_pillVariant) {
1405
+ // Leading edge leads and trailing edge lags while moving between tabs.
1406
+ CGFloat leading = 1 - (1 - fraction) * (1 - fraction);
1407
+ CGFloat trailing = fraction * fraction;
1408
+ BOOL forward = CGRectGetMinX(toFrame) >= CGRectGetMinX(fromFrame);
1409
+ CGFloat left = CGRectGetMinX(fromFrame) + (CGRectGetMinX(toFrame) - CGRectGetMinX(fromFrame)) * (forward ? trailing : leading);
1410
+ CGFloat right = CGRectGetMaxX(fromFrame) + (CGRectGetMaxX(toFrame) - CGRectGetMaxX(fromFrame)) * (forward ? leading : trailing);
1411
+ indicatorFrame = CGRectMake(left, CGRectGetMinY(fromFrame), MAX(0, right - left), CGRectGetHeight(fromFrame));
1412
+ _indicatorView.layer.cornerRadius = CGRectGetHeight(indicatorFrame) / 2;
1413
+ }
1337
1414
  _indicatorView.frame = indicatorFrame;
1338
1415
  _indicatorView.hidden = _textVariant || CGRectGetHeight(indicatorFrame) <= 0;
1339
1416
 
@@ -1347,7 +1424,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
1347
1424
  [self updateToolbarForKey:key];
1348
1425
  [_buttons enumerateObjectsUsingBlock:^(UIButton *button, NSUInteger index, BOOL *stop) {
1349
1426
  CGFloat emphasis = 1 - MIN(1, fabs(progress - index));
1350
- if ([self->_config[@"controlled"] boolValue]) {
1427
+ if ([self->_config[@"controlled"] boolValue] && !snapToSelection) {
1351
1428
  emphasis = index == self->_progressSource ? 1 - self->_progressFraction : 0;
1352
1429
  if (index == self->_progressDestination) emphasis += self->_progressFraction;
1353
1430
  }
@@ -2237,6 +2314,9 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
2237
2314
  - (void)adoptCurrentScrollEdgeForProgrammaticTransition:(BOOL)allowExternalOverlay;
2238
2315
  - (RNCCollapsiblePagerTransitionEdgeOwner *)borrowedPinnedStickyOwner;
2239
2316
  - (void)releaseProgrammaticScrollEdge:(UIScrollView *)scrollView;
2317
+ - (BOOL)beginStandInScrollEdgeForPageAtIndex:(NSInteger)pageIndex;
2318
+ - (BOOL)layoutStandInScrollEdgeOwner:(RNCCollapsiblePagerTransitionEdgeOwner *)owner;
2319
+ - (void)layoutStandInScrollEdges;
2240
2320
  - (void)releaseProgrammaticScrollEdgeOwner:(RNCCollapsiblePagerTransitionEdgeOwner *)owner;
2241
2321
  - (void)clearProgrammaticScrollEdges;
2242
2322
  - (void)finishProgrammaticScrollEdges;
@@ -2808,6 +2888,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
2808
2888
 
2809
2889
  - (void)updateScrollEdgeContentMasks
2810
2890
  {
2891
+ [self layoutStandInScrollEdges];
2811
2892
  [self updateHardEdgeSeparatorCovers];
2812
2893
  BOOL enabled = _topScrollEdgeEnabled &&
2813
2894
  (self.hasFixedTopOverlay || _stickyHeaderView != nil) &&
@@ -3088,6 +3169,18 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3088
3169
  for (NSInteger pageIndex = first; pageIndex <= last; pageIndex++) {
3089
3170
  [self preparePageForHorizontalTransitionAtIndex:pageIndex];
3090
3171
  UIScrollView *scrollView = [self verticalScrollViewForPageAtIndex:pageIndex];
3172
+ // A list that is not mounted yet, not laid out under the bars, or not
3173
+ // scrolled past its top cannot render the edge effect behind the bars.
3174
+ BOOL coversBars = scrollView != nil && scrollView.window == self.window &&
3175
+ [scrollView convertPoint:CGPointZero toView:_containerView].y <=
3176
+ [_pageControllers[pageIndex].view convertPoint:CGPointZero toView:_containerView].y + 0.5 &&
3177
+ scrollView.contentOffset.y + scrollView.adjustedContentInset.top > 0.5;
3178
+ // The stand-in applies only while the sticky header is pinned; otherwise
3179
+ // keep the temporary interaction on the page's own list.
3180
+ if (!coversBars && pageIndex != _currentIndex &&
3181
+ [self beginStandInScrollEdgeForPageAtIndex:pageIndex]) {
3182
+ continue;
3183
+ }
3091
3184
  if (scrollView == nil || scrollView.window != self.window) continue;
3092
3185
  if ([_programmaticScrollEdges objectForKey:scrollView] != nil) continue;
3093
3186
  RNCCollapsiblePagerTransitionEdgeOwner *owner = [RNCCollapsiblePagerTransitionEdgeOwner new];
@@ -3168,6 +3261,8 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3168
3261
  owner.stickyInteraction.scrollView = nil;
3169
3262
  [owner.topMarker removeFromSuperview];
3170
3263
  [owner.stickyMarker removeFromSuperview];
3264
+ [owner.standInScrollView removeFromSuperview];
3265
+ owner.standInScrollView = nil;
3171
3266
  if (owner.ownsTransitionHosts) {
3172
3267
  [owner.ownedTopHost removeFromSuperview];
3173
3268
  [owner.ownedStickyHost removeFromSuperview];
@@ -3199,15 +3294,219 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3199
3294
  - (void)finishProgrammaticScrollEdges
3200
3295
  {
3201
3296
  if (_programmaticScrollEdgeOwners.count == 0) return;
3297
+ // OneKey patch: keep the destination's transitional edge alive until the
3298
+ // settled interaction exists, so UIKit does not fade the edge effect back in.
3299
+ UIScrollView *settled = _observedScrollView;
3300
+ RNCCollapsiblePagerTransitionEdgeOwner *handoff =
3301
+ settled != nil ? [_programmaticScrollEdges objectForKey:settled] : nil;
3302
+ if (handoff != nil) {
3303
+ [_programmaticScrollEdges removeObjectForKey:settled];
3304
+ [_programmaticScrollEdgeOwners removeObjectIdenticalTo:handoff];
3305
+ }
3202
3306
  [self clearProgrammaticScrollEdges];
3203
- [self updateTopScrollEdgeForScrollView:_observedScrollView];
3307
+ if (@available(iOS 26.0, *)) {
3308
+ // A cancelled drag settles on the page whose settled edge was adopted.
3309
+ // Return that interaction as-is: a second container interaction for the
3310
+ // same scroll view and host would be torn down together with the old one.
3311
+ if (handoff != nil && !handoff.ownsTransitionHosts && _topEdgeInteraction == nil &&
3312
+ handoff.topHost == _topOverlayHostView &&
3313
+ handoff.topInteraction.scrollView == settled) {
3314
+ _topEdgeInteraction = handoff.topInteraction;
3315
+ _topEdgeInteractionHost = handoff.topHost;
3316
+ _topEdgeMarker = handoff.topMarker;
3317
+ _topEdgeScrollView = settled;
3318
+ _originalTopEdgeStyle = handoff.originalStyle;
3319
+ if (handoff.stickyInteraction != nil && handoff.stickyHost != nil &&
3320
+ handoff.stickyInteraction.scrollView == settled) {
3321
+ _stickyEdgeInteraction = handoff.stickyInteraction;
3322
+ _stickyEdgeInteractionHost = handoff.stickyHost;
3323
+ _stickyEdgeMarker = handoff.stickyMarker;
3324
+ } else {
3325
+ [handoff.stickyHost removeInteraction:handoff.stickyInteraction];
3326
+ handoff.stickyInteraction.scrollView = nil;
3327
+ [handoff.stickyMarker removeFromSuperview];
3328
+ }
3329
+ if (handoff.borrowsPinnedStickyHost && !_stickyHeaderIsPinned &&
3330
+ (_pinnedStickyHostView.superview == settled ||
3331
+ _pinnedStickyHostView.superview == nil)) {
3332
+ _pinnedStickyHostView.hidden = YES;
3333
+ _pinnedStickyHostView.layer.zPosition = 0;
3334
+ [_containerView addSubview:_pinnedStickyHostView];
3335
+ }
3336
+ [self updateTopScrollEdgeForScrollView:settled];
3337
+ return;
3338
+ }
3339
+ }
3340
+ [self updateTopScrollEdgeForScrollView:settled];
3341
+ if (handoff == nil) return;
3342
+ if (@available(iOS 26.0, *)) {
3343
+ if (_topEdgeScrollView == settled && settled != nil) {
3344
+ _originalTopEdgeStyle = handoff.originalStyle;
3345
+ handoff.originalStyle = settled.topEdgeEffect.style;
3346
+ }
3347
+ }
3348
+ if (handoff.borrowsPinnedStickyHost && !_stickyHeaderIsPinned &&
3349
+ (_pinnedStickyHostView.superview == settled ||
3350
+ _pinnedStickyHostView.superview == nil)) {
3351
+ _pinnedStickyHostView.hidden = YES;
3352
+ _pinnedStickyHostView.layer.zPosition = 0;
3353
+ [_containerView addSubview:_pinnedStickyHostView];
3354
+ }
3355
+ handoff.borrowsPinnedStickyHost = NO;
3356
+ // The caller reattaches the shared header in this run loop turn; drop the
3357
+ // transitional resources on the next one, after the header is rendered.
3358
+ dispatch_async(dispatch_get_main_queue(), ^{
3359
+ if (@available(iOS 26.0, *)) {
3360
+ [handoff.topHost removeInteraction:handoff.topInteraction];
3361
+ [handoff.stickyHost removeInteraction:handoff.stickyInteraction];
3362
+ if (handoff.topInteraction.scrollView == handoff.scrollView) {
3363
+ handoff.topInteraction.scrollView = nil;
3364
+ }
3365
+ if (handoff.stickyInteraction.scrollView == handoff.scrollView) {
3366
+ handoff.stickyInteraction.scrollView = nil;
3367
+ }
3368
+ }
3369
+ [handoff.topMarker removeFromSuperview];
3370
+ [handoff.stickyMarker removeFromSuperview];
3371
+ if (handoff.ownsTransitionHosts) {
3372
+ [handoff.ownedTopHost removeFromSuperview];
3373
+ [handoff.ownedStickyHost removeFromSuperview];
3374
+ }
3375
+ });
3376
+ }
3377
+
3378
+ - (BOOL)beginStandInScrollEdgeForPageAtIndex:(NSInteger)pageIndex
3379
+ {
3380
+ // OneKey patch: a page whose list is not mounted yet has no scroll view to
3381
+ // own an edge effect, so its masked top shows the bare background. An empty
3382
+ // stand-in scroll view resting past its top edge renders the same Hard
3383
+ // material (the settled header is masked out under the overlay as well).
3384
+ if (@available(iOS 27.0, *)) {
3385
+ if (pageIndex == _currentIndex || pageIndex < 0 ||
3386
+ pageIndex >= (NSInteger)_pageControllers.count) return NO;
3387
+ UIView *page = _pageControllers[pageIndex].view;
3388
+ UIView *container = page.superview;
3389
+ if (page.window != self.window || container == nil ||
3390
+ _stickyHeaderView == nil || _headerHeight <= 0 ||
3391
+ _headerOffset < _headerHeight - 0.5) return NO;
3392
+ for (RNCCollapsiblePagerTransitionEdgeOwner *existing in _programmaticScrollEdgeOwners) {
3393
+ if (existing.page == page) return YES;
3394
+ }
3395
+ CGFloat boundary = self.effectiveTopOverlayHeight + self.currentStickyHeaderHeight;
3396
+ CGFloat pageTop = [page convertPoint:CGPointZero toView:_containerView].y;
3397
+ if (boundary - pageTop <= 0 || CGRectGetWidth(page.bounds) <= 0) return NO;
3398
+ UIScrollView *standIn = [UIScrollView new];
3399
+ standIn.userInteractionEnabled = NO;
3400
+ standIn.scrollsToTop = NO;
3401
+ standIn.showsVerticalScrollIndicator = NO;
3402
+ standIn.showsHorizontalScrollIndicator = NO;
3403
+ standIn.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
3404
+ standIn.backgroundColor = UIColor.clearColor;
3405
+ standIn.accessibilityElementsHidden = YES;
3406
+ standIn.topEdgeEffect.style = UIScrollEdgeEffectStyle.hardStyle;
3407
+ [container insertSubview:standIn aboveSubview:page];
3408
+
3409
+ RNCCollapsiblePagerTransitionEdgeOwner *owner = [RNCCollapsiblePagerTransitionEdgeOwner new];
3410
+ owner.scrollView = standIn;
3411
+ owner.page = page;
3412
+ owner.standInScrollView = standIn;
3413
+ owner.originalStyle = UIScrollEdgeEffectStyle.hardStyle;
3414
+ owner.ownsTransitionHosts = YES;
3415
+ UIView *(^host)(void) = ^UIView *(void) {
3416
+ UIView *view = [UIView new];
3417
+ view.userInteractionEnabled = NO;
3418
+ view.accessibilityElementsHidden = YES;
3419
+ [container insertSubview:view aboveSubview:standIn];
3420
+ UILabel *marker = [UILabel new];
3421
+ marker.frame = view.bounds;
3422
+ marker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
3423
+ marker.text = @" ";
3424
+ marker.textColor = UIColor.clearColor;
3425
+ marker.backgroundColor = UIColor.clearColor;
3426
+ marker.isAccessibilityElement = NO;
3427
+ [view addSubview:marker];
3428
+ return view;
3429
+ };
3430
+ owner.ownedTopHost = host();
3431
+ owner.topHost = owner.ownedTopHost;
3432
+ owner.topInteraction = [UIScrollEdgeElementContainerInteraction new];
3433
+ owner.topInteraction.edge = UIRectEdgeTop;
3434
+ owner.topInteraction.scrollView = standIn;
3435
+ [owner.topHost addInteraction:owner.topInteraction];
3436
+ owner.ownedStickyHost = host();
3437
+ owner.stickyHost = owner.ownedStickyHost;
3438
+ owner.stickyInteraction = [UIScrollEdgeElementContainerInteraction new];
3439
+ owner.stickyInteraction.edge = UIRectEdgeTop;
3440
+ owner.stickyInteraction.scrollView = standIn;
3441
+ [owner.stickyHost addInteraction:owner.stickyInteraction];
3442
+ if (_programmaticScrollEdges == nil) {
3443
+ _programmaticScrollEdges = [NSMapTable weakToStrongObjectsMapTable];
3444
+ _programmaticScrollEdgeOwners = [NSMutableArray new];
3445
+ }
3446
+ [self layoutStandInScrollEdgeOwner:owner];
3447
+ [_programmaticScrollEdges setObject:owner forKey:standIn];
3448
+ [_programmaticScrollEdgeOwners addObject:owner];
3449
+ return YES;
3450
+ }
3451
+ return NO;
3452
+ }
3453
+
3454
+ // Stand-ins live in the pager container rather than inside their page, so they
3455
+ // do not follow page or header geometry on their own. Recompute them from the
3456
+ // current page origin and overlay + sticky boundary on every layout pass.
3457
+ - (BOOL)layoutStandInScrollEdgeOwner:(RNCCollapsiblePagerTransitionEdgeOwner *)owner
3458
+ {
3459
+ UIScrollView *standIn = owner.standInScrollView;
3460
+ UIView *page = owner.page;
3461
+ UIView *container = standIn.superview;
3462
+ BOOL valid = standIn != nil && page != nil && container != nil &&
3463
+ page.superview == container && _containerView != nil;
3464
+ CGFloat width = valid ? CGRectGetWidth(page.bounds) : 0;
3465
+ CGFloat height = 0;
3466
+ CGPoint origin = CGPointZero;
3467
+ if (valid) {
3468
+ CGFloat boundary = self.effectiveTopOverlayHeight + self.currentStickyHeaderHeight;
3469
+ height = boundary - [page convertPoint:CGPointZero toView:_containerView].y;
3470
+ origin = [page convertPoint:CGPointZero toView:container];
3471
+ valid = width > 0 && height > 0;
3472
+ }
3473
+ standIn.hidden = !valid;
3474
+ owner.ownedTopHost.hidden = !valid;
3475
+ owner.ownedStickyHost.hidden = !valid;
3476
+ if (!valid) return NO;
3477
+ CGRect frame = CGRectMake(origin.x, origin.y, width, height);
3478
+ if (!CGRectEqualToRect(standIn.frame, frame)) standIn.frame = frame;
3479
+ // Rest past the top edge so UIKit draws the edge material.
3480
+ CGFloat scrolled = MAX(_headerHeight, 1);
3481
+ CGSize contentSize = CGSizeMake(width, scrolled + height + 1);
3482
+ if (!CGSizeEqualToSize(standIn.contentSize, contentSize)) standIn.contentSize = contentSize;
3483
+ if (standIn.contentOffset.y != scrolled) standIn.contentOffset = CGPointMake(0, scrolled);
3484
+ void (^place)(UIView *, UIView *) = ^(UIView *host, UIView *reference) {
3485
+ if (host == nil) return;
3486
+ CGRect hostFrame = reference != nil
3487
+ ? [reference convertRect:reference.bounds toView:container] : CGRectZero;
3488
+ hostFrame.origin.x = origin.x;
3489
+ hostFrame.size.width = width;
3490
+ if (!CGRectEqualToRect(host.frame, hostFrame)) host.frame = hostFrame;
3491
+ };
3492
+ place(owner.ownedTopHost, _topOverlayHostView);
3493
+ place(owner.ownedStickyHost, _stickyHeaderView);
3494
+ return YES;
3495
+ }
3496
+
3497
+ - (void)layoutStandInScrollEdges
3498
+ {
3499
+ for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdgeOwners) {
3500
+ if (owner.standInScrollView != nil) [self layoutStandInScrollEdgeOwner:owner];
3501
+ }
3204
3502
  }
3205
3503
 
3206
3504
  - (BOOL)hasProgrammaticScrollEdgeForPage:(UIView *)page
3207
3505
  {
3208
3506
  if (@available(iOS 26.0, *)) {
3209
3507
  for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdges.objectEnumerator) {
3210
- if (owner.page == page && owner.scrollView.window == self.window &&
3508
+ if (owner.page == page && owner.standInScrollView == nil &&
3509
+ owner.scrollView.window == self.window &&
3211
3510
  owner.topInteraction.scrollView == owner.scrollView) return YES;
3212
3511
  }
3213
3512
  }
@@ -3320,10 +3619,22 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3320
3619
 
3321
3620
  - (void)updateHardEdgeSeparatorCovers
3322
3621
  {
3622
+ // OneKey patch: transitional edge owners draw the same Hard hairline while
3623
+ // the settled interaction is detached, so keep the covers during transitions.
3624
+ BOOL transitional = _programmaticScrollEdgeOwners.count > 0;
3323
3625
  BOOL enabled = _topScrollEdgeEnabled &&
3324
3626
  _topScrollEdgeEffect == RNCCollapsiblePagerViewTopScrollEdgeEffect::Hard &&
3325
- _topEdgeScrollView != nil && self.window != nil && !_isBeingRecycled;
3627
+ (_topEdgeScrollView != nil || transitional) && self.window != nil && !_isBeingRecycled;
3326
3628
  if (!enabled && _topEdgeSeparatorCover == nil && _stickyEdgeSeparatorCover == nil) return;
3629
+ BOOL transitionalSticky = NO;
3630
+ if (transitional && _topEdgeScrollView == nil) {
3631
+ for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdgeOwners) {
3632
+ if (owner.stickyInteraction != nil) {
3633
+ transitionalSticky = YES;
3634
+ break;
3635
+ }
3636
+ }
3637
+ }
3327
3638
  UIColor *color = nil;
3328
3639
  for (UIView *view = self; view != nil; view = view.superview) {
3329
3640
  UIColor *candidate = [view.backgroundColor resolvedColorWithTraitCollection:
@@ -3337,7 +3648,13 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3337
3648
  _topOverlayHostView.traitCollection];
3338
3649
  CGFloat scale = self.window.screen.scale ?: self.traitCollection.displayScale;
3339
3650
  CGFloat pixel = 1.0 / MAX(1, scale);
3340
- UIView *hosts[] = {_topEdgeInteractionHost, _stickyEdgeInteractionHost};
3651
+ UIView *topHost = _topEdgeInteractionHost;
3652
+ UIView *stickyHost = _stickyEdgeInteractionHost;
3653
+ if (_topEdgeScrollView == nil && transitional) {
3654
+ topHost = _topOverlayHostView;
3655
+ stickyHost = transitionalSticky ? _stickyHeaderView : nil;
3656
+ }
3657
+ UIView *hosts[] = {topHost, stickyHost};
3341
3658
  CALayer *covers[] = {_topEdgeSeparatorCover, _stickyEdgeSeparatorCover};
3342
3659
  for (NSInteger index = 0; index < 2; index++) {
3343
3660
  UIView *host = hosts[index];
@@ -3360,7 +3677,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
3360
3677
  CGRectGetWidth(_containerView.bounds), pixel);
3361
3678
  cover.contentsScale = scale;
3362
3679
  cover.backgroundColor = color.CGColor;
3363
- cover.hidden = index == 0 && _stickyHeaderIsPinned;
3680
+ cover.hidden = index == 0 && (_stickyHeaderIsPinned || transitionalSticky);
3364
3681
  }
3365
3682
  if (index == 0) _topEdgeSeparatorCover = cover;
3366
3683
  else _stickyEdgeSeparatorCover = cover;
@@ -4788,7 +5105,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
4788
5105
  - (RNCScrollCandidateResolution)resolveScrollCandidateInView:(UIView *)view
4789
5106
  {
4790
5107
  RNCScrollCandidateResolution resolution;
4791
- if (view == nil || view == _sharedHeaderHostView) return resolution;
5108
+ if (view == nil || view == _sharedHeaderHostView || RNCIsNativeOverlayHost(view)) return resolution;
4792
5109
  if (view != self &&
4793
5110
  [view isKindOfClass:RNCCollapsiblePagerViewComponentView.class]) {
4794
5111
  UIScrollView *nested = [(RNCCollapsiblePagerViewComponentView *)view
@@ -4879,7 +5196,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
4879
5196
 
4880
5197
  - (UIScrollView *)findExplicitNativeScrollerInView:(UIView *)view
4881
5198
  {
4882
- if (view == _sharedHeaderHostView) return nil;
5199
+ if (view == _sharedHeaderHostView || RNCIsNativeOverlayHost(view)) return nil;
4883
5200
  if (view != self &&
4884
5201
  [view isKindOfClass:RNCCollapsiblePagerViewComponentView.class]) {
4885
5202
  return [(RNCCollapsiblePagerViewComponentView *)view
@@ -4906,7 +5223,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
4906
5223
 
4907
5224
  - (UIScrollView *)findFabricScrollViewInView:(UIView *)view
4908
5225
  {
4909
- if (view == _sharedHeaderHostView) return nil;
5226
+ if (view == _sharedHeaderHostView || RNCIsNativeOverlayHost(view)) return nil;
4910
5227
  if (view != self &&
4911
5228
  [view isKindOfClass:RNCCollapsiblePagerViewComponentView.class]) {
4912
5229
  return [(RNCCollapsiblePagerViewComponentView *)view
@@ -4929,7 +5246,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
4929
5246
 
4930
5247
  - (UIScrollView *)findVerticalScrollViewInView:(UIView *)view
4931
5248
  {
4932
- if (view == _sharedHeaderHostView ||
5249
+ if (view == _sharedHeaderHostView || RNCIsNativeOverlayHost(view) ||
4933
5250
  ([view isKindOfClass:UIScrollView.class] &&
4934
5251
  [_mountingRemovedScrollViews containsObject:(UIScrollView *)view])) return nil;
4935
5252
  // A parent pager must follow the nested pager's active page instead of the
@@ -5776,6 +6093,10 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
5776
6093
  restoredLogicalOffset = _headerOffset + (_headerOffset >= _headerHeight ? body : 0);
5777
6094
  if (_transitionPageOffsets != nil) [_transitionCompensatedPages addIndex:pageIndex];
5778
6095
  if (deferredReleasedIdentity || scrollView.bounds.size.height <= 0 || scrollView.contentSize.height <= 0) {
6096
+ // Align a fresh page before content measurement while retaining its pending restore.
6097
+ if (!deferredReleasedIdentity && saved == nil && _headerOffset == 0) {
6098
+ [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, -next.top) animated:NO];
6099
+ }
5779
6100
  [_pendingPageRestoreKeys addObject:pageKey];
5780
6101
  _syntheticPageRestore = previousSyntheticRestore;
5781
6102
  return;
@@ -5931,12 +6252,15 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
5931
6252
  }
5932
6253
  }
5933
6254
  if (pageIndex == NSNotFound) return;
6255
+ if ([self verticalScrollViewForPageAtIndex:pageIndex] != scrollView) return;
5934
6256
 
5935
6257
  NSString *pageKey = [self pageKeyForIndex:pageIndex];
5936
6258
  BOOL hasReleasedStateForPage = _releasedPageScrollStates[pageKey] != nil;
5937
6259
  BOOL currentPageNeedsOwner = pageIndex == _currentIndex &&
5938
6260
  (_awaitingScrollOwnerForCurrentPage || _needsScrollObserverReattachAfterMount ||
5939
6261
  hasReleasedStateForPage ||
6262
+ (_observedScrollView == nil &&
6263
+ (_scrollReconcileScheduled || RNCIsMountedNativeListScrollView(scrollView))) ||
5940
6264
  (_observedScrollView != nil &&
5941
6265
  [_observedScrollView isKindOfClass:UICollectionView.class] &&
5942
6266
  !RNCIsMountedNativeListScrollView(_observedScrollView) &&
@@ -6784,8 +7108,20 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
6784
7108
 
6785
7109
  - (void)scrollToTop:(NSInteger)target animated:(BOOL)animated
6786
7110
  {
6787
- if (target != 0 && target != 1) return;
6788
- [self scrollHeaderToOffset:(target == 1 ? _headerHeight : 0) animated:animated];
7111
+ [self tryScrollToTop:target animated:animated];
7112
+ }
7113
+
7114
+ - (BOOL)tryScrollToTop:(NSInteger)target animated:(BOOL)animated
7115
+ {
7116
+ if (target != 0 && target != 1) return NO;
7117
+ return [self scrollHeaderToOffset:(target == 1 ? _headerHeight : 0) animated:animated];
7118
+ }
7119
+
7120
+ // The header offset is stored apart from the body, so a collapsed header can sit
7121
+ // above a body that is already at its top.
7122
+ - (BOOL)isAwayFromPageTop
7123
+ {
7124
+ return _headerOffset > 0.5;
6789
7125
  }
6790
7126
 
6791
7127
  - (void)scrollHeaderBy:(double)delta
@@ -6800,7 +7136,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
6800
7136
  [self scrollHeaderToOffset:MIN(MAX(offset, 0), _headerHeight) animated:NO];
6801
7137
  }
6802
7138
 
6803
- - (void)scrollHeaderToOffset:(CGFloat)logicalTarget animated:(BOOL)animated
7139
+ - (BOOL)scrollHeaderToOffset:(CGFloat)logicalTarget animated:(BOOL)animated
6804
7140
  {
6805
7141
  [self cancelTopInsetReboundCheck];
6806
7142
  UIScrollView *scrollView = _observedScrollView;
@@ -6808,7 +7144,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
6808
7144
  if (_isBeingRecycled || _transitioning || _isPagerDragging ||
6809
7145
  _transitionPageOffsets != nil || _syntheticPageRestore || scrollView == nil || scrollView.window == nil ||
6810
7146
  key == nil || ![key isEqualToString:self.currentPageKey] || _observedPageIndex != _currentIndex ||
6811
- _observedPageGeneration != _generation || self.window == nil) return;
7147
+ _observedPageGeneration != _generation || self.window == nil) return NO;
6812
7148
  [self cancelPagerTop];
6813
7149
  // Old List phase2 notifications must run before the new target owns this page.
6814
7150
  [NSNotificationCenter.defaultCenter postNotificationName:@"OneKeyNativeListCancelScrollCommand" object:scrollView];
@@ -6838,6 +7174,7 @@ static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFl
6838
7174
  [scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, physicalTarget) animated:animated];
6839
7175
  _dispatchingPagerTop = NO;
6840
7176
  [self finishPagerTopIfReached];
7177
+ return YES;
6841
7178
  }
6842
7179
 
6843
7180
  - (void)setPage:(NSInteger)index