@onekeyfe/react-native-pager-view 6.7.0-3 → 6.7.0-31
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 +21 -0
- package/android/build.gradle +1 -0
- package/android/src/androidTest/AndroidManifest.xml +7 -0
- package/android/src/androidTest/java/com/reactnativepagerview/CollapsiblePagerTabReservationTest.kt +476 -0
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerHost.kt +215 -39
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerNativeHeaders.kt +518 -21
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerViewManager.kt +40 -0
- package/android/src/main/java/com/reactnativepagerview/NativeScrollerScrollAwayInsets.kt +19 -0
- package/android/src/main/java/com/reactnativepagerview/NativeScrollerView.kt +50 -6
- package/android/src/main/java/com/reactnativepagerview/NestedScrollableHost.kt +8 -2
- package/android/src/main/java/com/reactnativepagerview/event/NativeHeaderPressEvent.kt +8 -0
- package/android/src/test/java/com/reactnativepagerview/NativeScrollerScrollAwayInsetsTest.kt +40 -0
- package/docs/SPEC.md +606 -10
- package/ios/RNCCollapsiblePagerViewComponentView.mm +1903 -91
- package/ios/RNCNativeScrollerComponentView.h +2 -0
- package/ios/RNCNativeScrollerComponentView.mm +42 -0
- package/ios/tests/RNCCollapsiblePagerFirstFrameTests.mm +562 -1
- package/ios/tests/RNCCollapsiblePagerHitTestTests.mm +1116 -0
- package/ios/tests/RNCCollapsiblePagerPressCancellationTests.mm +74 -9
- package/ios/tests/RNCCollapsiblePagerRefreshControlTests.mm +50 -0
- package/lib/module/CollapsiblePagerView.js +70 -11
- package/lib/module/CollapsiblePagerView.web.js +532 -8
- package/lib/module/CollapsiblePagerViewNativeComponent.ts +57 -42
- package/lib/module/NativeScroller.web.js +3 -0
- package/lib/module/NativeScrollerNativeComponent.ts +42 -46
- package/lib/module/PagerViewNativeComponent.ts +20 -25
- package/lib/module/WebCollapsiblePagerPage.js +7 -2
- package/lib/module/index.native.js +9 -0
- package/lib/typescript/src/CollapsiblePagerView.d.ts +42 -4
- package/lib/typescript/src/CollapsiblePagerView.web.d.ts +48 -2
- package/lib/typescript/src/CollapsiblePagerViewNativeComponent.d.ts +54 -38
- package/lib/typescript/src/NativeScroller.d.ts +5 -3
- package/lib/typescript/src/NativeScroller.web.d.ts +1 -1
- package/lib/typescript/src/NativeScrollerNativeComponent.d.ts +47 -48
- package/lib/typescript/src/PagerView.d.ts +1 -1
- package/lib/typescript/src/PagerView.web.d.ts +1 -1
- package/lib/typescript/src/PagerViewNativeComponent.d.ts +20 -21
- package/lib/typescript/src/WebCollapsiblePagerPage.d.ts +1 -1
- package/lib/typescript/src/index.native.d.ts +13 -0
- package/lib/typescript/src/usePagerView.d.ts +2 -2
- package/lib/typescript/src/utils.d.ts +2 -2
- package/package.json +22 -7
- package/react-native-pager-view.podspec +1 -0
- package/src/CollapsiblePagerView.tsx +179 -12
- package/src/CollapsiblePagerView.web.tsx +486 -7
- package/src/CollapsiblePagerViewNativeComponent.ts +57 -42
- package/src/NativeScroller.tsx +14 -4
- package/src/NativeScroller.web.tsx +15 -1
- package/src/NativeScrollerNativeComponent.ts +42 -46
- package/src/PagerViewNativeComponent.ts +20 -25
- package/src/WebCollapsiblePagerPage.tsx +7 -2
- package/src/index.native.tsx +30 -0
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
#import "React/RCTSurfaceTouchHandler.h"
|
|
15
15
|
#import "React/RCTTouchHandler.h"
|
|
16
16
|
#import <objc/runtime.h>
|
|
17
|
+
#import <React/RCTConvert.h>
|
|
18
|
+
#import <React/RCTFont.h>
|
|
17
19
|
#import <UIKit/UIGestureRecognizerSubclass.h>
|
|
18
20
|
|
|
19
21
|
// OneKey patch: deduplicate structural mutation parents before scanning the page.
|
|
20
22
|
#include <unordered_set>
|
|
23
|
+
#include <cmath>
|
|
21
24
|
|
|
22
25
|
using namespace facebook::react;
|
|
23
26
|
|
|
@@ -25,6 +28,7 @@ static void *RNCCollapsiblePagerContentOffsetContext = &RNCCollapsiblePagerConte
|
|
|
25
28
|
static void *RNCRefreshControlLayerContext = &RNCRefreshControlLayerContext;
|
|
26
29
|
static void *RNCScrollRefreshControlContext = &RNCScrollRefreshControlContext;
|
|
27
30
|
static char RNCRefreshControlOffsetKey;
|
|
31
|
+
static void RNCCollapsiblePagerLog(NSString *message);
|
|
28
32
|
|
|
29
33
|
@interface RNCRefreshControlOffsetState : NSObject
|
|
30
34
|
+ (void)setOffset:(CGFloat)offset forControl:(UIRefreshControl *)control owner:(id)owner;
|
|
@@ -39,6 +43,10 @@ static char RNCRefreshControlOffsetKey;
|
|
|
39
43
|
BOOL _originalMasksToBounds;
|
|
40
44
|
BOOL _applying;
|
|
41
45
|
BOOL _observing;
|
|
46
|
+
CGFloat _lastLoggedOffset;
|
|
47
|
+
NSUInteger _lastLoggedOwnerCount;
|
|
48
|
+
CGFloat _lastLoggedTransformY;
|
|
49
|
+
BOOL _hasLoggedState;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
- (instancetype)initWithControl:(UIRefreshControl *)control
|
|
@@ -79,6 +87,21 @@ static char RNCRefreshControlOffsetKey;
|
|
|
79
87
|
}
|
|
80
88
|
[CATransaction commit];
|
|
81
89
|
_applying = NO;
|
|
90
|
+
#if DEBUG
|
|
91
|
+
if (!_hasLoggedState || fabs(_lastLoggedOffset - offset) > 0.01 ||
|
|
92
|
+
_lastLoggedOwnerCount != _offsets.count ||
|
|
93
|
+
fabs(_lastLoggedTransformY - transform.m42) > 0.01) {
|
|
94
|
+
_hasLoggedState = YES;
|
|
95
|
+
_lastLoggedOffset = offset;
|
|
96
|
+
_lastLoggedOwnerCount = _offsets.count;
|
|
97
|
+
_lastLoggedTransformY = transform.m42;
|
|
98
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
99
|
+
@"[IOS-HOME-VISUAL] epochMs=%.0f monoMs=%.0f phase=refresh-transform ownerCount=%lu offsetSum=%.1f baselineY=%.1f appliedY=%.1f masksToBounds=%d",
|
|
100
|
+
[NSDate.date timeIntervalSince1970] * 1000, CACurrentMediaTime() * 1000,
|
|
101
|
+
(unsigned long)_offsets.count, offset, _baselineTransform.m42,
|
|
102
|
+
transform.m42, control.layer.masksToBounds]);
|
|
103
|
+
}
|
|
104
|
+
#endif
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
+ (void)setOffset:(CGFloat)offset forControl:(UIRefreshControl *)control owner:(id)owner
|
|
@@ -137,6 +160,20 @@ static NSString *const RNCCollapsiblePagerNativeScrollerIDPrefix =
|
|
|
137
160
|
|
|
138
161
|
static const CFTimeInterval RNCCollapsiblePagerFallbackDebounceInterval = 0.5;
|
|
139
162
|
|
|
163
|
+
typedef NS_ENUM(NSInteger, RNCScrollCandidateTier) {
|
|
164
|
+
RNCScrollCandidateTierNone = 0,
|
|
165
|
+
RNCScrollCandidateTierGenericFallback = 1,
|
|
166
|
+
RNCScrollCandidateTierVerifiedNativeList = 2,
|
|
167
|
+
RNCScrollCandidateTierFabricScrollView = 3,
|
|
168
|
+
RNCScrollCandidateTierExplicitScroller = 4,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
struct RNCScrollCandidateResolution {
|
|
172
|
+
UIScrollView *scrollView = nil;
|
|
173
|
+
RNCScrollCandidateTier tier = RNCScrollCandidateTierNone;
|
|
174
|
+
BOOL hasUnreadyScrollHost = NO;
|
|
175
|
+
};
|
|
176
|
+
|
|
140
177
|
// OneKey patch: native scroll views can survive a move or be reused for a new
|
|
141
178
|
// Fabric component. Keep weak identity until their page is attached again.
|
|
142
179
|
@interface RNCCollapsiblePagerReleasedScrollState : NSObject
|
|
@@ -150,6 +187,25 @@ static const CFTimeInterval RNCCollapsiblePagerFallbackDebounceInterval = 0.5;
|
|
|
150
187
|
@implementation RNCCollapsiblePagerReleasedScrollState
|
|
151
188
|
@end
|
|
152
189
|
|
|
190
|
+
@interface RNCCollapsiblePagerTransitionEdgeOwner : NSObject
|
|
191
|
+
@property (nonatomic, weak) UIScrollView *scrollView;
|
|
192
|
+
@property (nonatomic, weak) UIView *page;
|
|
193
|
+
@property (nonatomic, strong) UIScrollEdgeEffectStyle *originalStyle;
|
|
194
|
+
@property (nonatomic, strong) UIScrollEdgeElementContainerInteraction *topInteraction;
|
|
195
|
+
@property (nonatomic, strong) UIScrollEdgeElementContainerInteraction *stickyInteraction;
|
|
196
|
+
@property (nonatomic, weak) UIView *topHost;
|
|
197
|
+
@property (nonatomic, weak) UIView *stickyHost;
|
|
198
|
+
@property (nonatomic, strong) UILabel *topMarker;
|
|
199
|
+
@property (nonatomic, strong) UILabel *stickyMarker;
|
|
200
|
+
@property (nonatomic, assign) BOOL borrowsPinnedStickyHost;
|
|
201
|
+
@property (nonatomic, assign) BOOL ownsTransitionHosts;
|
|
202
|
+
@property (nonatomic, strong) UIView *ownedTopHost;
|
|
203
|
+
@property (nonatomic, strong) UIView *ownedStickyHost;
|
|
204
|
+
@end
|
|
205
|
+
|
|
206
|
+
@implementation RNCCollapsiblePagerTransitionEdgeOwner
|
|
207
|
+
@end
|
|
208
|
+
|
|
153
209
|
static UIView *RNCScrollComponentView(UIScrollView *scrollView)
|
|
154
210
|
{
|
|
155
211
|
for (UIView *view = scrollView; view != nil; view = view.superview) {
|
|
@@ -344,11 +400,70 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
344
400
|
(long)pagerState]);
|
|
345
401
|
}
|
|
346
402
|
|
|
403
|
+
static CGFloat RNCPagerToolbarDimension(NSDictionary *entry, NSString *key, CGFloat fallback, CGFloat minimum, CGFloat maximum)
|
|
404
|
+
{
|
|
405
|
+
id value = entry[key];
|
|
406
|
+
if (![value isKindOfClass:NSNumber.class]) return fallback;
|
|
407
|
+
double dimension = [value doubleValue];
|
|
408
|
+
return std::isfinite(dimension) ? MIN(maximum, MAX(minimum, dimension)) : fallback;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
@protocol RNCPagerNamedSVGBridge <NSObject>
|
|
412
|
+
+ (void)cancelWithOwner:(id)owner;
|
|
413
|
+
+ (void)requestWithOwner:(id)owner name:(NSString *)name color:(NSString *)color
|
|
414
|
+
width:(NSInteger)width height:(NSInteger)height scale:(double)scale
|
|
415
|
+
complete:(void (^)(UIImage *))complete;
|
|
416
|
+
@end
|
|
417
|
+
|
|
418
|
+
@interface RNCPagerToolbarButton : UIButton
|
|
419
|
+
@property (nonatomic, strong) UIColor *baseColor;
|
|
420
|
+
@property (nonatomic, strong) UIColor *hoverColor;
|
|
421
|
+
@property (nonatomic, strong) UIColor *pressedColor;
|
|
422
|
+
@property (nonatomic) BOOL hovering;
|
|
423
|
+
@property (nonatomic) CGFloat iconSize;
|
|
424
|
+
- (void)refreshBackground;
|
|
425
|
+
@end
|
|
426
|
+
@implementation RNCPagerToolbarButton
|
|
427
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
428
|
+
if ((self = [super initWithFrame:frame])) {
|
|
429
|
+
self.adjustsImageWhenHighlighted = NO;
|
|
430
|
+
[self addGestureRecognizer:[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hover:)]];
|
|
431
|
+
}
|
|
432
|
+
return self;
|
|
433
|
+
}
|
|
434
|
+
- (CGRect)imageRectForContentRect:(CGRect)contentRect {
|
|
435
|
+
CGFloat side = MIN(self.iconSize, MIN(CGRectGetWidth(contentRect), CGRectGetHeight(contentRect)));
|
|
436
|
+
return CGRectMake(CGRectGetMidX(contentRect) - side / 2, CGRectGetMidY(contentRect) - side / 2, side, side);
|
|
437
|
+
}
|
|
438
|
+
- (void)hover:(UIHoverGestureRecognizer *)gesture {
|
|
439
|
+
self.hovering = gesture.state == UIGestureRecognizerStateBegan || gesture.state == UIGestureRecognizerStateChanged;
|
|
440
|
+
[self refreshBackground];
|
|
441
|
+
}
|
|
442
|
+
- (void)setEnabled:(BOOL)enabled {
|
|
443
|
+
[super setEnabled:enabled];
|
|
444
|
+
if (!enabled) self.hovering = NO;
|
|
445
|
+
[self refreshBackground];
|
|
446
|
+
}
|
|
447
|
+
- (void)setHighlighted:(BOOL)highlighted {
|
|
448
|
+
[super setHighlighted:highlighted];
|
|
449
|
+
[self refreshBackground];
|
|
450
|
+
}
|
|
451
|
+
- (void)refreshBackground {
|
|
452
|
+
self.backgroundColor = self.enabled && self.highlighted ? self.pressedColor : (self.enabled && self.hovering ? self.hoverColor : self.baseColor);
|
|
453
|
+
}
|
|
454
|
+
@end
|
|
455
|
+
|
|
347
456
|
@interface RNCCollapsiblePagerNativeTabBarView : UIView <UIScrollViewDelegate>
|
|
348
457
|
@property (nonatomic, copy) RNCCollapsiblePagerNativeTabPressHandler onTabPress;
|
|
458
|
+
@property (nonatomic, copy) void (^onToolbarPress)(NSString *, CGRect);
|
|
459
|
+
@property (nonatomic, copy) void (^onToolbarNeedsSettlement)(void);
|
|
460
|
+
- (void)updateToolbarPagerIndex:(NSInteger)index busy:(BOOL)busy;
|
|
461
|
+
- (void)updateConfigJSON:(NSString *)json;
|
|
349
462
|
- (void)updateItemsJSON:(NSString *)itemsJSON;
|
|
350
463
|
- (void)updateStyleWithHeight:(CGFloat)height
|
|
464
|
+
variant:(NSString *)variant
|
|
351
465
|
contentPaddingHorizontal:(CGFloat)contentPaddingHorizontal
|
|
466
|
+
contentPaddingVertical:(CGFloat)contentPaddingVertical
|
|
352
467
|
itemSpacing:(CGFloat)itemSpacing
|
|
353
468
|
fontSize:(CGFloat)fontSize
|
|
354
469
|
fontFamily:(NSString *)fontFamily
|
|
@@ -359,18 +474,57 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
359
474
|
indicatorHeight:(CGFloat)indicatorHeight
|
|
360
475
|
indicatorBottom:(CGFloat)indicatorBottom;
|
|
361
476
|
- (void)setProgress:(CGFloat)progress;
|
|
477
|
+
- (BOOL)usesControlledTextProgress;
|
|
478
|
+
- (BOOL)ownsSettledToolbar;
|
|
362
479
|
- (void)setLeftToRight:(BOOL)leftToRight;
|
|
363
480
|
- (void)updateAncestorGesturePrecedence;
|
|
364
481
|
@end
|
|
365
482
|
|
|
366
483
|
@implementation RNCCollapsiblePagerNativeTabBarView {
|
|
367
484
|
RNCCollapsiblePagerHorizontalScrollView *_scrollView;
|
|
485
|
+
UIView *_trackView;
|
|
368
486
|
UIView *_indicatorView;
|
|
369
487
|
NSArray<NSDictionary *> *_items;
|
|
370
488
|
NSMutableArray<UIButton *> *_buttons;
|
|
371
489
|
NSMutableArray<NSValue *> *_indicatorFrames;
|
|
372
490
|
CGFloat _barHeight;
|
|
373
491
|
CGFloat _contentPaddingHorizontal;
|
|
492
|
+
CGFloat _contentPaddingVertical;
|
|
493
|
+
BOOL _segmented;
|
|
494
|
+
BOOL _textVariant;
|
|
495
|
+
NSDictionary *_config;
|
|
496
|
+
RNCPagerToolbarButton *_toolbarButton;
|
|
497
|
+
NSString *_toolbarKey;
|
|
498
|
+
BOOL _toolbarPagerBusy;
|
|
499
|
+
NSInteger _toolbarPageIndex;
|
|
500
|
+
NSDictionary *_committedToolbarEntry;
|
|
501
|
+
NSString *_desiredToolbarKey;
|
|
502
|
+
NSDictionary *_desiredToolbarEntry;
|
|
503
|
+
UIImage *_loadedToolbarImage;
|
|
504
|
+
BOOL _toolbarPresenceAnimating;
|
|
505
|
+
BOOL _toolbarPresenceInterrupted;
|
|
506
|
+
NSString *_toolbarTouchKey;
|
|
507
|
+
BOOL _toolbarTouchStarted;
|
|
508
|
+
NSString *_iconIdentity;
|
|
509
|
+
NSObject *_iconOwner;
|
|
510
|
+
NSInteger _progressSource;
|
|
511
|
+
NSInteger _progressDestination;
|
|
512
|
+
CGFloat _progressFraction;
|
|
513
|
+
CGFloat _nativeProgress;
|
|
514
|
+
BOOL _hasNativeProgress;
|
|
515
|
+
BOOL _hasMappedPageProgress;
|
|
516
|
+
CGFloat _toolbarReservedWidth;
|
|
517
|
+
BOOL _toolbarVisible;
|
|
518
|
+
NSUInteger _toolbarAnimationGeneration;
|
|
519
|
+
NSString *_loadedIconIdentity;
|
|
520
|
+
BOOL _iconRequestPending;
|
|
521
|
+
UIImage *_readyToolbarImage;
|
|
522
|
+
NSString *_readyToolbarIdentity;
|
|
523
|
+
NSString *_failedIconIdentity;
|
|
524
|
+
CGFloat _toolbarSize;
|
|
525
|
+
CGFloat _toolbarIconSize;
|
|
526
|
+
CGFloat _toolbarContentWidth;
|
|
527
|
+
CGFloat _toolbarTrailingInset;
|
|
374
528
|
CGFloat _itemSpacing;
|
|
375
529
|
CGFloat _fontSize;
|
|
376
530
|
NSString *_fontFamily;
|
|
@@ -389,10 +543,27 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
389
543
|
{
|
|
390
544
|
if (self = [super initWithFrame:frame]) {
|
|
391
545
|
_items = @[];
|
|
546
|
+
_config = @{};
|
|
547
|
+
_toolbarPagerBusy = YES;
|
|
548
|
+
_toolbarPageIndex = -1;
|
|
549
|
+
_toolbarButton = [RNCPagerToolbarButton new];
|
|
550
|
+
_toolbarButton.layer.cornerRadius = 19;
|
|
551
|
+
_toolbarButton.hidden = YES;
|
|
552
|
+
_toolbarButton.alpha = 0;
|
|
553
|
+
_toolbarButton.userInteractionEnabled = NO;
|
|
554
|
+
_toolbarButton.accessibilityElementsHidden = YES;
|
|
555
|
+
_toolbarButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
556
|
+
_toolbarButton.iconSize = 24;
|
|
557
|
+
[_toolbarButton addTarget:self action:@selector(toolbarTouchDown) forControlEvents:UIControlEventTouchDown];
|
|
558
|
+
[_toolbarButton addTarget:self action:@selector(toolbarPress:forEvent:) forControlEvents:UIControlEventTouchUpInside];
|
|
559
|
+
[_toolbarButton addTarget:self action:@selector(toolbarCancel) forControlEvents:UIControlEventTouchCancel | UIControlEventTouchUpOutside];
|
|
560
|
+
[self addSubview:_toolbarButton];
|
|
392
561
|
_buttons = [NSMutableArray new];
|
|
393
562
|
_indicatorFrames = [NSMutableArray new];
|
|
394
563
|
_barHeight = 44;
|
|
395
564
|
_contentPaddingHorizontal = 20;
|
|
565
|
+
_contentPaddingVertical = 0;
|
|
566
|
+
_segmented = NO;
|
|
396
567
|
_itemSpacing = 8;
|
|
397
568
|
_fontSize = 16;
|
|
398
569
|
_activeTextColor = UIColor.labelColor;
|
|
@@ -414,6 +585,10 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
414
585
|
_scrollView.delegate = self;
|
|
415
586
|
[self addSubview:_scrollView];
|
|
416
587
|
|
|
588
|
+
_trackView = [UIView new];
|
|
589
|
+
_trackView.userInteractionEnabled = NO;
|
|
590
|
+
[_scrollView addSubview:_trackView];
|
|
591
|
+
|
|
417
592
|
_indicatorView = [UIView new];
|
|
418
593
|
_indicatorView.userInteractionEnabled = NO;
|
|
419
594
|
[_scrollView addSubview:_indicatorView];
|
|
@@ -430,6 +605,18 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
430
605
|
return [UIFont systemFontOfSize:_fontSize weight:UIFontWeightMedium];
|
|
431
606
|
}
|
|
432
607
|
|
|
608
|
+
- (UIFont *)activeTabFont
|
|
609
|
+
{
|
|
610
|
+
NSString *activeFamily = _config[@"activeFontFamily"];
|
|
611
|
+
if (activeFamily.length > 0) {
|
|
612
|
+
return [UIFont fontWithName:activeFamily size:_fontSize]
|
|
613
|
+
?: [UIFont systemFontOfSize:_fontSize weight:UIFontWeightSemibold];
|
|
614
|
+
}
|
|
615
|
+
UIFont *normalFont = _fontFamily.length > 0 ? [UIFont fontWithName:_fontFamily size:_fontSize] : nil;
|
|
616
|
+
return normalFont != nil ? [RCTFont updateFont:normalFont withWeight:@"600"]
|
|
617
|
+
: [UIFont systemFontOfSize:_fontSize weight:UIFontWeightSemibold];
|
|
618
|
+
}
|
|
619
|
+
|
|
433
620
|
- (void)updateItemsJSON:(NSString *)itemsJSON
|
|
434
621
|
{
|
|
435
622
|
NSData *data = [itemsJSON dataUsingEncoding:NSUTF8StringEncoding];
|
|
@@ -464,11 +651,18 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
464
651
|
for (UIButton *button in _buttons) [_scrollView bringSubviewToFront:button];
|
|
465
652
|
_shouldCenterSelectedItem = YES;
|
|
466
653
|
self.hidden = _items.count == 0;
|
|
654
|
+
if (_hasNativeProgress) [self setProgress:_nativeProgress];
|
|
655
|
+
else if ([_config[@"controlled"] boolValue]) {
|
|
656
|
+
NSUInteger selected = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:self->_config[@"selectedKey"]]; }];
|
|
657
|
+
if (selected != NSNotFound) { _progress = selected; _progressSource = selected; _progressDestination = selected; _progressFraction = 0; }
|
|
658
|
+
}
|
|
467
659
|
[self setNeedsLayout];
|
|
468
660
|
}
|
|
469
661
|
|
|
470
662
|
- (void)updateStyleWithHeight:(CGFloat)height
|
|
663
|
+
variant:(NSString *)variant
|
|
471
664
|
contentPaddingHorizontal:(CGFloat)contentPaddingHorizontal
|
|
665
|
+
contentPaddingVertical:(CGFloat)contentPaddingVertical
|
|
472
666
|
itemSpacing:(CGFloat)itemSpacing
|
|
473
667
|
fontSize:(CGFloat)fontSize
|
|
474
668
|
fontFamily:(NSString *)fontFamily
|
|
@@ -480,19 +674,27 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
480
674
|
indicatorBottom:(CGFloat)indicatorBottom
|
|
481
675
|
{
|
|
482
676
|
_barHeight = MAX(1, height);
|
|
677
|
+
BOOL wasSegmented = _segmented;
|
|
678
|
+
_segmented = [variant isEqualToString:@"segmented"];
|
|
679
|
+
_textVariant = [variant isEqualToString:@"text"];
|
|
483
680
|
_contentPaddingHorizontal = MAX(0, contentPaddingHorizontal);
|
|
681
|
+
_contentPaddingVertical = MAX(0, contentPaddingVertical);
|
|
484
682
|
_itemSpacing = MAX(0, itemSpacing);
|
|
485
683
|
_fontSize = MAX(1, fontSize);
|
|
486
684
|
_fontFamily = [fontFamily copy];
|
|
487
|
-
self.backgroundColor = backgroundColor ?: UIColor.clearColor;
|
|
488
|
-
_scrollView.backgroundColor = self.backgroundColor;
|
|
685
|
+
self.backgroundColor = _segmented ? UIColor.clearColor : (backgroundColor ?: UIColor.clearColor);
|
|
686
|
+
_scrollView.backgroundColor = _textVariant ? UIColor.clearColor : self.backgroundColor;
|
|
687
|
+
_scrollView.scrollEnabled = !_segmented;
|
|
688
|
+
if (_segmented && !wasSegmented) [_scrollView setContentOffset:CGPointZero animated:NO];
|
|
689
|
+
_trackView.hidden = !_segmented;
|
|
690
|
+
_trackView.backgroundColor = backgroundColor ?: UIColor.clearColor;
|
|
489
691
|
_activeTextColor = activeTextColor ?: UIColor.labelColor;
|
|
490
692
|
_inactiveTextColor = inactiveTextColor ?: UIColor.secondaryLabelColor;
|
|
491
693
|
_indicatorColor = indicatorColor ?: _activeTextColor;
|
|
492
694
|
_indicatorHeight = MAX(0, indicatorHeight);
|
|
493
695
|
_indicatorBottom = MAX(0, indicatorBottom);
|
|
494
696
|
_indicatorView.backgroundColor = _indicatorColor;
|
|
495
|
-
_indicatorView.layer.cornerRadius = _indicatorHeight / 2;
|
|
697
|
+
_indicatorView.layer.cornerRadius = _segmented ? 0 : _indicatorHeight / 2;
|
|
496
698
|
for (UIButton *button in _buttons) button.titleLabel.font = self.tabFont;
|
|
497
699
|
[self setNeedsLayout];
|
|
498
700
|
}
|
|
@@ -550,19 +752,56 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
550
752
|
- (void)layoutSubviews
|
|
551
753
|
{
|
|
552
754
|
[super layoutSubviews];
|
|
553
|
-
|
|
755
|
+
CGFloat reserved = _toolbarReservedWidth;
|
|
756
|
+
[self bringSubviewToFront:_toolbarButton];
|
|
757
|
+
_scrollView.frame = CGRectMake(_leftToRight ? 0 : reserved, 0,
|
|
758
|
+
MAX(0, CGRectGetWidth(self.bounds) - reserved), CGRectGetHeight(self.bounds));
|
|
759
|
+
CGFloat inset = _toolbarTrailingInset - (_toolbarSize - _toolbarContentWidth) / 2;
|
|
760
|
+
_toolbarButton.frame = CGRectMake(_leftToRight ? CGRectGetWidth(self.bounds) - inset - _toolbarSize : inset,
|
|
761
|
+
(CGRectGetHeight(self.bounds) - _toolbarSize) / 2, _toolbarSize, _toolbarSize);
|
|
762
|
+
if (_segmented) {
|
|
763
|
+
CGFloat width = CGRectGetWidth(_scrollView.bounds);
|
|
764
|
+
CGFloat height = CGRectGetHeight(self.bounds);
|
|
765
|
+
CGFloat insetX = MIN(_contentPaddingHorizontal, width / 2);
|
|
766
|
+
CGFloat insetY = MIN(_contentPaddingVertical, height / 2);
|
|
767
|
+
CGRect trackFrame = CGRectMake(insetX, insetY,
|
|
768
|
+
MAX(0, width - 2 * insetX), MAX(0, height - 2 * insetY));
|
|
769
|
+
_trackView.frame = trackFrame;
|
|
770
|
+
_trackView.layer.cornerRadius = CGRectGetHeight(trackFrame) / 2;
|
|
771
|
+
_scrollView.contentSize = _scrollView.bounds.size;
|
|
772
|
+
[_indicatorFrames removeAllObjects];
|
|
773
|
+
NSUInteger count = _buttons.count;
|
|
774
|
+
[_buttons enumerateObjectsUsingBlock:^(UIButton *button, NSUInteger index, BOOL *stop) {
|
|
775
|
+
CGFloat first = CGRectGetMinX(trackFrame) + CGRectGetWidth(trackFrame) * index / count;
|
|
776
|
+
CGFloat last = CGRectGetMinX(trackFrame) + CGRectGetWidth(trackFrame) * (index + 1) / count;
|
|
777
|
+
CGFloat x = self->_leftToRight ? first : CGRectGetMaxX(trackFrame) - (last - CGRectGetMinX(trackFrame));
|
|
778
|
+
CGFloat end = self->_leftToRight ? last : CGRectGetMaxX(trackFrame) - (first - CGRectGetMinX(trackFrame));
|
|
779
|
+
button.frame = CGRectMake(x, CGRectGetMinY(trackFrame), MAX(0, end - x), CGRectGetHeight(trackFrame));
|
|
780
|
+
CGRect thumbFrame = CGRectMake(x + 2, CGRectGetMinY(trackFrame) + 2,
|
|
781
|
+
MAX(0, CGRectGetWidth(button.frame) - 4), MAX(0, CGRectGetHeight(trackFrame) - 4));
|
|
782
|
+
[self->_indicatorFrames addObject:[NSValue valueWithCGRect:thumbFrame]];
|
|
783
|
+
}];
|
|
784
|
+
_indicatorView.layer.cornerRadius = MAX(0, CGRectGetHeight(trackFrame) - 4) / 2;
|
|
785
|
+
[self updatePresentation];
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
_trackView.frame = CGRectZero;
|
|
554
789
|
UIFont *font = self.tabFont;
|
|
555
790
|
NSMutableArray<NSNumber *> *widths = [NSMutableArray arrayWithCapacity:_buttons.count];
|
|
556
791
|
CGFloat itemsWidth = 0;
|
|
557
792
|
for (UIButton *button in _buttons) {
|
|
558
793
|
NSString *title = [button titleForState:UIControlStateNormal] ?: @"";
|
|
559
794
|
CGFloat textWidth = ceil([title sizeWithAttributes:@{NSFontAttributeName: font}].width);
|
|
560
|
-
|
|
795
|
+
if (_textVariant) {
|
|
796
|
+
UIFont *activeFont = self.activeTabFont;
|
|
797
|
+
textWidth = MAX(textWidth, ceil([title sizeWithAttributes:@{NSFontAttributeName: activeFont}].width));
|
|
798
|
+
}
|
|
799
|
+
CGFloat buttonWidth = MAX(44, textWidth + (_textVariant ? 20 : 16));
|
|
561
800
|
[widths addObject:@(buttonWidth)];
|
|
562
801
|
itemsWidth += buttonWidth;
|
|
563
802
|
}
|
|
564
803
|
if (_buttons.count > 1) itemsWidth += (_buttons.count - 1) * _itemSpacing;
|
|
565
|
-
CGFloat contentWidth = MAX(CGRectGetWidth(
|
|
804
|
+
CGFloat contentWidth = MAX(CGRectGetWidth(_scrollView.bounds),
|
|
566
805
|
itemsWidth + _contentPaddingHorizontal * 2);
|
|
567
806
|
_scrollView.contentSize = CGSizeMake(contentWidth, MAX(_barHeight, CGRectGetHeight(self.bounds)));
|
|
568
807
|
[_indicatorFrames removeAllObjects];
|
|
@@ -592,14 +831,493 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
592
831
|
[self updatePresentation];
|
|
593
832
|
}
|
|
594
833
|
|
|
834
|
+
- (Class<RNCPagerNamedSVGBridge>)iconBridge {
|
|
835
|
+
Class cls = NSClassFromString(@"OneKeyNamedSVGBridge");
|
|
836
|
+
if (![cls respondsToSelector:@selector(cancelWithOwner:)] ||
|
|
837
|
+
![cls respondsToSelector:@selector(requestWithOwner:name:color:width:height:scale:complete:)]) return Nil;
|
|
838
|
+
return (Class<RNCPagerNamedSVGBridge>)cls;
|
|
839
|
+
}
|
|
840
|
+
- (void)updateConfigJSON:(NSString *)json {
|
|
841
|
+
BOOL wasOwned = [self ownsSettledToolbar];
|
|
842
|
+
NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
|
|
843
|
+
id parsed = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil;
|
|
844
|
+
_config = [parsed isKindOfClass:NSDictionary.class] ? parsed : @{};
|
|
845
|
+
BOOL owned = [self ownsSettledToolbar];
|
|
846
|
+
if (owned != wasOwned) {
|
|
847
|
+
if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner];
|
|
848
|
+
_iconOwner = [NSObject new];
|
|
849
|
+
_iconRequestPending = NO;
|
|
850
|
+
_readyToolbarImage = nil;
|
|
851
|
+
_readyToolbarIdentity = nil;
|
|
852
|
+
_desiredToolbarKey = nil;
|
|
853
|
+
_desiredToolbarEntry = nil;
|
|
854
|
+
[self suspendToolbar];
|
|
855
|
+
if (!owned) {
|
|
856
|
+
++_toolbarAnimationGeneration;
|
|
857
|
+
[_toolbarButton.layer removeAllAnimations];
|
|
858
|
+
_toolbarPresenceAnimating = NO;
|
|
859
|
+
_toolbarPresenceInterrupted = NO;
|
|
860
|
+
_toolbarButton.alpha = _toolbarVisible ? 1 : 0;
|
|
861
|
+
_toolbarButton.hidden = !_toolbarVisible;
|
|
862
|
+
[self setToolbarInteractive:_toolbarVisible];
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (!owned) {
|
|
866
|
+
_toolbarTouchKey = nil;
|
|
867
|
+
_toolbarButton.highlighted = NO;
|
|
868
|
+
_toolbarButton.hovering = NO;
|
|
869
|
+
}
|
|
870
|
+
_toolbarButton.adjustsImageWhenDisabled = !owned;
|
|
871
|
+
NSString *key = _config[@"selectedKey"];
|
|
872
|
+
if (![_config[@"controlled"] boolValue]) {
|
|
873
|
+
_progress = RNCClamp(_nativeProgress, 0, MAX(0, (NSInteger)_items.count - 1));
|
|
874
|
+
key = _items.count ? _items[(NSInteger)round(_progress)][@"key"] : nil;
|
|
875
|
+
}
|
|
876
|
+
if (_hasNativeProgress) {
|
|
877
|
+
[self setProgress:_nativeProgress];
|
|
878
|
+
} else {
|
|
879
|
+
NSUInteger index = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:key]; }];
|
|
880
|
+
if (index != NSNotFound) {
|
|
881
|
+
_progress = index;
|
|
882
|
+
_progressSource = index;
|
|
883
|
+
_progressDestination = index;
|
|
884
|
+
_progressFraction = 0;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
[self updateToolbarForKey:key];
|
|
888
|
+
[self setNeedsLayout];
|
|
889
|
+
}
|
|
890
|
+
- (BOOL)usesControlledTextProgress { return _textVariant && [_config[@"controlled"] boolValue]; }
|
|
891
|
+
- (void)setLegacyToolbarVisible:(BOOL)visible {
|
|
892
|
+
_toolbarButton.enabled = visible;
|
|
893
|
+
_toolbarButton.userInteractionEnabled = visible;
|
|
894
|
+
_toolbarButton.accessibilityElementsHidden = !visible;
|
|
895
|
+
_toolbarButton.isAccessibilityElement = visible;
|
|
896
|
+
if (_toolbarVisible == visible) return;
|
|
897
|
+
_toolbarVisible = visible;
|
|
898
|
+
NSUInteger generation = ++_toolbarAnimationGeneration;
|
|
899
|
+
CALayer *presentation = _toolbarButton.layer.presentationLayer;
|
|
900
|
+
CGFloat alpha = presentation ? presentation.opacity : _toolbarButton.alpha;
|
|
901
|
+
[_toolbarButton.layer removeAllAnimations];
|
|
902
|
+
_toolbarButton.alpha = alpha;
|
|
903
|
+
_toolbarButton.enabled = visible;
|
|
904
|
+
_toolbarButton.userInteractionEnabled = visible;
|
|
905
|
+
_toolbarButton.accessibilityElementsHidden = !visible;
|
|
906
|
+
if (visible) _toolbarButton.hidden = NO;
|
|
907
|
+
if (self.window == nil) {
|
|
908
|
+
_toolbarButton.alpha = visible ? 1 : 0;
|
|
909
|
+
_toolbarButton.hidden = !visible;
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
[UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
|
|
913
|
+
self->_toolbarButton.alpha = visible ? 1 : 0;
|
|
914
|
+
} completion:^(BOOL finished) {
|
|
915
|
+
if (self->_toolbarAnimationGeneration == generation && !visible) {
|
|
916
|
+
self->_toolbarButton.hidden = YES;
|
|
917
|
+
[self applyReadyLegacyToolbarImage];
|
|
918
|
+
}
|
|
919
|
+
}];
|
|
920
|
+
}
|
|
921
|
+
- (void)applyReadyLegacyToolbarImage {
|
|
922
|
+
if (_readyToolbarImage == nil || ![_readyToolbarIdentity isEqualToString:_iconIdentity]) return;
|
|
923
|
+
CALayer *presentation = _toolbarButton.layer.presentationLayer;
|
|
924
|
+
if (_toolbarButton.alpha > 0.001 || (presentation && presentation.opacity > 0.001)) return;
|
|
925
|
+
[_toolbarButton setImage:_readyToolbarImage forState:UIControlStateNormal];
|
|
926
|
+
_loadedIconIdentity = _readyToolbarIdentity;
|
|
927
|
+
_loadedToolbarImage = _readyToolbarImage;
|
|
928
|
+
_readyToolbarImage = nil;
|
|
929
|
+
_readyToolbarIdentity = nil;
|
|
930
|
+
_iconRequestPending = NO;
|
|
931
|
+
[self setLegacyToolbarVisible:YES];
|
|
932
|
+
}
|
|
933
|
+
- (void)updateLegacyToolbarForKey:(NSString *)key {
|
|
934
|
+
NSDictionary *toolbar = [_config[@"toolbar"] isKindOfClass:NSDictionary.class] ? _config[@"toolbar"] : nil;
|
|
935
|
+
_toolbarReservedWidth = toolbar == nil ? 0 : 44;
|
|
936
|
+
if (toolbar.count > 0) {
|
|
937
|
+
_toolbarReservedWidth = 0;
|
|
938
|
+
for (id value in toolbar.allValues) {
|
|
939
|
+
NSDictionary *entry = [value isKindOfClass:NSDictionary.class] ? value : @{};
|
|
940
|
+
CGFloat size = RNCPagerToolbarDimension(entry, @"size", 38, 1, 128);
|
|
941
|
+
CGFloat content = RNCPagerToolbarDimension(entry, @"contentWidth", MIN(24, size), 0, size);
|
|
942
|
+
CGFloat trailing = RNCPagerToolbarDimension(entry, @"trailingInset", 20, 0, 128);
|
|
943
|
+
_toolbarReservedWidth = MAX(_toolbarReservedWidth, content + trailing);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
NSDictionary *entry = [toolbar[key ?: @""] isKindOfClass:NSDictionary.class] ? toolbar[key] : nil;
|
|
947
|
+
NSString *name = [entry[@"iconName"] isKindOfClass:NSString.class] ? entry[@"iconName"] : nil;
|
|
948
|
+
if (![_toolbarKey isEqualToString:key]) {
|
|
949
|
+
_toolbarTouchKey = nil;
|
|
950
|
+
_toolbarButton.highlighted = NO;
|
|
951
|
+
_toolbarButton.hovering = NO;
|
|
952
|
+
}
|
|
953
|
+
_toolbarKey = [key copy];
|
|
954
|
+
if (name.length == 0) {
|
|
955
|
+
_toolbarTouchKey = nil;
|
|
956
|
+
_toolbarButton.accessibilityLabel = nil;
|
|
957
|
+
_toolbarButton.accessibilityIdentifier = nil;
|
|
958
|
+
if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner];
|
|
959
|
+
_iconOwner = [NSObject new];
|
|
960
|
+
_iconRequestPending = NO;
|
|
961
|
+
_readyToolbarImage = nil;
|
|
962
|
+
_readyToolbarIdentity = nil;
|
|
963
|
+
[self setLegacyToolbarVisible:NO];
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
_toolbarSize = RNCPagerToolbarDimension(entry, @"size", 38, 1, 128);
|
|
967
|
+
_toolbarIconSize = RNCPagerToolbarDimension(entry, @"iconSize", MIN(24, _toolbarSize), 1, _toolbarSize);
|
|
968
|
+
_toolbarContentWidth = RNCPagerToolbarDimension(entry, @"contentWidth", MIN(24, _toolbarSize), 0, _toolbarSize);
|
|
969
|
+
_toolbarTrailingInset = RNCPagerToolbarDimension(entry, @"trailingInset", 20, 0, 128);
|
|
970
|
+
_toolbarButton.layer.cornerRadius = _toolbarSize / 2;
|
|
971
|
+
_toolbarButton.iconSize = _toolbarIconSize;
|
|
972
|
+
[_toolbarButton setNeedsLayout];
|
|
973
|
+
_toolbarButton.baseColor = [entry[@"selected"] boolValue] ? ([RCTConvert UIColor:entry[@"selectedBackgroundColor"]] ?: UIColor.clearColor) : UIColor.clearColor;
|
|
974
|
+
_toolbarButton.hoverColor = [RCTConvert UIColor:entry[@"hoverBackgroundColor"]] ?: _toolbarButton.baseColor;
|
|
975
|
+
_toolbarButton.pressedColor = [RCTConvert UIColor:entry[@"pressedBackgroundColor"]] ?: _toolbarButton.baseColor;
|
|
976
|
+
[_toolbarButton refreshBackground];
|
|
977
|
+
_toolbarButton.accessibilityLabel = entry[@"accessibilityLabel"];
|
|
978
|
+
_toolbarButton.accessibilityIdentifier = entry[@"testID"];
|
|
979
|
+
NSString *color = [entry[@"iconColor"] isKindOfClass:NSString.class] ? entry[@"iconColor"] : @"#000000";
|
|
980
|
+
CGFloat scale = self.window.screen.scale ?: UIScreen.mainScreen.scale;
|
|
981
|
+
NSString *identity = [NSString stringWithFormat:@"%@|%@|%g|%g", name, color, scale, _toolbarIconSize];
|
|
982
|
+
if ([_loadedIconIdentity isEqualToString:identity] && [_toolbarButton imageForState:UIControlStateNormal] != nil) {
|
|
983
|
+
if (_iconRequestPending) {
|
|
984
|
+
[[self iconBridge] cancelWithOwner:_iconOwner];
|
|
985
|
+
_iconOwner = [NSObject new];
|
|
986
|
+
}
|
|
987
|
+
_iconIdentity = identity;
|
|
988
|
+
_iconRequestPending = NO;
|
|
989
|
+
_readyToolbarImage = nil;
|
|
990
|
+
_readyToolbarIdentity = nil;
|
|
991
|
+
[self setLegacyToolbarVisible:YES];
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
if ((_iconRequestPending || [_failedIconIdentity isEqualToString:identity]) && [_iconIdentity isEqualToString:identity]) return;
|
|
995
|
+
if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner];
|
|
996
|
+
NSObject *owner = [NSObject new];
|
|
997
|
+
_iconOwner = owner;
|
|
998
|
+
_iconIdentity = identity;
|
|
999
|
+
_iconRequestPending = NO;
|
|
1000
|
+
_readyToolbarImage = nil;
|
|
1001
|
+
_readyToolbarIdentity = nil;
|
|
1002
|
+
[self setLegacyToolbarVisible:NO];
|
|
1003
|
+
if ([_failedIconIdentity isEqualToString:identity] || self.window == nil) return;
|
|
1004
|
+
_iconRequestPending = YES;
|
|
1005
|
+
__weak __typeof__(self) weakSelf = self;
|
|
1006
|
+
[[self iconBridge] requestWithOwner:owner name:name color:color width:(NSInteger)ceil(_toolbarIconSize * scale) height:(NSInteger)ceil(_toolbarIconSize * scale) scale:scale complete:^(UIImage *image) {
|
|
1007
|
+
__strong __typeof__(weakSelf) self = weakSelf;
|
|
1008
|
+
if (!self || self->_iconOwner != owner || ![self->_iconIdentity isEqualToString:identity] || !self.window) return;
|
|
1009
|
+
if (image == nil) {
|
|
1010
|
+
self->_iconRequestPending = NO;
|
|
1011
|
+
self->_failedIconIdentity = identity;
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
UIImage *scaled = image.CGImage ? [UIImage imageWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] : image;
|
|
1015
|
+
self->_readyToolbarImage = [scaled imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
1016
|
+
self->_readyToolbarIdentity = identity;
|
|
1017
|
+
[self applyReadyLegacyToolbarImage];
|
|
1018
|
+
}];
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
- (BOOL)ownsSettledToolbar {
|
|
1022
|
+
return [_config[@"controlled"] boolValue] && [_config[@"toolbar"] isKindOfClass:NSDictionary.class];
|
|
1023
|
+
}
|
|
1024
|
+
- (BOOL)toolbarCanCommit {
|
|
1025
|
+
if (!self.window) return NO;
|
|
1026
|
+
if (![self ownsSettledToolbar]) return YES;
|
|
1027
|
+
if (_toolbarPagerBusy || _toolbarPageIndex < 0) return NO;
|
|
1028
|
+
NSArray *pages = [_config[@"pageKeys"] isKindOfClass:NSArray.class] ? _config[@"pageKeys"] : @[];
|
|
1029
|
+
NSArray *items = [_items valueForKey:@"key"];
|
|
1030
|
+
BOOL valid = pages.count > 0 && [pages containsObject:_config[@"selectedKey"] ?: @""] &&
|
|
1031
|
+
[NSSet setWithArray:pages].count == pages.count && [NSSet setWithArray:items].count == items.count;
|
|
1032
|
+
for (id key in pages) if (![items containsObject:key]) { valid = NO; break; }
|
|
1033
|
+
return !valid || (_toolbarPageIndex < pages.count && [pages[_toolbarPageIndex] isEqual:_config[@"selectedKey"]]);
|
|
1034
|
+
}
|
|
1035
|
+
- (void)setToolbarInteractive:(BOOL)interactive {
|
|
1036
|
+
_toolbarButton.enabled = interactive;
|
|
1037
|
+
_toolbarButton.userInteractionEnabled = interactive;
|
|
1038
|
+
_toolbarButton.accessibilityElementsHidden = !interactive;
|
|
1039
|
+
_toolbarButton.isAccessibilityElement = interactive;
|
|
1040
|
+
if (!interactive) {
|
|
1041
|
+
_toolbarTouchKey = nil;
|
|
1042
|
+
_toolbarButton.highlighted = NO;
|
|
1043
|
+
_toolbarButton.hovering = NO;
|
|
1044
|
+
[_toolbarButton refreshBackground];
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
- (void)cancelToolbarRequest {
|
|
1048
|
+
if (_iconRequestPending || _readyToolbarImage) {
|
|
1049
|
+
if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner];
|
|
1050
|
+
_iconOwner = [NSObject new];
|
|
1051
|
+
_iconRequestPending = NO;
|
|
1052
|
+
_readyToolbarImage = nil;
|
|
1053
|
+
_readyToolbarIdentity = nil;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
- (void)suspendToolbar {
|
|
1057
|
+
[self setToolbarInteractive:NO];
|
|
1058
|
+
[self cancelToolbarRequest];
|
|
1059
|
+
_desiredToolbarKey = nil;
|
|
1060
|
+
_desiredToolbarEntry = nil;
|
|
1061
|
+
if (_toolbarPresenceAnimating) {
|
|
1062
|
+
CALayer *presentation = _toolbarButton.layer.presentationLayer;
|
|
1063
|
+
CGFloat alpha = presentation ? presentation.opacity : _toolbarButton.alpha;
|
|
1064
|
+
++_toolbarAnimationGeneration;
|
|
1065
|
+
[_toolbarButton.layer removeAllAnimations];
|
|
1066
|
+
_toolbarButton.alpha = alpha;
|
|
1067
|
+
_toolbarPresenceAnimating = NO;
|
|
1068
|
+
_toolbarPresenceInterrupted = YES;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
- (void)updateToolbarPagerIndex:(NSInteger)index busy:(BOOL)busy {
|
|
1072
|
+
if (_toolbarPagerBusy == busy && (busy || _toolbarPageIndex == index)) return;
|
|
1073
|
+
_toolbarPagerBusy = busy;
|
|
1074
|
+
if (!busy) _toolbarPageIndex = index;
|
|
1075
|
+
NSString *key = [_config[@"controlled"] boolValue] ? _config[@"selectedKey"] : _toolbarKey;
|
|
1076
|
+
[self updateToolbarForKey:key];
|
|
1077
|
+
}
|
|
1078
|
+
- (void)setToolbarVisible:(BOOL)visible {
|
|
1079
|
+
if (_toolbarVisible == visible && !_toolbarPresenceInterrupted) return;
|
|
1080
|
+
_toolbarVisible = visible;
|
|
1081
|
+
_toolbarPresenceInterrupted = NO;
|
|
1082
|
+
NSUInteger generation = ++_toolbarAnimationGeneration;
|
|
1083
|
+
CALayer *presentation = _toolbarButton.layer.presentationLayer;
|
|
1084
|
+
CGFloat alpha = presentation ? presentation.opacity : _toolbarButton.alpha;
|
|
1085
|
+
[_toolbarButton.layer removeAllAnimations];
|
|
1086
|
+
_toolbarButton.alpha = alpha;
|
|
1087
|
+
if (visible) _toolbarButton.hidden = NO;
|
|
1088
|
+
if (!self.window) {
|
|
1089
|
+
_toolbarPresenceAnimating = NO;
|
|
1090
|
+
_toolbarButton.alpha = visible ? 1 : 0;
|
|
1091
|
+
_toolbarButton.hidden = !visible;
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
_toolbarPresenceAnimating = YES;
|
|
1095
|
+
[UIView animateWithDuration:0.10 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
|
|
1096
|
+
self->_toolbarButton.alpha = visible ? 1 : 0;
|
|
1097
|
+
} completion:^(BOOL finished) {
|
|
1098
|
+
if (self->_toolbarAnimationGeneration != generation) return;
|
|
1099
|
+
self->_toolbarPresenceAnimating = NO;
|
|
1100
|
+
if (!visible) self->_toolbarButton.hidden = YES;
|
|
1101
|
+
}];
|
|
1102
|
+
}
|
|
1103
|
+
- (void)commitToolbarImage:(UIImage *)image identity:(NSString *)identity {
|
|
1104
|
+
if (![self toolbarCanCommit] || !_desiredToolbarKey || !_desiredToolbarEntry) return;
|
|
1105
|
+
NSDictionary *entry = _desiredToolbarEntry;
|
|
1106
|
+
BOOL changed = ![_toolbarKey isEqualToString:_desiredToolbarKey] || ![_committedToolbarEntry isEqual:entry] || _loadedToolbarImage != image;
|
|
1107
|
+
if (![_toolbarKey isEqualToString:_desiredToolbarKey]) [self setToolbarInteractive:NO];
|
|
1108
|
+
_toolbarKey = [_desiredToolbarKey copy];
|
|
1109
|
+
_committedToolbarEntry = entry;
|
|
1110
|
+
_toolbarSize = RNCPagerToolbarDimension(entry, @"size", 38, 1, 128);
|
|
1111
|
+
_toolbarIconSize = RNCPagerToolbarDimension(entry, @"iconSize", MIN(24, _toolbarSize), 1, _toolbarSize);
|
|
1112
|
+
_toolbarContentWidth = RNCPagerToolbarDimension(entry, @"contentWidth", MIN(24, _toolbarSize), 0, _toolbarSize);
|
|
1113
|
+
_toolbarTrailingInset = RNCPagerToolbarDimension(entry, @"trailingInset", 20, 0, 128);
|
|
1114
|
+
_toolbarButton.layer.cornerRadius = _toolbarSize / 2;
|
|
1115
|
+
_toolbarButton.iconSize = _toolbarIconSize;
|
|
1116
|
+
[_toolbarButton setNeedsLayout];
|
|
1117
|
+
_toolbarButton.baseColor = [entry[@"selected"] boolValue] ? ([RCTConvert UIColor:entry[@"selectedBackgroundColor"]] ?: UIColor.clearColor) : UIColor.clearColor;
|
|
1118
|
+
_toolbarButton.hoverColor = [RCTConvert UIColor:entry[@"hoverBackgroundColor"]] ?: _toolbarButton.baseColor;
|
|
1119
|
+
_toolbarButton.pressedColor = [RCTConvert UIColor:entry[@"pressedBackgroundColor"]] ?: _toolbarButton.baseColor;
|
|
1120
|
+
[_toolbarButton refreshBackground];
|
|
1121
|
+
_toolbarButton.accessibilityLabel = entry[@"accessibilityLabel"];
|
|
1122
|
+
_toolbarButton.accessibilityIdentifier = entry[@"testID"];
|
|
1123
|
+
[_toolbarButton setImage:image forState:UIControlStateNormal];
|
|
1124
|
+
_loadedIconIdentity = identity;
|
|
1125
|
+
_loadedToolbarImage = image;
|
|
1126
|
+
_readyToolbarImage = nil;
|
|
1127
|
+
_readyToolbarIdentity = nil;
|
|
1128
|
+
_iconRequestPending = NO;
|
|
1129
|
+
[self setToolbarVisible:YES];
|
|
1130
|
+
[self setToolbarInteractive:YES];
|
|
1131
|
+
if (changed) [self setNeedsLayout];
|
|
1132
|
+
}
|
|
1133
|
+
- (void)applyReadyToolbarImage {
|
|
1134
|
+
if (!_readyToolbarImage || ![_readyToolbarIdentity isEqualToString:_iconIdentity] || ![self toolbarCanCommit]) return;
|
|
1135
|
+
[self commitToolbarImage:_readyToolbarImage identity:_readyToolbarIdentity];
|
|
1136
|
+
}
|
|
1137
|
+
- (void)hideFailedToolbar {
|
|
1138
|
+
[self setToolbarInteractive:NO];
|
|
1139
|
+
_toolbarKey = nil;
|
|
1140
|
+
_committedToolbarEntry = nil;
|
|
1141
|
+
[_toolbarButton setImage:nil forState:UIControlStateNormal];
|
|
1142
|
+
_toolbarButton.accessibilityLabel = nil;
|
|
1143
|
+
_toolbarButton.accessibilityIdentifier = nil;
|
|
1144
|
+
[self setToolbarVisible:NO];
|
|
1145
|
+
}
|
|
1146
|
+
- (void)updateToolbarForKey:(NSString *)key {
|
|
1147
|
+
if (![self ownsSettledToolbar]) { [self updateLegacyToolbarForKey:key]; return; }
|
|
1148
|
+
NSDictionary *toolbar = [_config[@"toolbar"] isKindOfClass:NSDictionary.class] ? _config[@"toolbar"] : nil;
|
|
1149
|
+
_toolbarReservedWidth = toolbar == nil ? 0 : 44;
|
|
1150
|
+
if (toolbar.count > 0) {
|
|
1151
|
+
_toolbarReservedWidth = 0;
|
|
1152
|
+
for (id value in toolbar.allValues) {
|
|
1153
|
+
NSDictionary *entry = [value isKindOfClass:NSDictionary.class] ? value : @{};
|
|
1154
|
+
CGFloat size = RNCPagerToolbarDimension(entry, @"size", 38, 1, 128);
|
|
1155
|
+
CGFloat content = RNCPagerToolbarDimension(entry, @"contentWidth", MIN(24, size), 0, size);
|
|
1156
|
+
CGFloat trailing = RNCPagerToolbarDimension(entry, @"trailingInset", 20, 0, 128);
|
|
1157
|
+
_toolbarReservedWidth = MAX(_toolbarReservedWidth, content + trailing);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
if (![self toolbarCanCommit]) { [self suspendToolbar]; return; }
|
|
1161
|
+
NSDictionary *entry = [toolbar[key ?: @""] isKindOfClass:NSDictionary.class] ? toolbar[key] : nil;
|
|
1162
|
+
NSString *name = [entry[@"iconName"] isKindOfClass:NSString.class] ? entry[@"iconName"] : nil;
|
|
1163
|
+
if (!name.length) {
|
|
1164
|
+
[self cancelToolbarRequest];
|
|
1165
|
+
_desiredToolbarKey = nil;
|
|
1166
|
+
_desiredToolbarEntry = nil;
|
|
1167
|
+
_toolbarKey = nil;
|
|
1168
|
+
_committedToolbarEntry = nil;
|
|
1169
|
+
[self setToolbarInteractive:NO];
|
|
1170
|
+
_toolbarButton.accessibilityLabel = nil;
|
|
1171
|
+
_toolbarButton.accessibilityIdentifier = nil;
|
|
1172
|
+
[self setToolbarVisible:NO];
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
_desiredToolbarKey = [key copy];
|
|
1176
|
+
_desiredToolbarEntry = [entry copy];
|
|
1177
|
+
CGFloat size = RNCPagerToolbarDimension(entry, @"size", 38, 1, 128);
|
|
1178
|
+
CGFloat iconSize = RNCPagerToolbarDimension(entry, @"iconSize", MIN(24, size), 1, size);
|
|
1179
|
+
NSString *color = [entry[@"iconColor"] isKindOfClass:NSString.class] ? entry[@"iconColor"] : @"#000000";
|
|
1180
|
+
CGFloat scale = self.window.screen.scale ?: UIScreen.mainScreen.scale;
|
|
1181
|
+
NSString *identity = [NSString stringWithFormat:@"%@|%@|%g|%g", name, color, scale, iconSize];
|
|
1182
|
+
if ([_loadedIconIdentity isEqualToString:identity] && _loadedToolbarImage) {
|
|
1183
|
+
[self cancelToolbarRequest];
|
|
1184
|
+
_iconIdentity = identity;
|
|
1185
|
+
[self commitToolbarImage:_loadedToolbarImage identity:identity];
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if ([_iconIdentity isEqualToString:identity] && (_iconRequestPending || _readyToolbarImage)) {
|
|
1189
|
+
[self setToolbarInteractive:NO];
|
|
1190
|
+
[self applyReadyToolbarImage];
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
[self cancelToolbarRequest];
|
|
1194
|
+
_iconIdentity = identity;
|
|
1195
|
+
[self setToolbarInteractive:NO];
|
|
1196
|
+
if ([_failedIconIdentity isEqualToString:identity]) { [self hideFailedToolbar]; return; }
|
|
1197
|
+
NSObject *owner = [NSObject new];
|
|
1198
|
+
_iconOwner = owner;
|
|
1199
|
+
_iconRequestPending = YES;
|
|
1200
|
+
__weak __typeof__(self) weakSelf = self;
|
|
1201
|
+
[[self iconBridge] requestWithOwner:owner name:name color:color width:(NSInteger)ceil(iconSize * scale) height:(NSInteger)ceil(iconSize * scale) scale:scale complete:^(UIImage *image) {
|
|
1202
|
+
__strong __typeof__(weakSelf) self = weakSelf;
|
|
1203
|
+
if (!self || self->_iconOwner != owner || ![self->_iconIdentity isEqualToString:identity] || !self.window) return;
|
|
1204
|
+
self->_iconRequestPending = NO;
|
|
1205
|
+
if (!image) {
|
|
1206
|
+
self->_failedIconIdentity = identity;
|
|
1207
|
+
if ([self toolbarCanCommit]) [self hideFailedToolbar];
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
UIImage *scaled = image.CGImage ? [UIImage imageWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp] : image;
|
|
1211
|
+
self->_readyToolbarImage = [scaled imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
1212
|
+
self->_readyToolbarIdentity = identity;
|
|
1213
|
+
[self applyReadyToolbarImage];
|
|
1214
|
+
}];
|
|
1215
|
+
}
|
|
1216
|
+
- (void)didMoveToWindow {
|
|
1217
|
+
[super didMoveToWindow];
|
|
1218
|
+
if (![self ownsSettledToolbar]) {
|
|
1219
|
+
if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner];
|
|
1220
|
+
_iconIdentity = nil;
|
|
1221
|
+
_loadedIconIdentity = nil;
|
|
1222
|
+
_iconRequestPending = NO;
|
|
1223
|
+
_readyToolbarImage = nil;
|
|
1224
|
+
_readyToolbarIdentity = nil;
|
|
1225
|
+
_failedIconIdentity = nil;
|
|
1226
|
+
_iconOwner = [NSObject new];
|
|
1227
|
+
_toolbarAnimationGeneration++;
|
|
1228
|
+
[_toolbarButton.layer removeAllAnimations];
|
|
1229
|
+
_toolbarVisible = NO;
|
|
1230
|
+
_toolbarButton.alpha = 0;
|
|
1231
|
+
_toolbarButton.hidden = YES;
|
|
1232
|
+
_toolbarButton.enabled = NO;
|
|
1233
|
+
_toolbarButton.userInteractionEnabled = NO;
|
|
1234
|
+
_toolbarButton.accessibilityElementsHidden = YES;
|
|
1235
|
+
_toolbarTouchKey = nil;
|
|
1236
|
+
_toolbarTouchStarted = NO;
|
|
1237
|
+
_toolbarButton.highlighted = NO;
|
|
1238
|
+
_toolbarButton.hovering = NO;
|
|
1239
|
+
[self updateToolbarForKey:_toolbarKey];
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
[self suspendToolbar];
|
|
1243
|
+
_toolbarPagerBusy = YES;
|
|
1244
|
+
_toolbarPageIndex = -1;
|
|
1245
|
+
_toolbarTouchStarted = NO;
|
|
1246
|
+
if (self.window && self.onToolbarNeedsSettlement) self.onToolbarNeedsSettlement();
|
|
1247
|
+
}
|
|
1248
|
+
- (void)dealloc { if (_iconOwner) [[self iconBridge] cancelWithOwner:_iconOwner]; }
|
|
1249
|
+
- (void)toolbarTouchDown {
|
|
1250
|
+
_toolbarTouchStarted = YES;
|
|
1251
|
+
_toolbarTouchKey = _toolbarButton.enabled && [self toolbarCanCommit] ? [_toolbarKey copy] : nil;
|
|
1252
|
+
}
|
|
1253
|
+
- (void)toolbarCancel {
|
|
1254
|
+
_toolbarTouchKey = nil;
|
|
1255
|
+
if (![self ownsSettledToolbar]) _toolbarTouchStarted = NO;
|
|
1256
|
+
}
|
|
1257
|
+
- (void)toolbarPress:(UIControl *)sender forEvent:(UIEvent *)event {
|
|
1258
|
+
if (![self ownsSettledToolbar]) {
|
|
1259
|
+
NSString *key = _toolbarTouchStarted ? _toolbarTouchKey : _toolbarKey;
|
|
1260
|
+
_toolbarTouchStarted = NO; _toolbarTouchKey = nil;
|
|
1261
|
+
if (key && [key isEqualToString:_toolbarKey] && !_toolbarButton.hidden && _toolbarButton.enabled && self.window && self.onToolbarPress)
|
|
1262
|
+
self.onToolbarPress(key, [_toolbarButton convertRect:_toolbarButton.bounds toView:self.window]);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
BOOL pointer = event && event.type == UIEventTypeTouches;
|
|
1266
|
+
NSString *key = pointer ? (_toolbarTouchStarted ? _toolbarTouchKey : nil) : _toolbarKey;
|
|
1267
|
+
if (pointer) { _toolbarTouchStarted = NO; _toolbarTouchKey = nil; }
|
|
1268
|
+
BOOL selectedMatches = ![_config[@"controlled"] boolValue] || [key isEqual:_config[@"selectedKey"]];
|
|
1269
|
+
if (key && selectedMatches && [key isEqualToString:_toolbarKey] && [self toolbarCanCommit] &&
|
|
1270
|
+
!_toolbarButton.hidden && _toolbarButton.enabled && self.onToolbarPress) {
|
|
1271
|
+
self.onToolbarPress(key, [_toolbarButton convertRect:_toolbarButton.bounds toView:self.window]);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
595
1275
|
- (void)setProgress:(CGFloat)progress
|
|
596
1276
|
{
|
|
1277
|
+
_hasMappedPageProgress = NO;
|
|
1278
|
+
_nativeProgress = progress;
|
|
1279
|
+
_hasNativeProgress = YES;
|
|
597
1280
|
if (_items.count == 0) return;
|
|
598
1281
|
if (fabs(_progress - progress) >= 0.001) _shouldCenterSelectedItem = YES;
|
|
1282
|
+
if ([_config[@"controlled"] boolValue]) {
|
|
1283
|
+
NSArray *pageKeys = [_config[@"pageKeys"] isKindOfClass:NSArray.class] ? _config[@"pageKeys"] : @[];
|
|
1284
|
+
NSMutableArray<NSNumber *> *indices = [NSMutableArray new];
|
|
1285
|
+
NSSet *unique = [NSSet setWithArray:pageKeys];
|
|
1286
|
+
NSArray *itemKeys = [_items valueForKey:@"key"];
|
|
1287
|
+
BOOL valid = pageKeys.count > 0 && [pageKeys containsObject:_config[@"selectedKey"] ?: @""] && unique.count == pageKeys.count && [NSSet setWithArray:itemKeys].count == itemKeys.count;
|
|
1288
|
+
for (NSString *key in pageKeys) {
|
|
1289
|
+
NSUInteger index = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:key]; }];
|
|
1290
|
+
if (index == NSNotFound) { valid = NO; break; }
|
|
1291
|
+
[indices addObject:@(index)];
|
|
1292
|
+
}
|
|
1293
|
+
if (!valid) {
|
|
1294
|
+
NSUInteger selected = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:self->_config[@"selectedKey"]]; }];
|
|
1295
|
+
if (selected == NSNotFound) return;
|
|
1296
|
+
_progressSource = selected; _progressDestination = selected; _progressFraction = 0;
|
|
1297
|
+
_progress = selected;
|
|
1298
|
+
if (_indicatorFrames.count == _items.count) [self updatePresentation];
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
_hasMappedPageProgress = YES;
|
|
1302
|
+
CGFloat bounded = RNCClamp(progress, 0, pageKeys.count - 1);
|
|
1303
|
+
NSInteger lower = (NSInteger)floor(bounded);
|
|
1304
|
+
NSInteger upper = MIN(lower + 1, pageKeys.count - 1);
|
|
1305
|
+
_progressSource = indices[lower].integerValue;
|
|
1306
|
+
_progressDestination = indices[upper].integerValue;
|
|
1307
|
+
_progressFraction = bounded - lower;
|
|
1308
|
+
progress = _progressSource + (_progressDestination - _progressSource) * _progressFraction;
|
|
1309
|
+
}
|
|
599
1310
|
_progress = RNCClamp(progress, 0, _items.count - 1);
|
|
600
1311
|
if (_indicatorFrames.count == _items.count) [self updatePresentation];
|
|
601
1312
|
}
|
|
602
1313
|
|
|
1314
|
+
- (NSInteger)visualFontOwnerIndex:(NSInteger)semanticIndex {
|
|
1315
|
+
if (_textVariant && [_config[@"controlled"] boolValue] && _hasMappedPageProgress) {
|
|
1316
|
+
return _progressFraction < 0.5 ? _progressSource : _progressDestination;
|
|
1317
|
+
}
|
|
1318
|
+
return semanticIndex;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
603
1321
|
- (void)updatePresentation
|
|
604
1322
|
{
|
|
605
1323
|
NSInteger count = _buttons.count;
|
|
@@ -614,14 +1332,25 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
614
1332
|
CGRectGetMinX(fromFrame) + (CGRectGetMinX(toFrame) - CGRectGetMinX(fromFrame)) * fraction,
|
|
615
1333
|
CGRectGetMinY(fromFrame),
|
|
616
1334
|
CGRectGetWidth(fromFrame) + (CGRectGetWidth(toFrame) - CGRectGetWidth(fromFrame)) * fraction,
|
|
617
|
-
_indicatorHeight
|
|
1335
|
+
_segmented ? CGRectGetHeight(fromFrame) : _indicatorHeight
|
|
618
1336
|
);
|
|
619
1337
|
_indicatorView.frame = indicatorFrame;
|
|
620
|
-
_indicatorView.hidden =
|
|
1338
|
+
_indicatorView.hidden = _textVariant || CGRectGetHeight(indicatorFrame) <= 0;
|
|
621
1339
|
|
|
622
1340
|
NSInteger selectedIndex = (NSInteger)round(progress);
|
|
1341
|
+
if ([_config[@"controlled"] boolValue]) {
|
|
1342
|
+
NSUInteger selected = [_items indexOfObjectPassingTest:^BOOL(NSDictionary *item, NSUInteger i, BOOL *stop) { return [item[@"key"] isEqual:self->_config[@"selectedKey"]]; }];
|
|
1343
|
+
selectedIndex = selected == NSNotFound ? -1 : (NSInteger)selected;
|
|
1344
|
+
}
|
|
1345
|
+
NSInteger fontOwnerIndex = [self visualFontOwnerIndex:selectedIndex];
|
|
1346
|
+
NSString *key = selectedIndex >= 0 && selectedIndex < count ? _items[selectedIndex][@"key"] : nil;
|
|
1347
|
+
[self updateToolbarForKey:key];
|
|
623
1348
|
[_buttons enumerateObjectsUsingBlock:^(UIButton *button, NSUInteger index, BOOL *stop) {
|
|
624
1349
|
CGFloat emphasis = 1 - MIN(1, fabs(progress - index));
|
|
1350
|
+
if ([self->_config[@"controlled"] boolValue]) {
|
|
1351
|
+
emphasis = index == self->_progressSource ? 1 - self->_progressFraction : 0;
|
|
1352
|
+
if (index == self->_progressDestination) emphasis += self->_progressFraction;
|
|
1353
|
+
}
|
|
625
1354
|
UIColor *color = RNCInterpolateColor(
|
|
626
1355
|
self->_inactiveTextColor,
|
|
627
1356
|
self->_activeTextColor,
|
|
@@ -629,12 +1358,17 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
629
1358
|
self.traitCollection
|
|
630
1359
|
);
|
|
631
1360
|
[button setTitleColor:color forState:UIControlStateNormal];
|
|
1361
|
+
if (self->_textVariant) {
|
|
1362
|
+
button.titleLabel.font = index == fontOwnerIndex
|
|
1363
|
+
? self.activeTabFont
|
|
1364
|
+
: self.tabFont;
|
|
1365
|
+
}
|
|
632
1366
|
button.accessibilityTraits = index == selectedIndex
|
|
633
1367
|
? UIAccessibilityTraitButton | UIAccessibilityTraitSelected
|
|
634
1368
|
: UIAccessibilityTraitButton;
|
|
635
1369
|
}];
|
|
636
1370
|
|
|
637
|
-
if (_shouldCenterSelectedItem && !_scrollView.tracking && !_scrollView.dragging &&
|
|
1371
|
+
if (_shouldCenterSelectedItem && !_segmented && !_scrollView.tracking && !_scrollView.dragging &&
|
|
638
1372
|
!_scrollView.decelerating && CGRectGetWidth(_scrollView.bounds) > 0) {
|
|
639
1373
|
CGFloat maximumOffset = MAX(0, _scrollView.contentSize.width - CGRectGetWidth(_scrollView.bounds));
|
|
640
1374
|
CGFloat desiredOffset = RNCClamp(
|
|
@@ -1433,6 +2167,24 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1433
2167
|
- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)other { return YES; }
|
|
1434
2168
|
@end
|
|
1435
2169
|
|
|
2170
|
+
@protocol RNCPagerPresentationProgressTarget <NSObject>
|
|
2171
|
+
- (void)sampleProgrammaticTabProgress:(CADisplayLink *)link;
|
|
2172
|
+
- (void)sampleToolbarSettlement:(CADisplayLink *)link;
|
|
2173
|
+
@end
|
|
2174
|
+
|
|
2175
|
+
@interface RNCPagerPresentationProgressProxy : NSObject
|
|
2176
|
+
@property (nonatomic, weak) id<RNCPagerPresentationProgressTarget> target;
|
|
2177
|
+
@property (nonatomic, assign) BOOL toolbarSettlement;
|
|
2178
|
+
@end
|
|
2179
|
+
@implementation RNCPagerPresentationProgressProxy
|
|
2180
|
+
- (void)tick:(CADisplayLink *)link {
|
|
2181
|
+
id<RNCPagerPresentationProgressTarget> target = self.target;
|
|
2182
|
+
if (target && self.toolbarSettlement) [target sampleToolbarSettlement:link];
|
|
2183
|
+
else if (target) [target sampleProgrammaticTabProgress:link];
|
|
2184
|
+
else [link invalidate];
|
|
2185
|
+
}
|
|
2186
|
+
@end
|
|
2187
|
+
|
|
1436
2188
|
@interface RNCCollapsiblePagerViewComponentView () <
|
|
1437
2189
|
RCTRNCCollapsiblePagerViewViewProtocol,
|
|
1438
2190
|
UIPageViewControllerDataSource,
|
|
@@ -1441,33 +2193,54 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1441
2193
|
UIGestureRecognizerDelegate,
|
|
1442
2194
|
RCTMountingTransactionObserving,
|
|
1443
2195
|
RNCNativeScrollerInsetCoordinator,
|
|
1444
|
-
RNCPagerViewNestedOverlayObserver
|
|
2196
|
+
RNCPagerViewNestedOverlayObserver,
|
|
2197
|
+
RNCPagerPresentationProgressTarget
|
|
1445
2198
|
>
|
|
2199
|
+
- (void)syncNativeToolbarState;
|
|
2200
|
+
- (void)cancelNativeToolbarSettlement;
|
|
2201
|
+
- (void)scheduleNativeToolbarSettlement;
|
|
1446
2202
|
- (void)finishPagerScrollEmittingSelection:(BOOL)emitSelection;
|
|
2203
|
+
- (void)cancelPendingNativePagerScroll;
|
|
1447
2204
|
- (void)completeTransitionOnNextRunLoopForGeneration:(NSUInteger)generation
|
|
1448
2205
|
transition:(NSUInteger)transition;
|
|
1449
2206
|
- (void)setDirectNativePagerEnabled:(BOOL)enabled;
|
|
1450
2207
|
- (void)attachSharedHeadersToScrollView:(UIScrollView *)scrollView;
|
|
1451
2208
|
- (void)liftSharedHeadersForPagerTransition:(NSString *)reason;
|
|
1452
2209
|
- (void)restoreSharedHeadersToContainer;
|
|
2210
|
+
- (NSInteger)currentStickyHeaderHeight;
|
|
1453
2211
|
- (void)layoutSharedHeaders;
|
|
2212
|
+
- (void)bringReservedStickyControlToFront;
|
|
1454
2213
|
- (void)restorePinnedStickyHeader;
|
|
1455
2214
|
- (void)updatePinnedStickyHeader;
|
|
1456
2215
|
- (UIScrollView *)currentVerticalScrollViewForParentPager;
|
|
1457
2216
|
- (UIScrollView *)verticalScrollViewForPageAtIndex:(NSInteger)pageIndex;
|
|
2217
|
+
- (RNCScrollCandidateResolution)resolveScrollCandidateForPageAtIndex:(NSInteger)pageIndex;
|
|
2218
|
+
- (RNCScrollCandidateResolution)resolveScrollCandidateInView:(UIView *)view;
|
|
1458
2219
|
- (UIScrollView *)findExplicitNativeScrollerInView:(UIView *)view;
|
|
1459
2220
|
- (UIScrollView *)findFabricScrollViewInView:(UIView *)view;
|
|
1460
2221
|
- (UIScrollView *)findVerticalScrollViewInView:(UIView *)view;
|
|
2222
|
+
- (void)scheduleCoalescedScrollReconcile;
|
|
1461
2223
|
- (void)scheduleScrollObserverRetryForCurrentPage;
|
|
1462
2224
|
- (void)preparePageForHorizontalTransitionAtIndex:(NSInteger)pageIndex;
|
|
1463
2225
|
- (void)updateSharedHeaderPressCancellationGesture;
|
|
1464
2226
|
- (void)detachSharedHeaderPressCancellationGesture;
|
|
1465
2227
|
- (void)updateRefreshControlForScrollView:(UIScrollView *)scrollView;
|
|
1466
2228
|
- (void)releaseRefreshControlForScrollView:(UIScrollView *)scrollView;
|
|
2229
|
+
- (void)logHomeVisualGeometry:(NSString *)phase scrollView:(UIScrollView *)scrollView;
|
|
1467
2230
|
- (void)cancelTopInsetReboundCheck;
|
|
1468
2231
|
- (void)scheduleTopInsetReboundCheck;
|
|
1469
2232
|
- (void)syncScrollEdgeAppearance;
|
|
1470
2233
|
- (void)updateHardEdgeSeparatorCovers;
|
|
2234
|
+
- (void)updateTopOverlayThemeBackground;
|
|
2235
|
+
- (BOOL)canPreserveHorizontalScrollEdgesAllowExternalOverlay:(BOOL)allowExternalOverlay;
|
|
2236
|
+
- (void)beginProgrammaticScrollEdgesToIndex:(NSInteger)index allowExternalOverlay:(BOOL)allowExternalOverlay;
|
|
2237
|
+
- (void)adoptCurrentScrollEdgeForProgrammaticTransition:(BOOL)allowExternalOverlay;
|
|
2238
|
+
- (RNCCollapsiblePagerTransitionEdgeOwner *)borrowedPinnedStickyOwner;
|
|
2239
|
+
- (void)releaseProgrammaticScrollEdge:(UIScrollView *)scrollView;
|
|
2240
|
+
- (void)releaseProgrammaticScrollEdgeOwner:(RNCCollapsiblePagerTransitionEdgeOwner *)owner;
|
|
2241
|
+
- (void)clearProgrammaticScrollEdges;
|
|
2242
|
+
- (void)finishProgrammaticScrollEdges;
|
|
2243
|
+
- (BOOL)hasProgrammaticScrollEdgeForPage:(UIView *)page;
|
|
1471
2244
|
- (void)updateScrollEdgeContentMasks;
|
|
1472
2245
|
- (void)restoreScrollEdgeContentMasks;
|
|
1473
2246
|
- (void)sharedHeaderPressCancellationGestureChanged:(UIPanGestureRecognizer *)recognizer;
|
|
@@ -1506,6 +2279,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1506
2279
|
UILabel *_stickyEdgeMarker;
|
|
1507
2280
|
CALayer *_topEdgeSeparatorCover;
|
|
1508
2281
|
CALayer *_stickyEdgeSeparatorCover;
|
|
2282
|
+
CALayer *_topOverlayThemeBackgroundLayer;
|
|
1509
2283
|
__weak UIView *_topEdgeInteractionHost;
|
|
1510
2284
|
__weak UIView *_stickyEdgeInteractionHost;
|
|
1511
2285
|
__weak UIScrollView *_topEdgeScrollView;
|
|
@@ -1517,6 +2291,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1517
2291
|
NSInteger _pendingInitialPage;
|
|
1518
2292
|
NSInteger _headerHeight;
|
|
1519
2293
|
NSInteger _stickyHeaderHeight;
|
|
2294
|
+
NSArray *_stickyHeaderHeights;
|
|
1520
2295
|
CGFloat _topOverlayHeight;
|
|
1521
2296
|
NSInteger _externalTopOverlayTag;
|
|
1522
2297
|
__weak UIView *_externalTopOverlayView;
|
|
@@ -1535,6 +2310,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1535
2310
|
NSUInteger _pendingTopInsetReboundGeneration;
|
|
1536
2311
|
NSTimer *_topInsetReboundTimer;
|
|
1537
2312
|
CGFloat _nativeTabBarHeight;
|
|
2313
|
+
CGFloat _nativeTabBarTrailingReservedWidth;
|
|
1538
2314
|
CGFloat _nativeSubHeaderHeight;
|
|
1539
2315
|
CGFloat _headerOffset;
|
|
1540
2316
|
BOOL _scrollEnabled;
|
|
@@ -1543,12 +2319,31 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1543
2319
|
BOOL _nativeSmoothHeaderScrollEnabled;
|
|
1544
2320
|
UIPanGestureRecognizer *_blockerGesture;
|
|
1545
2321
|
BOOL _transitioning;
|
|
2322
|
+
BOOL _toolbarTransitionPending;
|
|
2323
|
+
CADisplayLink *_toolbarSettleDisplayLink;
|
|
2324
|
+
NSUInteger _toolbarSettleGeneration;
|
|
2325
|
+
NSUInteger _toolbarSettleTransition;
|
|
2326
|
+
NSInteger _toolbarSettlePage;
|
|
2327
|
+
CGFloat _toolbarSettleWidth;
|
|
2328
|
+
NSUInteger _toolbarSettleTicks;
|
|
2329
|
+
BOOL _toolbarSettleAttempted;
|
|
1546
2330
|
BOOL _isPagerDragging;
|
|
1547
2331
|
BOOL _directNativePagerEnabled;
|
|
1548
2332
|
BOOL _pendingDirectNativePagerEnabled;
|
|
1549
2333
|
BOOL _hasPendingDirectNativePagerChange;
|
|
1550
2334
|
BOOL _hasReceivedPageCommand;
|
|
1551
2335
|
NSUInteger _transitionId;
|
|
2336
|
+
void (^_pendingNativePagerScrollCompletion)(BOOL);
|
|
2337
|
+
NSUInteger _pendingNativePagerScrollGeneration;
|
|
2338
|
+
NSUInteger _pendingNativePagerScrollTransition;
|
|
2339
|
+
CGFloat _pendingNativePagerScrollTarget;
|
|
2340
|
+
CADisplayLink *_tabProgressDisplayLink;
|
|
2341
|
+
NSUInteger _tabProgressGeneration;
|
|
2342
|
+
NSUInteger _tabProgressTransition;
|
|
2343
|
+
CGFloat _tabProgressWidth;
|
|
2344
|
+
NSIndexSet *_programmaticPageMaskIndexes;
|
|
2345
|
+
NSMapTable<UIScrollView *, RNCCollapsiblePagerTransitionEdgeOwner *> *_programmaticScrollEdges;
|
|
2346
|
+
NSMutableArray<RNCCollapsiblePagerTransitionEdgeOwner *> *_programmaticScrollEdgeOwners;
|
|
1552
2347
|
// OneKey patch: Retain the latest tab tap while an animation is in flight.
|
|
1553
2348
|
NSInteger _pendingGoToIndex;
|
|
1554
2349
|
BOOL _pendingGoToAnimated;
|
|
@@ -1576,6 +2371,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1576
2371
|
NSMapTable<UIScrollView *, NSValue *> *_originalInsets;
|
|
1577
2372
|
NSMapTable<UIScrollView *, UIRefreshControl *> *_managedRefreshControls;
|
|
1578
2373
|
NSHashTable<UIScrollView *> *_refreshControlObservedScrollViews;
|
|
2374
|
+
CFTimeInterval _homeVisualLastScrollLog;
|
|
2375
|
+
CFTimeInterval _homeVisualLastLayoutLog;
|
|
2376
|
+
CFTimeInterval _homeVisualStartMono;
|
|
2377
|
+
NSString *_homeVisualLastGeometrySignature;
|
|
2378
|
+
CGFloat _homeVisualLastThemeOpacity;
|
|
2379
|
+
CFTimeInterval _homeVisualLastThemeLog;
|
|
2380
|
+
BOOL _homeVisualThemeHolding;
|
|
1579
2381
|
NSMapTable<UIScrollView *, NSNumber *> *_appliedTopInsets;
|
|
1580
2382
|
NSMapTable<UIScrollView *, NSValue *> *_originalIndicatorInsets;
|
|
1581
2383
|
NSMapTable<UIScrollView *, NSNumber *> *_originalAlwaysBounceVertical;
|
|
@@ -1614,6 +2416,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1614
2416
|
RNCCollapsiblePagerOuterPagerPanGestureRecognizer *_sharedHeaderOuterPagerGesture;
|
|
1615
2417
|
RNCCollapsiblePagerVerticalPagerGuardGestureRecognizer *_verticalPagerGesture;
|
|
1616
2418
|
BOOL _observingContentOffset;
|
|
2419
|
+
BOOL _awaitingScrollOwnerForCurrentPage;
|
|
2420
|
+
BOOL _scrollReconcileScheduled;
|
|
1617
2421
|
BOOL _scrollResolveRetryScheduled;
|
|
1618
2422
|
CFTimeInterval _pendingFallbackScrollViewDetectedAt;
|
|
1619
2423
|
NSInteger _scrollResolveRetryPageIndex;
|
|
@@ -1645,6 +2449,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1645
2449
|
_displayBodyOverrides = [NSMutableDictionary new];
|
|
1646
2450
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nativeListScrollCommandAccepted:)
|
|
1647
2451
|
name:@"OneKeyNativeListScrollCommandAccepted" object:nil];
|
|
2452
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nativeScrollViewDidBecomeReadyNotification:)
|
|
2453
|
+
name:@"OneKeyNativeScrollViewDidBecomeReady" object:nil];
|
|
1648
2454
|
_pendingPageRestoreKeys = [NSMutableSet new];
|
|
1649
2455
|
_releasedPageScrollStates = [NSMutableDictionary new];
|
|
1650
2456
|
_mountingRemovedScrollViews = [NSHashTable weakObjectsHashTable];
|
|
@@ -1714,6 +2520,23 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1714
2520
|
});
|
|
1715
2521
|
}
|
|
1716
2522
|
};
|
|
2523
|
+
_nativeTabBarView.onToolbarNeedsSettlement = ^{
|
|
2524
|
+
__strong __typeof__(weakSelf) self = weakSelf;
|
|
2525
|
+
if (!self) return;
|
|
2526
|
+
NSUInteger generation = self->_generation;
|
|
2527
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
2528
|
+
if (self->_generation == generation) [self syncNativeToolbarState];
|
|
2529
|
+
});
|
|
2530
|
+
};
|
|
2531
|
+
_nativeTabBarView.onToolbarPress = ^(NSString *key, CGRect rect) {
|
|
2532
|
+
__strong __typeof__(weakSelf) self = weakSelf;
|
|
2533
|
+
if (!self || self->_isBeingRecycled) return;
|
|
2534
|
+
const auto emitter = [self eventEmitter];
|
|
2535
|
+
if (emitter) emitter->onNativeToolbarPress({
|
|
2536
|
+
.key = std::string(key.UTF8String ?: ""),
|
|
2537
|
+
.anchorRect = {.x = rect.origin.x, .y = rect.origin.y, .width = rect.size.width, .height = rect.size.height}
|
|
2538
|
+
});
|
|
2539
|
+
};
|
|
1717
2540
|
[_sharedHeaderHostView addSubview:_nativeTabBarView];
|
|
1718
2541
|
|
|
1719
2542
|
_nativeSubHeaderView = [RNCCollapsiblePagerNativeSubHeaderView new];
|
|
@@ -1774,11 +2597,14 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1774
2597
|
if (hitView != nil && !sharedHeaderPointIsVisible &&
|
|
1775
2598
|
(hitView == _sharedHeaderHostView ||
|
|
1776
2599
|
[hitView isDescendantOfView:_sharedHeaderHostView])) return nil;
|
|
1777
|
-
if (hitView != nil && _ownedPageMasks.count > 0 &&
|
|
2600
|
+
if (hitView != nil && (_ownedPageMasks.count > 0 || _programmaticScrollEdges.count > 0) &&
|
|
1778
2601
|
[_containerView convertPoint:point fromView:self].y < _pageMaskBoundary) {
|
|
1779
2602
|
for (UIView *page in _ownedPageMasks.keyEnumerator.allObjects) {
|
|
1780
2603
|
if ([hitView isDescendantOfView:page]) return nil;
|
|
1781
2604
|
}
|
|
2605
|
+
for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdges.objectEnumerator) {
|
|
2606
|
+
if (owner.page != nil && [hitView isDescendantOfView:owner.page]) return nil;
|
|
2607
|
+
}
|
|
1782
2608
|
}
|
|
1783
2609
|
return hitView;
|
|
1784
2610
|
}
|
|
@@ -1795,6 +2621,14 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1795
2621
|
- (void)didMoveToWindow
|
|
1796
2622
|
{
|
|
1797
2623
|
[super didMoveToWindow];
|
|
2624
|
+
[self cancelNativeToolbarSettlement];
|
|
2625
|
+
if (self.window == nil) [self stopProgrammaticTabProgress];
|
|
2626
|
+
if (self.window == nil && _pendingNativePagerScrollCompletion != nil) {
|
|
2627
|
+
[self cancelPendingNativePagerScroll];
|
|
2628
|
+
_pagerScrollView.scrollEnabled = _scrollEnabled;
|
|
2629
|
+
[self finishPagerScrollEmittingSelection:NO];
|
|
2630
|
+
}
|
|
2631
|
+
[self syncNativeToolbarState];
|
|
1798
2632
|
[self registerExternalOuterPager];
|
|
1799
2633
|
BOOL externalHeightChanged = [self resolveExternalTopOverlay];
|
|
1800
2634
|
if (self.window == nil) [self restoreScrollEdgeContentMasks];
|
|
@@ -1803,8 +2637,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1803
2637
|
[self updateTopScrollEdgeForScrollView:_observedScrollView];
|
|
1804
2638
|
[self updateSharedHeaderPressCancellationGesture];
|
|
1805
2639
|
[self updateHeaderSettledStateForceBusy:NO];
|
|
2640
|
+
[self logHomeVisualGeometry:@"window" scrollView:_observedScrollView];
|
|
1806
2641
|
for (UIScrollView *scrollView in _originalInsets.keyEnumerator) {
|
|
1807
|
-
[self updateNativeScrollerViewport:scrollView stickyHeight:self.window == nil ? 0 :
|
|
2642
|
+
[self updateNativeScrollerViewport:scrollView stickyHeight:self.window == nil ? 0 : self.currentStickyHeaderHeight + self.effectiveTopOverlayHeight];
|
|
1808
2643
|
}
|
|
1809
2644
|
if (externalHeightChanged) [self reapplyInsetsToObservedScrollView];
|
|
1810
2645
|
// OneKey patch: removing a decelerating page from its window can suppress
|
|
@@ -1830,7 +2665,10 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1830
2665
|
|
|
1831
2666
|
- (CGFloat)effectiveTopOverlayHeight
|
|
1832
2667
|
{
|
|
1833
|
-
|
|
2668
|
+
BOOL localOverlayPending = _topScrollEdgeEnabled && _topOverlayHeight > 0 &&
|
|
2669
|
+
_externalTopOverlayTag <= 0;
|
|
2670
|
+
return _topOverlayView != nil || localOverlayPending
|
|
2671
|
+
? _topOverlayHeight : _externalTopOverlayHeight;
|
|
1834
2672
|
}
|
|
1835
2673
|
|
|
1836
2674
|
- (BOOL)hasFixedTopOverlay
|
|
@@ -1851,6 +2689,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1851
2689
|
}
|
|
1852
2690
|
}
|
|
1853
2691
|
if (_externalOuterPager == outer) return;
|
|
2692
|
+
if (_topOverlayView == nil && _externalTopOverlayTag > 0) {
|
|
2693
|
+
[self clearProgrammaticScrollEdges];
|
|
2694
|
+
}
|
|
1854
2695
|
[_externalOuterPager removeNestedOverlayObserver:self];
|
|
1855
2696
|
_externalOuterPager = outer;
|
|
1856
2697
|
_externalOuterPageActive = NO;
|
|
@@ -1882,6 +2723,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1882
2723
|
}
|
|
1883
2724
|
BOOL changed = _externalTopOverlayView != nextView ||
|
|
1884
2725
|
fabs(_externalTopOverlayHeight - nextHeight) > 0.5;
|
|
2726
|
+
if (changed && _topOverlayView == nil && _externalTopOverlayTag > 0) {
|
|
2727
|
+
[self clearProgrammaticScrollEdges];
|
|
2728
|
+
}
|
|
1885
2729
|
_externalTopOverlayView = nextView;
|
|
1886
2730
|
_externalTopOverlayHeight = nextHeight;
|
|
1887
2731
|
_topOverlayHostView.hidden = !self.hasFixedTopOverlay;
|
|
@@ -1893,9 +2737,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1893
2737
|
{
|
|
1894
2738
|
if (_isBeingRecycled || _externalOuterPager == nil || _externalTopOverlayTag <= 0) return;
|
|
1895
2739
|
if (_externalOuterPageActive == active && _externalOuterTransitioning == transitioning) return;
|
|
2740
|
+
if ((transitioning || !active) && _topOverlayView == nil) {
|
|
2741
|
+
[self clearProgrammaticScrollEdges];
|
|
2742
|
+
}
|
|
1896
2743
|
BOOL wasTransitioning = _externalOuterTransitioning;
|
|
1897
2744
|
_externalOuterPageActive = active;
|
|
1898
2745
|
_externalOuterTransitioning = transitioning;
|
|
2746
|
+
[self syncNativeToolbarState];
|
|
1899
2747
|
if (transitioning && !wasTransitioning) {
|
|
1900
2748
|
[self updateTopScrollEdgeForScrollView:nil];
|
|
1901
2749
|
[self liftSharedHeadersForPagerTransition:@"outer"];
|
|
@@ -1913,6 +2761,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1913
2761
|
[super traitCollectionDidChange:previousTraitCollection];
|
|
1914
2762
|
if (previousTraitCollection.userInterfaceStyle != self.traitCollection.userInterfaceStyle) {
|
|
1915
2763
|
[self syncScrollEdgeAppearance];
|
|
2764
|
+
[self updateTopOverlayThemeBackground];
|
|
2765
|
+
[self logHomeVisualGeometry:@"trait" scrollView:_observedScrollView];
|
|
1916
2766
|
}
|
|
1917
2767
|
}
|
|
1918
2768
|
|
|
@@ -1938,6 +2788,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1938
2788
|
|
|
1939
2789
|
- (void)restoreScrollEdgeContentMasks
|
|
1940
2790
|
{
|
|
2791
|
+
[self clearProgrammaticScrollEdges];
|
|
2792
|
+
_programmaticPageMaskIndexes = nil;
|
|
1941
2793
|
if (_sharedHeaderHostView.maskView == _sharedHeaderMaskView) {
|
|
1942
2794
|
_sharedHeaderHostView.maskView = _originalSharedHeaderMaskView;
|
|
1943
2795
|
}
|
|
@@ -1962,6 +2814,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
1962
2814
|
self.window != nil && !_isBeingRecycled;
|
|
1963
2815
|
if (!enabled) {
|
|
1964
2816
|
[self restoreScrollEdgeContentMasks];
|
|
2817
|
+
[self updateTopOverlayThemeBackground];
|
|
1965
2818
|
return;
|
|
1966
2819
|
}
|
|
1967
2820
|
if (self.hasFixedTopOverlay && _sharedHeaderHostView.window == self.window &&
|
|
@@ -2001,11 +2854,14 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2001
2854
|
_pageMaskBoundary = boundary;
|
|
2002
2855
|
NSMutableSet<UIView *> *visiblePages = [NSMutableSet new];
|
|
2003
2856
|
if (transitioning) {
|
|
2004
|
-
for (
|
|
2005
|
-
UIView *page =
|
|
2857
|
+
for (NSUInteger index = 0; index < _pageControllers.count; index++) {
|
|
2858
|
+
UIView *page = _pageControllers[index].view;
|
|
2859
|
+
BOOL programmaticParticipant = [_programmaticPageMaskIndexes containsIndex:index];
|
|
2860
|
+
if ([self hasProgrammaticScrollEdgeForPage:page]) continue;
|
|
2006
2861
|
if (page.window != self.window ||
|
|
2007
|
-
!
|
|
2008
|
-
|
|
2862
|
+
(!programmaticParticipant &&
|
|
2863
|
+
!CGRectIntersectsRect([page convertRect:page.bounds toView:_containerView],
|
|
2864
|
+
_containerView.bounds))) continue;
|
|
2009
2865
|
[visiblePages addObject:page];
|
|
2010
2866
|
UIView *mask = [_ownedPageMasks objectForKey:page];
|
|
2011
2867
|
if (mask == nil) {
|
|
@@ -2017,8 +2873,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2017
2873
|
}
|
|
2018
2874
|
CGFloat localTop = [_containerView convertPoint:CGPointMake(0, boundary)
|
|
2019
2875
|
toView:page].y;
|
|
2020
|
-
|
|
2876
|
+
CGRect maskFrame = CGRectMake(0, localTop, CGRectGetWidth(page.bounds),
|
|
2021
2877
|
MAX(0, CGRectGetHeight(page.bounds) - localTop));
|
|
2878
|
+
if (programmaticParticipant) {
|
|
2879
|
+
[UIView performWithoutAnimation:^{ mask.frame = maskFrame; }];
|
|
2880
|
+
} else {
|
|
2881
|
+
mask.frame = maskFrame;
|
|
2882
|
+
}
|
|
2022
2883
|
}
|
|
2023
2884
|
}
|
|
2024
2885
|
for (UIView *page in _ownedPageMasks.keyEnumerator.allObjects) {
|
|
@@ -2031,6 +2892,102 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2031
2892
|
[_ownedPageMasks removeObjectForKey:page];
|
|
2032
2893
|
[_originalPageMasks removeObjectForKey:page];
|
|
2033
2894
|
}
|
|
2895
|
+
[self updateTopOverlayThemeBackground];
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
- (void)updateTopOverlayThemeBackground
|
|
2899
|
+
{
|
|
2900
|
+
if (@available(iOS 27.0, *)) {
|
|
2901
|
+
BOOL localHardOverlay = !_isBeingRecycled && _topScrollEdgeEnabled &&
|
|
2902
|
+
_topScrollEdgeEffect == RNCCollapsiblePagerViewTopScrollEdgeEffect::Hard &&
|
|
2903
|
+
_nativeSmoothHeaderScrollEnabled && _topOverlayView != nil &&
|
|
2904
|
+
_externalTopOverlayTag <= 0 && _topOverlayHeight > 0 && _headerHeight > 0 &&
|
|
2905
|
+
_topOverlayHostView.window == self.window && self.window != nil &&
|
|
2906
|
+
!CGRectIsEmpty(_topOverlayHostView.bounds);
|
|
2907
|
+
if (!localHardOverlay) {
|
|
2908
|
+
[_topOverlayThemeBackgroundLayer removeFromSuperlayer];
|
|
2909
|
+
_topOverlayThemeBackgroundLayer = nil;
|
|
2910
|
+
_homeVisualThemeHolding = NO;
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
UIColor *color = nil;
|
|
2915
|
+
for (UIView *view = self; view != nil; view = view.superview) {
|
|
2916
|
+
UIColor *candidate = [view.backgroundColor resolvedColorWithTraitCollection:
|
|
2917
|
+
_topOverlayHostView.traitCollection];
|
|
2918
|
+
if (candidate != nil && CGColorGetAlpha(candidate.CGColor) >= 1) {
|
|
2919
|
+
color = candidate;
|
|
2920
|
+
break;
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
if (color == nil) {
|
|
2924
|
+
[_topOverlayThemeBackgroundLayer removeFromSuperlayer];
|
|
2925
|
+
_topOverlayThemeBackgroundLayer = nil;
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2929
|
+
UIScrollView *scrollView = _observedScrollView;
|
|
2930
|
+
BOOL geometryReady = scrollView != nil &&
|
|
2931
|
+
_sharedHeaderScrollView == scrollView && _topEdgeScrollView == scrollView &&
|
|
2932
|
+
_topEdgeInteraction.scrollView == scrollView &&
|
|
2933
|
+
scrollView.topEdgeEffect.style == UIScrollEdgeEffectStyle.hardStyle &&
|
|
2934
|
+
_sharedHeaderMaskView != nil &&
|
|
2935
|
+
_sharedHeaderHostView.maskView == _sharedHeaderMaskView &&
|
|
2936
|
+
_headerView.window == self.window;
|
|
2937
|
+
if (_topOverlayThemeBackgroundLayer == nil && !geometryReady) return;
|
|
2938
|
+
BOOL created = _topOverlayThemeBackgroundLayer == nil;
|
|
2939
|
+
if (created) {
|
|
2940
|
+
_topOverlayThemeBackgroundLayer = [CALayer layer];
|
|
2941
|
+
_topOverlayThemeBackgroundLayer.name = @"onekey-top-overlay-theme-background";
|
|
2942
|
+
_topOverlayThemeBackgroundLayer.actions = @{
|
|
2943
|
+
@"position": NSNull.null, @"bounds": NSNull.null,
|
|
2944
|
+
@"opacity": NSNull.null, @"backgroundColor": NSNull.null
|
|
2945
|
+
};
|
|
2946
|
+
[_topOverlayHostView.layer insertSublayer:_topOverlayThemeBackgroundLayer atIndex:0];
|
|
2947
|
+
}
|
|
2948
|
+
_topOverlayThemeBackgroundLayer.frame = _topOverlayHostView.bounds;
|
|
2949
|
+
_topOverlayThemeBackgroundLayer.backgroundColor = color.CGColor;
|
|
2950
|
+
if (!geometryReady) {
|
|
2951
|
+
if (!_homeVisualThemeHolding) {
|
|
2952
|
+
_homeVisualThemeHolding = YES;
|
|
2953
|
+
#if DEBUG
|
|
2954
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
2955
|
+
@"[IOS-HOME-VISUAL] phase=theme-background-hold pagerTag=%ld generation=%lu pageIndex=%ld opacity=%.3f",
|
|
2956
|
+
(long)self.tag, (unsigned long)_generation, (long)_currentIndex,
|
|
2957
|
+
_topOverlayThemeBackgroundLayer.opacity]);
|
|
2958
|
+
#endif
|
|
2959
|
+
}
|
|
2960
|
+
return;
|
|
2961
|
+
}
|
|
2962
|
+
_homeVisualThemeHolding = NO;
|
|
2963
|
+
CGRect overlayWindow = [_topOverlayHostView convertRect:_topOverlayHostView.bounds
|
|
2964
|
+
toView:self.window];
|
|
2965
|
+
CGRect headerWindow = [_headerView convertRect:_headerView.bounds
|
|
2966
|
+
toView:self.window];
|
|
2967
|
+
CGFloat overlayBottom = CGRectGetMaxY(overlayWindow);
|
|
2968
|
+
CGFloat collapse = MIN(MAX(overlayBottom - CGRectGetMinY(headerWindow), 0),
|
|
2969
|
+
_headerHeight);
|
|
2970
|
+
CGFloat opacity = 1 - collapse / _headerHeight;
|
|
2971
|
+
_topOverlayThemeBackgroundLayer.opacity = opacity;
|
|
2972
|
+
#if DEBUG
|
|
2973
|
+
CFTimeInterval now = CACurrentMediaTime();
|
|
2974
|
+
if (created || fabs(opacity - _homeVisualLastThemeOpacity) >= 0.1 ||
|
|
2975
|
+
now - _homeVisualLastThemeLog >= 2.0) {
|
|
2976
|
+
_homeVisualLastThemeOpacity = opacity;
|
|
2977
|
+
_homeVisualLastThemeLog = now;
|
|
2978
|
+
CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
2979
|
+
[color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
2980
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
2981
|
+
@"[IOS-HOME-VISUAL] phase=theme-background epochMs=%.0f monoMs=%.0f pagerTag=%ld generation=%lu pageIndex=%ld opacity=%.3f collapse=%.1f header=%.1f overlayBottom=%.1f headerY=%.1f bodyYEstimate=%.1f hardOwner=%d rgba=%.3f,%.3f,%.3f,%.3f",
|
|
2982
|
+
NSDate.date.timeIntervalSince1970 * 1000, now * 1000,
|
|
2983
|
+
(long)self.tag, (unsigned long)_generation, (long)_currentIndex,
|
|
2984
|
+
opacity, collapse, (CGFloat)_headerHeight, overlayBottom,
|
|
2985
|
+
CGRectGetMinY(headerWindow), overlayBottom + _headerHeight +
|
|
2986
|
+
self.currentStickyHeaderHeight - collapse, _topEdgeInteraction.scrollView == scrollView,
|
|
2987
|
+
red, green, blue, alpha]);
|
|
2988
|
+
}
|
|
2989
|
+
#endif
|
|
2990
|
+
}
|
|
2034
2991
|
}
|
|
2035
2992
|
|
|
2036
2993
|
- (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter
|
|
@@ -2049,10 +3006,226 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2049
3006
|
emitter->onScrollEdgeCapability({.available = (bool)available});
|
|
2050
3007
|
}
|
|
2051
3008
|
|
|
3009
|
+
- (RNCCollapsiblePagerTransitionEdgeOwner *)borrowedPinnedStickyOwner
|
|
3010
|
+
{
|
|
3011
|
+
for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdgeOwners) {
|
|
3012
|
+
if (owner.borrowsPinnedStickyHost) return owner;
|
|
3013
|
+
}
|
|
3014
|
+
return nil;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
- (BOOL)canPreserveHorizontalScrollEdgesAllowExternalOverlay:(BOOL)allowExternalOverlay
|
|
3018
|
+
{
|
|
3019
|
+
if (@available(iOS 27.0, *)) {
|
|
3020
|
+
if (!_directNativePagerEnabled || !_topScrollEdgeEnabled ||
|
|
3021
|
+
!_nativeSmoothHeaderScrollEnabled ||
|
|
3022
|
+
_topScrollEdgeEffect != RNCCollapsiblePagerViewTopScrollEdgeEffect::Hard ||
|
|
3023
|
+
self.window == nil || _isBeingRecycled) return NO;
|
|
3024
|
+
if (_topOverlayView != nil && _externalTopOverlayTag <= 0) return YES;
|
|
3025
|
+
return allowExternalOverlay && _topOverlayView == nil && _externalTopOverlayTag > 0 &&
|
|
3026
|
+
_externalTopOverlayView.window == self.window && _externalTopOverlayHeight > 0 &&
|
|
3027
|
+
_topOverlayHostView.window == self.window && !_topOverlayHostView.hidden &&
|
|
3028
|
+
(_externalOuterPager == nil || (_externalOuterPageActive && !_externalOuterTransitioning));
|
|
3029
|
+
}
|
|
3030
|
+
return NO;
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
- (void)adoptCurrentScrollEdgeForProgrammaticTransition:(BOOL)allowExternalOverlay
|
|
3034
|
+
{
|
|
3035
|
+
if (@available(iOS 27.0, *)) {
|
|
3036
|
+
UIScrollView *source = _observedScrollView;
|
|
3037
|
+
if (![self canPreserveHorizontalScrollEdgesAllowExternalOverlay:allowExternalOverlay] ||
|
|
3038
|
+
source == nil || source != _topEdgeScrollView ||
|
|
3039
|
+
_topEdgeInteraction == nil || _topEdgeInteraction.scrollView != source ||
|
|
3040
|
+
_currentIndex < 0 || _currentIndex >= _pageControllers.count) return;
|
|
3041
|
+
|
|
3042
|
+
RNCCollapsiblePagerTransitionEdgeOwner *existing =
|
|
3043
|
+
[_programmaticScrollEdges objectForKey:source];
|
|
3044
|
+
if (existing != nil && existing.topInteraction.scrollView == source) return;
|
|
3045
|
+
if (existing != nil) [self releaseProgrammaticScrollEdgeOwner:existing];
|
|
3046
|
+
if (_programmaticScrollEdges == nil) {
|
|
3047
|
+
_programmaticScrollEdges = [NSMapTable weakToStrongObjectsMapTable];
|
|
3048
|
+
_programmaticScrollEdgeOwners = [NSMutableArray new];
|
|
3049
|
+
}
|
|
3050
|
+
RNCCollapsiblePagerTransitionEdgeOwner *owner = [RNCCollapsiblePagerTransitionEdgeOwner new];
|
|
3051
|
+
owner.scrollView = source;
|
|
3052
|
+
owner.page = _pageControllers[_currentIndex].view;
|
|
3053
|
+
owner.originalStyle = _originalTopEdgeStyle;
|
|
3054
|
+
owner.topInteraction = _topEdgeInteraction;
|
|
3055
|
+
owner.topHost = _topEdgeInteractionHost;
|
|
3056
|
+
owner.topMarker = _topEdgeMarker;
|
|
3057
|
+
owner.stickyInteraction = _stickyEdgeInteraction;
|
|
3058
|
+
owner.stickyHost = _stickyEdgeInteractionHost;
|
|
3059
|
+
owner.stickyMarker = _stickyEdgeMarker;
|
|
3060
|
+
owner.borrowsPinnedStickyHost = _stickyHeaderIsPinned &&
|
|
3061
|
+
owner.stickyHost == _pinnedStickyHostView &&
|
|
3062
|
+
owner.stickyInteraction.scrollView == source;
|
|
3063
|
+
[_programmaticScrollEdges setObject:owner forKey:source];
|
|
3064
|
+
[_programmaticScrollEdgeOwners addObject:owner];
|
|
3065
|
+
|
|
3066
|
+
// Transfer ownership without detaching UIKit's existing edge resources.
|
|
3067
|
+
_topEdgeInteraction = nil;
|
|
3068
|
+
_stickyEdgeInteraction = nil;
|
|
3069
|
+
_topEdgeMarker = nil;
|
|
3070
|
+
_stickyEdgeMarker = nil;
|
|
3071
|
+
_topEdgeInteractionHost = nil;
|
|
3072
|
+
_stickyEdgeInteractionHost = nil;
|
|
3073
|
+
_topEdgeScrollView = nil;
|
|
3074
|
+
_originalTopEdgeStyle = nil;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
- (void)beginProgrammaticScrollEdgesToIndex:(NSInteger)index allowExternalOverlay:(BOOL)allowExternalOverlay
|
|
3079
|
+
{
|
|
3080
|
+
if (@available(iOS 27.0, *)) {
|
|
3081
|
+
if (![self canPreserveHorizontalScrollEdgesAllowExternalOverlay:allowExternalOverlay]) return;
|
|
3082
|
+
if (_programmaticScrollEdges == nil) {
|
|
3083
|
+
_programmaticScrollEdges = [NSMapTable weakToStrongObjectsMapTable];
|
|
3084
|
+
_programmaticScrollEdgeOwners = [NSMutableArray new];
|
|
3085
|
+
}
|
|
3086
|
+
NSInteger first = MIN(_currentIndex, index);
|
|
3087
|
+
NSInteger last = MAX(_currentIndex, index);
|
|
3088
|
+
for (NSInteger pageIndex = first; pageIndex <= last; pageIndex++) {
|
|
3089
|
+
[self preparePageForHorizontalTransitionAtIndex:pageIndex];
|
|
3090
|
+
UIScrollView *scrollView = [self verticalScrollViewForPageAtIndex:pageIndex];
|
|
3091
|
+
if (scrollView == nil || scrollView.window != self.window) continue;
|
|
3092
|
+
if ([_programmaticScrollEdges objectForKey:scrollView] != nil) continue;
|
|
3093
|
+
RNCCollapsiblePagerTransitionEdgeOwner *owner = [RNCCollapsiblePagerTransitionEdgeOwner new];
|
|
3094
|
+
owner.scrollView = scrollView;
|
|
3095
|
+
owner.page = _pageControllers[pageIndex].view;
|
|
3096
|
+
owner.originalStyle = scrollView.topEdgeEffect.style;
|
|
3097
|
+
scrollView.topEdgeEffect.style = UIScrollEdgeEffectStyle.hardStyle;
|
|
3098
|
+
UILabel *(^markerForHost)(UIView *) = ^UILabel *(UIView *host) {
|
|
3099
|
+
UILabel *marker = [UILabel new];
|
|
3100
|
+
marker.frame = host.bounds;
|
|
3101
|
+
marker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
3102
|
+
marker.text = @" ";
|
|
3103
|
+
marker.textColor = UIColor.clearColor;
|
|
3104
|
+
marker.backgroundColor = UIColor.clearColor;
|
|
3105
|
+
marker.userInteractionEnabled = NO;
|
|
3106
|
+
marker.isAccessibilityElement = NO;
|
|
3107
|
+
marker.accessibilityElementsHidden = YES;
|
|
3108
|
+
[host addSubview:marker];
|
|
3109
|
+
return marker;
|
|
3110
|
+
};
|
|
3111
|
+
owner.ownsTransitionHosts = pageIndex != _currentIndex;
|
|
3112
|
+
UIView *(^transitionHost)(UIView *) = ^UIView *(UIView *referenceHost) {
|
|
3113
|
+
CGRect frame = [referenceHost convertRect:referenceHost.bounds toView:owner.page];
|
|
3114
|
+
CGRect viewport = [scrollView convertRect:scrollView.bounds toView:owner.page];
|
|
3115
|
+
frame.origin.x = CGRectGetMinX(viewport);
|
|
3116
|
+
UIView *host = [[UIView alloc] initWithFrame:frame];
|
|
3117
|
+
host.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
|
3118
|
+
host.userInteractionEnabled = NO;
|
|
3119
|
+
host.accessibilityElementsHidden = YES;
|
|
3120
|
+
[owner.page addSubview:host];
|
|
3121
|
+
return host;
|
|
3122
|
+
};
|
|
3123
|
+
if (owner.ownsTransitionHosts) {
|
|
3124
|
+
owner.ownedTopHost = transitionHost(_topOverlayHostView);
|
|
3125
|
+
owner.topHost = owner.ownedTopHost;
|
|
3126
|
+
} else {
|
|
3127
|
+
owner.topHost = _topOverlayHostView;
|
|
3128
|
+
}
|
|
3129
|
+
owner.topMarker = markerForHost(owner.topHost);
|
|
3130
|
+
owner.topInteraction = [UIScrollEdgeElementContainerInteraction new];
|
|
3131
|
+
owner.topInteraction.edge = UIRectEdgeTop;
|
|
3132
|
+
owner.topInteraction.scrollView = scrollView;
|
|
3133
|
+
[owner.topHost addInteraction:owner.topInteraction];
|
|
3134
|
+
if (_stickyHeaderView != nil && _headerOffset >= _headerHeight - 0.5) {
|
|
3135
|
+
if (owner.ownsTransitionHosts) {
|
|
3136
|
+
owner.ownedStickyHost = transitionHost(_stickyHeaderView);
|
|
3137
|
+
owner.stickyHost = owner.ownedStickyHost;
|
|
3138
|
+
} else {
|
|
3139
|
+
owner.stickyHost = _stickyHeaderView;
|
|
3140
|
+
}
|
|
3141
|
+
owner.stickyMarker = markerForHost(owner.stickyHost);
|
|
3142
|
+
owner.stickyInteraction = [UIScrollEdgeElementContainerInteraction new];
|
|
3143
|
+
owner.stickyInteraction.edge = UIRectEdgeTop;
|
|
3144
|
+
owner.stickyInteraction.scrollView = scrollView;
|
|
3145
|
+
[owner.stickyHost addInteraction:owner.stickyInteraction];
|
|
3146
|
+
}
|
|
3147
|
+
[_programmaticScrollEdges setObject:owner forKey:scrollView];
|
|
3148
|
+
[_programmaticScrollEdgeOwners addObject:owner];
|
|
3149
|
+
}
|
|
3150
|
+
[self updateScrollEdgeContentMasks];
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
- (void)releaseProgrammaticScrollEdge:(UIScrollView *)scrollView
|
|
3155
|
+
{
|
|
3156
|
+
if (scrollView == nil) return;
|
|
3157
|
+
[self releaseProgrammaticScrollEdgeOwner:[_programmaticScrollEdges objectForKey:scrollView]];
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
- (void)releaseProgrammaticScrollEdgeOwner:(RNCCollapsiblePagerTransitionEdgeOwner *)owner
|
|
3161
|
+
{
|
|
3162
|
+
if (@available(iOS 26.0, *)) {
|
|
3163
|
+
if (owner == nil) return;
|
|
3164
|
+
UIScrollView *scrollView = owner.scrollView;
|
|
3165
|
+
[owner.topHost removeInteraction:owner.topInteraction];
|
|
3166
|
+
owner.topInteraction.scrollView = nil;
|
|
3167
|
+
[owner.stickyHost removeInteraction:owner.stickyInteraction];
|
|
3168
|
+
owner.stickyInteraction.scrollView = nil;
|
|
3169
|
+
[owner.topMarker removeFromSuperview];
|
|
3170
|
+
[owner.stickyMarker removeFromSuperview];
|
|
3171
|
+
if (owner.ownsTransitionHosts) {
|
|
3172
|
+
[owner.ownedTopHost removeFromSuperview];
|
|
3173
|
+
[owner.ownedStickyHost removeFromSuperview];
|
|
3174
|
+
owner.ownedTopHost = nil;
|
|
3175
|
+
owner.ownedStickyHost = nil;
|
|
3176
|
+
}
|
|
3177
|
+
scrollView.topEdgeEffect.style = owner.originalStyle;
|
|
3178
|
+
if (owner.borrowsPinnedStickyHost && !_stickyHeaderIsPinned &&
|
|
3179
|
+
(_pinnedStickyHostView.superview == scrollView ||
|
|
3180
|
+
_pinnedStickyHostView.superview == nil)) {
|
|
3181
|
+
_pinnedStickyHostView.hidden = YES;
|
|
3182
|
+
_pinnedStickyHostView.layer.zPosition = 0;
|
|
3183
|
+
[_containerView addSubview:_pinnedStickyHostView];
|
|
3184
|
+
}
|
|
3185
|
+
if (scrollView != nil) [_programmaticScrollEdges removeObjectForKey:scrollView];
|
|
3186
|
+
[_programmaticScrollEdgeOwners removeObjectIdenticalTo:owner];
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3190
|
+
- (void)clearProgrammaticScrollEdges
|
|
3191
|
+
{
|
|
3192
|
+
for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdgeOwners.copy) {
|
|
3193
|
+
[self releaseProgrammaticScrollEdgeOwner:owner];
|
|
3194
|
+
}
|
|
3195
|
+
_programmaticScrollEdges = nil;
|
|
3196
|
+
_programmaticScrollEdgeOwners = nil;
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
- (void)finishProgrammaticScrollEdges
|
|
3200
|
+
{
|
|
3201
|
+
if (_programmaticScrollEdgeOwners.count == 0) return;
|
|
3202
|
+
[self clearProgrammaticScrollEdges];
|
|
3203
|
+
[self updateTopScrollEdgeForScrollView:_observedScrollView];
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
- (BOOL)hasProgrammaticScrollEdgeForPage:(UIView *)page
|
|
3207
|
+
{
|
|
3208
|
+
if (@available(iOS 26.0, *)) {
|
|
3209
|
+
for (RNCCollapsiblePagerTransitionEdgeOwner *owner in _programmaticScrollEdges.objectEnumerator) {
|
|
3210
|
+
if (owner.page == page && owner.scrollView.window == self.window &&
|
|
3211
|
+
owner.topInteraction.scrollView == owner.scrollView) return YES;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
return NO;
|
|
3215
|
+
}
|
|
3216
|
+
|
|
2052
3217
|
- (void)updateTopScrollEdgeForScrollView:(UIScrollView *)scrollView
|
|
2053
3218
|
{
|
|
2054
3219
|
[self syncScrollEdgeAppearance];
|
|
2055
3220
|
if (@available(iOS 26.0, *)) {
|
|
3221
|
+
if (_programmaticScrollEdgeOwners.count > 0 &&
|
|
3222
|
+
![self canPreserveHorizontalScrollEdgesAllowExternalOverlay:YES]) {
|
|
3223
|
+
[self clearProgrammaticScrollEdges];
|
|
3224
|
+
}
|
|
3225
|
+
if (scrollView != nil && [_programmaticScrollEdges objectForKey:scrollView] != nil) {
|
|
3226
|
+
[self updateScrollEdgeContentMasks];
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
2056
3229
|
if (_pendingTopOverlayAppearanceCommit) scrollView = nil;
|
|
2057
3230
|
BOOL externalOwnerReady = _externalTopOverlayTag <= 0 ||
|
|
2058
3231
|
_externalOuterPager == nil ||
|
|
@@ -2187,6 +3360,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2187
3360
|
CGRectGetWidth(_containerView.bounds), pixel);
|
|
2188
3361
|
cover.contentsScale = scale;
|
|
2189
3362
|
cover.backgroundColor = color.CGColor;
|
|
3363
|
+
cover.hidden = index == 0 && _stickyHeaderIsPinned;
|
|
2190
3364
|
}
|
|
2191
3365
|
if (index == 0) _topEdgeSeparatorCover = cover;
|
|
2192
3366
|
else _stickyEdgeSeparatorCover = cover;
|
|
@@ -2195,9 +3369,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2195
3369
|
|
|
2196
3370
|
- (void)dealloc
|
|
2197
3371
|
{
|
|
3372
|
+
[self cancelNativeToolbarSettlement];
|
|
3373
|
+
[self stopProgrammaticTabProgress];
|
|
3374
|
+
[self clearProgrammaticScrollEdges];
|
|
2198
3375
|
[self updateTopScrollEdgeForScrollView:nil];
|
|
2199
3376
|
[self cancelHeaderSettledCheck];
|
|
2200
3377
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"OneKeyNativeListScrollCommandAccepted" object:nil];
|
|
3378
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"OneKeyNativeScrollViewDidBecomeReady" object:nil];
|
|
2201
3379
|
for (UIScrollView *scrollView in _originalInsets.keyEnumerator) {
|
|
2202
3380
|
[self updateNativeScrollerViewport:scrollView stickyHeight:0];
|
|
2203
3381
|
}
|
|
@@ -2247,6 +3425,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2247
3425
|
}
|
|
2248
3426
|
_hasPendingDirectNativePagerChange = NO;
|
|
2249
3427
|
if (_directNativePagerEnabled == enabled) return;
|
|
3428
|
+
[self cancelNativeToolbarSettlement];
|
|
3429
|
+
[self cancelPendingNativePagerScroll];
|
|
2250
3430
|
|
|
2251
3431
|
[self restoreScrollEdgeContentMasks];
|
|
2252
3432
|
[self detachScrollObserver];
|
|
@@ -2308,12 +3488,12 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2308
3488
|
return width * MAX(0, physicalIndex);
|
|
2309
3489
|
}
|
|
2310
3490
|
|
|
2311
|
-
- (CGFloat)
|
|
3491
|
+
- (CGFloat)directPagerProgressForOffset:(CGFloat)offset
|
|
2312
3492
|
{
|
|
2313
3493
|
CGFloat width = CGRectGetWidth(_pagerScrollView.bounds);
|
|
2314
3494
|
if (width <= 0 || _pageControllers.count == 0) return _currentIndex;
|
|
2315
3495
|
CGFloat physicalProgress = RNCClamp(
|
|
2316
|
-
|
|
3496
|
+
offset / width,
|
|
2317
3497
|
0,
|
|
2318
3498
|
_pageControllers.count - 1
|
|
2319
3499
|
);
|
|
@@ -2322,11 +3502,56 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2322
3502
|
: _pageControllers.count - 1 - physicalProgress;
|
|
2323
3503
|
}
|
|
2324
3504
|
|
|
3505
|
+
- (CGFloat)directPagerProgress {
|
|
3506
|
+
return [self directPagerProgressForOffset:_pagerScrollView.contentOffset.x];
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
- (void)stopProgrammaticTabProgress {
|
|
3510
|
+
if (_tabProgressDisplayLink != nil && _tabProgressWidth > 0 && fabs(CGRectGetWidth(_pagerScrollView.bounds) - _tabProgressWidth) < 0.5) {
|
|
3511
|
+
CALayer *presentation = _pagerScrollView.layer.presentationLayer;
|
|
3512
|
+
if (presentation && std::isfinite(presentation.bounds.origin.x)) {
|
|
3513
|
+
[_nativeTabBarView setProgress:[self directPagerProgressForOffset:presentation.bounds.origin.x]];
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
[_tabProgressDisplayLink invalidate];
|
|
3517
|
+
_tabProgressDisplayLink = nil;
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
- (void)updateNativeTabProgress:(CGFloat)progress {
|
|
3521
|
+
if (_tabProgressDisplayLink == nil) [_nativeTabBarView setProgress:progress];
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
- (void)sampleProgrammaticTabProgress:(CADisplayLink *)link {
|
|
3525
|
+
if (link != _tabProgressDisplayLink) { [link invalidate]; return; }
|
|
3526
|
+
if (self.window == nil || !_transitioning || ![_nativeTabBarView usesControlledTextProgress] ||
|
|
3527
|
+
_tabProgressGeneration != _generation || _tabProgressTransition != _transitionId ||
|
|
3528
|
+
!std::isfinite(CGRectGetWidth(_pagerScrollView.bounds)) || _tabProgressWidth <= 0 ||
|
|
3529
|
+
fabs(CGRectGetWidth(_pagerScrollView.bounds) - _tabProgressWidth) >= 0.5) {
|
|
3530
|
+
[self stopProgrammaticTabProgress];
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
CALayer *presentation = _pagerScrollView.layer.presentationLayer;
|
|
3534
|
+
if (presentation == nil || !std::isfinite(presentation.bounds.origin.x)) return;
|
|
3535
|
+
[_nativeTabBarView setProgress:[self directPagerProgressForOffset:presentation.bounds.origin.x]];
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
- (void)startProgrammaticTabProgress {
|
|
3539
|
+
[self stopProgrammaticTabProgress];
|
|
3540
|
+
RNCPagerPresentationProgressProxy *proxy = [RNCPagerPresentationProgressProxy new];
|
|
3541
|
+
proxy.target = self;
|
|
3542
|
+
_tabProgressWidth = CGRectGetWidth(_pagerScrollView.bounds);
|
|
3543
|
+
_tabProgressGeneration = _generation;
|
|
3544
|
+
_tabProgressTransition = _transitionId;
|
|
3545
|
+
_tabProgressDisplayLink = [CADisplayLink displayLinkWithTarget:proxy selector:@selector(tick:)];
|
|
3546
|
+
[_tabProgressDisplayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
|
|
3547
|
+
}
|
|
3548
|
+
|
|
2325
3549
|
#pragma mark - Smooth shared header ownership
|
|
2326
3550
|
|
|
2327
3551
|
- (void)restorePinnedStickyHeader
|
|
2328
3552
|
{
|
|
2329
3553
|
if (!_stickyHeaderIsPinned) return;
|
|
3554
|
+
BOOL borrowedHost = [self borrowedPinnedStickyOwner] != nil;
|
|
2330
3555
|
_stickyHeaderIsPinned = NO;
|
|
2331
3556
|
_stickyHeaderView.transform = CGAffineTransformIdentity;
|
|
2332
3557
|
_nativeTabBarView.transform = CGAffineTransformIdentity;
|
|
@@ -2337,14 +3562,17 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2337
3562
|
if (_stickyHeaderView != nil) [_sharedHeaderHostView addSubview:_stickyHeaderView];
|
|
2338
3563
|
[_sharedHeaderHostView addSubview:_nativeTabBarView];
|
|
2339
3564
|
[_sharedHeaderHostView addSubview:_nativeSubHeaderView];
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
3565
|
+
if (!borrowedHost) {
|
|
3566
|
+
_pinnedStickyHostView.hidden = YES;
|
|
3567
|
+
_pinnedStickyHostView.layer.zPosition = 0;
|
|
3568
|
+
[_containerView addSubview:_pinnedStickyHostView];
|
|
3569
|
+
}
|
|
2343
3570
|
if ([_pagerScrollView isKindOfClass:RNCCollapsiblePagerDirectScrollView.class]) {
|
|
2344
3571
|
((RNCCollapsiblePagerDirectScrollView *)_pagerScrollView).excludedHeaderView = _sharedHeaderHostView;
|
|
2345
3572
|
}
|
|
2346
3573
|
[_nativeTabBarView updateAncestorGesturePrecedence];
|
|
2347
3574
|
[_nativeSubHeaderView updateAncestorGesturePrecedence];
|
|
3575
|
+
[self bringReservedStickyControlToFront];
|
|
2348
3576
|
}
|
|
2349
3577
|
|
|
2350
3578
|
- (void)restoreSharedHeadersToContainer
|
|
@@ -2419,10 +3647,22 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2419
3647
|
reason ?: @"unknown"]);
|
|
2420
3648
|
}
|
|
2421
3649
|
|
|
3650
|
+
- (NSInteger)stickyHeaderHeightForPageIndex:(NSInteger)index
|
|
3651
|
+
{
|
|
3652
|
+
if (index < 0 || index >= (NSInteger)_stickyHeaderHeights.count) return _stickyHeaderHeight;
|
|
3653
|
+
id value = _stickyHeaderHeights[index];
|
|
3654
|
+
return [value isKindOfClass:NSNumber.class] ? MAX(0, [value integerValue]) : _stickyHeaderHeight;
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
- (NSInteger)currentStickyHeaderHeight
|
|
3658
|
+
{
|
|
3659
|
+
return [self stickyHeaderHeightForPageIndex:_currentIndex];
|
|
3660
|
+
}
|
|
3661
|
+
|
|
2422
3662
|
- (void)layoutSharedHeaders
|
|
2423
3663
|
{
|
|
2424
3664
|
CGFloat width = CGRectGetWidth(self.bounds);
|
|
2425
|
-
CGFloat totalHeight = _headerHeight +
|
|
3665
|
+
CGFloat totalHeight = _headerHeight + self.currentStickyHeaderHeight;
|
|
2426
3666
|
BOOL attachedToList = _nativeSmoothHeaderScrollEnabled &&
|
|
2427
3667
|
_sharedHeaderScrollView != nil && !_sharedHeadersLiftedForPagerTransition;
|
|
2428
3668
|
|
|
@@ -2440,20 +3680,24 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2440
3680
|
);
|
|
2441
3681
|
CGFloat stickyY = _headerHeight;
|
|
2442
3682
|
_headerView.frame = CGRectMake(0, 0, width, _headerHeight);
|
|
2443
|
-
|
|
2444
|
-
|
|
3683
|
+
RNCCollapsiblePagerTransitionEdgeOwner *borrowedOwner = [self borrowedPinnedStickyOwner];
|
|
3684
|
+
UIScrollView *pinnedScrollView = borrowedOwner.scrollView ?: _sharedHeaderScrollView;
|
|
3685
|
+
CGPoint pinnedOrigin = (borrowedOwner != nil || _stickyHeaderIsPinned) && pinnedScrollView != nil
|
|
3686
|
+
? [pinnedScrollView convertPoint:CGPointMake(0, self.effectiveTopOverlayHeight)
|
|
3687
|
+
fromView:_containerView]
|
|
2445
3688
|
: CGPointMake(0, self.effectiveTopOverlayHeight);
|
|
2446
3689
|
_pinnedStickyHostView.frame = CGRectMake(
|
|
2447
|
-
pinnedOrigin.x, pinnedOrigin.y, width,
|
|
3690
|
+
pinnedOrigin.x, pinnedOrigin.y, width, self.currentStickyHeaderHeight);
|
|
2448
3691
|
CGFloat stickyChildY = _stickyHeaderIsPinned ? 0 : stickyY;
|
|
2449
|
-
_stickyHeaderView.frame = CGRectMake(0, stickyChildY, width,
|
|
3692
|
+
_stickyHeaderView.frame = CGRectMake(0, stickyChildY, width, self.currentStickyHeaderHeight);
|
|
2450
3693
|
CGFloat nativeTabBarVisibleHeight = _nativeTabBarView.hidden
|
|
2451
3694
|
? 0
|
|
2452
|
-
: MIN(
|
|
3695
|
+
: MIN(self.currentStickyHeaderHeight, _nativeTabBarHeight);
|
|
3696
|
+
CGFloat tabReservedWidth = MIN(width, MAX(0, _nativeTabBarTrailingReservedWidth));
|
|
2453
3697
|
_nativeTabBarView.frame = CGRectMake(
|
|
2454
|
-
0,
|
|
3698
|
+
self.isLtrLayout ? 0 : tabReservedWidth,
|
|
2455
3699
|
stickyChildY,
|
|
2456
|
-
width,
|
|
3700
|
+
width - tabReservedWidth,
|
|
2457
3701
|
nativeTabBarVisibleHeight
|
|
2458
3702
|
);
|
|
2459
3703
|
_nativeSubHeaderView.frame = CGRectMake(
|
|
@@ -2461,15 +3705,32 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2461
3705
|
stickyChildY + nativeTabBarVisibleHeight,
|
|
2462
3706
|
width,
|
|
2463
3707
|
MIN(
|
|
2464
|
-
MAX(0,
|
|
3708
|
+
MAX(0, self.currentStickyHeaderHeight - nativeTabBarVisibleHeight),
|
|
2465
3709
|
_nativeSubHeaderHeight
|
|
2466
3710
|
)
|
|
2467
3711
|
);
|
|
2468
3712
|
_topOverlayHostView.frame = CGRectMake(0, 0, width, self.effectiveTopOverlayHeight);
|
|
2469
3713
|
_topOverlayView.frame = _topOverlayHostView.bounds;
|
|
3714
|
+
[self bringReservedStickyControlToFront];
|
|
2470
3715
|
[self applyHeaderOffset];
|
|
2471
3716
|
}
|
|
2472
3717
|
|
|
3718
|
+
- (void)bringReservedStickyControlToFront
|
|
3719
|
+
{
|
|
3720
|
+
if (_stickyHeaderView != nil &&
|
|
3721
|
+
_stickyHeaderView.superview == _nativeTabBarView.superview) {
|
|
3722
|
+
if (_nativeTabBarTrailingReservedWidth > 0) {
|
|
3723
|
+
[_stickyHeaderView.superview bringSubviewToFront:_stickyHeaderView];
|
|
3724
|
+
} else {
|
|
3725
|
+
[_nativeTabBarView.superview bringSubviewToFront:_nativeTabBarView];
|
|
3726
|
+
if (!_nativeSubHeaderView.hidden &&
|
|
3727
|
+
_nativeSubHeaderView.superview == _nativeTabBarView.superview) {
|
|
3728
|
+
[_nativeSubHeaderView.superview bringSubviewToFront:_nativeSubHeaderView];
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
|
|
2473
3734
|
- (void)updatePinnedStickyHeader
|
|
2474
3735
|
{
|
|
2475
3736
|
BOOL attachedToList = _nativeSmoothHeaderScrollEnabled &&
|
|
@@ -2497,7 +3758,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2497
3758
|
CGPoint origin = [scrollView convertPoint:CGPointMake(0, self.effectiveTopOverlayHeight)
|
|
2498
3759
|
fromView:_containerView];
|
|
2499
3760
|
_pinnedStickyHostView.frame = CGRectMake(origin.x, origin.y,
|
|
2500
|
-
CGRectGetWidth(self.bounds),
|
|
3761
|
+
CGRectGetWidth(self.bounds), self.currentStickyHeaderHeight);
|
|
2501
3762
|
}
|
|
2502
3763
|
return;
|
|
2503
3764
|
}
|
|
@@ -2515,11 +3776,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2515
3776
|
[host addSubview:_nativeSubHeaderView];
|
|
2516
3777
|
CGFloat childY = shouldPin ? 0 : _headerHeight;
|
|
2517
3778
|
CGFloat width = CGRectGetWidth(self.bounds);
|
|
2518
|
-
CGFloat tabHeight = _nativeTabBarView.hidden ? 0 : MIN(
|
|
2519
|
-
|
|
2520
|
-
|
|
3779
|
+
CGFloat tabHeight = _nativeTabBarView.hidden ? 0 : MIN(self.currentStickyHeaderHeight, _nativeTabBarHeight);
|
|
3780
|
+
CGFloat tabReservedWidth = MIN(width, MAX(0, _nativeTabBarTrailingReservedWidth));
|
|
3781
|
+
_stickyHeaderView.frame = CGRectMake(0, childY, width, self.currentStickyHeaderHeight);
|
|
3782
|
+
_nativeTabBarView.frame = CGRectMake(self.isLtrLayout ? 0 : tabReservedWidth,
|
|
3783
|
+
childY, width - tabReservedWidth, tabHeight);
|
|
2521
3784
|
_nativeSubHeaderView.frame = CGRectMake(0, childY + tabHeight, width,
|
|
2522
|
-
MIN(MAX(0,
|
|
3785
|
+
MIN(MAX(0, self.currentStickyHeaderHeight - tabHeight), _nativeSubHeaderHeight));
|
|
2523
3786
|
_pinnedStickyHostView.hidden = !shouldPin;
|
|
2524
3787
|
if ([_pagerScrollView isKindOfClass:RNCCollapsiblePagerDirectScrollView.class]) {
|
|
2525
3788
|
((RNCCollapsiblePagerDirectScrollView *)_pagerScrollView).excludedHeaderView =
|
|
@@ -2530,14 +3793,17 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2530
3793
|
_pinnedStickyHostView.layer.zPosition = 1000;
|
|
2531
3794
|
CGPoint origin = [scrollView convertPoint:CGPointMake(0, self.effectiveTopOverlayHeight)
|
|
2532
3795
|
fromView:_containerView];
|
|
2533
|
-
_pinnedStickyHostView.frame = CGRectMake(origin.x, origin.y, width,
|
|
3796
|
+
_pinnedStickyHostView.frame = CGRectMake(origin.x, origin.y, width, self.currentStickyHeaderHeight);
|
|
2534
3797
|
} else {
|
|
2535
3798
|
_pinnedStickyHostView.layer.zPosition = 0;
|
|
2536
3799
|
[_containerView addSubview:_pinnedStickyHostView];
|
|
2537
3800
|
}
|
|
2538
3801
|
[_nativeTabBarView updateAncestorGesturePrecedence];
|
|
2539
3802
|
[_nativeSubHeaderView updateAncestorGesturePrecedence];
|
|
3803
|
+
[self bringReservedStickyControlToFront];
|
|
2540
3804
|
[self updateTopScrollEdgeForScrollView:_observedScrollView];
|
|
3805
|
+
[self logHomeVisualGeometry:shouldPin ? @"pin" : @"unpin"
|
|
3806
|
+
scrollView:_observedScrollView];
|
|
2541
3807
|
}
|
|
2542
3808
|
|
|
2543
3809
|
- (void)preparePageForHorizontalTransitionAtIndex:(NSInteger)pageIndex
|
|
@@ -2550,8 +3816,81 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2550
3816
|
}
|
|
2551
3817
|
}
|
|
2552
3818
|
|
|
3819
|
+
- (void)cancelNativeToolbarSettlement {
|
|
3820
|
+
[_toolbarSettleDisplayLink invalidate];
|
|
3821
|
+
_toolbarSettleDisplayLink = nil;
|
|
3822
|
+
_toolbarSettleAttempted = NO;
|
|
3823
|
+
_toolbarSettleTicks = 0;
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
- (void)scheduleNativeToolbarSettlement {
|
|
3827
|
+
CGFloat width = CGRectGetWidth(_pagerScrollView.bounds);
|
|
3828
|
+
BOOL sameAttempt = _toolbarSettleAttempted && _toolbarSettleGeneration == _generation &&
|
|
3829
|
+
_toolbarSettleTransition == _transitionId && _toolbarSettlePage == _currentIndex &&
|
|
3830
|
+
_toolbarSettleWidth == width;
|
|
3831
|
+
if (sameAttempt) return;
|
|
3832
|
+
[self cancelNativeToolbarSettlement];
|
|
3833
|
+
_toolbarSettleAttempted = YES;
|
|
3834
|
+
_toolbarSettleGeneration = _generation;
|
|
3835
|
+
_toolbarSettleTransition = _transitionId;
|
|
3836
|
+
_toolbarSettlePage = _currentIndex;
|
|
3837
|
+
_toolbarSettleWidth = width;
|
|
3838
|
+
RNCPagerPresentationProgressProxy *proxy = [RNCPagerPresentationProgressProxy new];
|
|
3839
|
+
proxy.target = self;
|
|
3840
|
+
proxy.toolbarSettlement = YES;
|
|
3841
|
+
_toolbarSettleDisplayLink = [CADisplayLink displayLinkWithTarget:proxy selector:@selector(tick:)];
|
|
3842
|
+
[_toolbarSettleDisplayLink addToRunLoop:NSRunLoop.mainRunLoop forMode:NSRunLoopCommonModes];
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
- (void)sampleToolbarSettlement:(CADisplayLink *)link {
|
|
3846
|
+
if (link != _toolbarSettleDisplayLink) { [link invalidate]; return; }
|
|
3847
|
+
if (_toolbarSettleGeneration != _generation || _toolbarSettleTransition != _transitionId ||
|
|
3848
|
+
_toolbarSettlePage != _currentIndex ||
|
|
3849
|
+
_toolbarSettleWidth != CGRectGetWidth(_pagerScrollView.bounds) ||
|
|
3850
|
+
!self.window || _nativeTabBarView.window != self.window || ![_nativeTabBarView ownsSettledToolbar]) {
|
|
3851
|
+
[self cancelNativeToolbarSettlement];
|
|
3852
|
+
return;
|
|
3853
|
+
}
|
|
3854
|
+
++_toolbarSettleTicks;
|
|
3855
|
+
[self syncNativeToolbarState];
|
|
3856
|
+
if (link == _toolbarSettleDisplayLink && _toolbarSettleTicks >= 2) {
|
|
3857
|
+
[link invalidate];
|
|
3858
|
+
_toolbarSettleDisplayLink = nil;
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
- (void)syncNativeToolbarState {
|
|
3863
|
+
BOOL logicalBusy = !self.window || _isBeingRecycled || !_hasAppliedInitialPage || _toolbarTransitionPending ||
|
|
3864
|
+
_transitioning || _isPagerDragging || _externalOuterTransitioning ||
|
|
3865
|
+
(_externalOuterPager != nil && !_externalOuterPageActive) || _needsSlotRebuild ||
|
|
3866
|
+
_pendingGoToIndex >= 0 || _transitionPageOffsets != nil || _pendingNativePagerScrollCompletion != nil ||
|
|
3867
|
+
_tabProgressDisplayLink != nil || _currentIndex < 0 || _currentIndex >= _pageControllers.count ||
|
|
3868
|
+
CGRectGetWidth(self.bounds) <= 0 || CGRectGetHeight(self.bounds) <= 0 ||
|
|
3869
|
+
_pagerScrollView.dragging || _pagerScrollView.decelerating;
|
|
3870
|
+
BOOL busy = logicalBusy || _pagerScrollView.tracking;
|
|
3871
|
+
if (!busy && _directNativePagerEnabled) {
|
|
3872
|
+
CALayer *presentation = _pagerScrollView.layer.presentationLayer;
|
|
3873
|
+
CGFloat offset = presentation ? presentation.bounds.origin.x : _pagerScrollView.contentOffset.x;
|
|
3874
|
+
busy = CGRectGetWidth(_pagerScrollView.bounds) <= 0 || !std::isfinite(offset) ||
|
|
3875
|
+
fabs(offset - [self directPagerOffsetForIndex:_currentIndex]) >= 0.5;
|
|
3876
|
+
} else if (!busy) {
|
|
3877
|
+
busy = _pageViewController.viewControllers.firstObject != _pageControllers[_currentIndex];
|
|
3878
|
+
}
|
|
3879
|
+
[_nativeTabBarView updateToolbarPagerIndex:_currentIndex busy:busy];
|
|
3880
|
+
if (busy && !logicalBusy && [_nativeTabBarView ownsSettledToolbar] &&
|
|
3881
|
+
_nativeTabBarView.window == self.window && !_nativeTabBarView.hidden &&
|
|
3882
|
+
CGRectGetWidth(_pagerScrollView.bounds) > 0) {
|
|
3883
|
+
[self scheduleNativeToolbarSettlement];
|
|
3884
|
+
} else {
|
|
3885
|
+
[self cancelNativeToolbarSettlement];
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
|
|
2553
3889
|
- (void)beginPageStateTransition
|
|
2554
3890
|
{
|
|
3891
|
+
[self cancelNativeToolbarSettlement];
|
|
3892
|
+
_toolbarTransitionPending = YES;
|
|
3893
|
+
[_nativeTabBarView updateToolbarPagerIndex:-1 busy:YES];
|
|
2555
3894
|
[self cancelPagerTop];
|
|
2556
3895
|
if (!_nativeSmoothHeaderScrollEnabled || _headerHeight <= 0 || _transitionPageOffsets != nil) return;
|
|
2557
3896
|
_transitionSourceDisplayBody = MAX(_observedScrollView.contentOffset.y + _observedScrollView.contentInset.top - _headerHeight, 0);
|
|
@@ -2689,6 +4028,15 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2689
4028
|
- (void)mountingTransactionDidMount:(const MountingTransaction &)transaction
|
|
2690
4029
|
withSurfaceTelemetry:(const SurfaceTelemetry &)surfaceTelemetry
|
|
2691
4030
|
{
|
|
4031
|
+
if (_needsSlotRebuild && _deferTopEdgeSlotRebuild &&
|
|
4032
|
+
_topScrollEdgeEnabled && _nativeSmoothHeaderScrollEnabled &&
|
|
4033
|
+
_topScrollEdgeEffect == RNCCollapsiblePagerViewTopScrollEdgeEffect::Hard &&
|
|
4034
|
+
_topOverlayHeight > 0 && _pageKeys.count > 0 &&
|
|
4035
|
+
_externalTopOverlayTag <= 0 &&
|
|
4036
|
+
_logicalChildren.count == _pageKeys.count + 3 &&
|
|
4037
|
+
!_transitioning && !_isPagerDragging && !_isBeingRecycled) {
|
|
4038
|
+
_deferTopEdgeSlotRebuild = NO;
|
|
4039
|
+
}
|
|
2692
4040
|
if (_needsSlotRebuild && !_deferTopEdgeSlotRebuild &&
|
|
2693
4041
|
!_transitioning && !_isPagerDragging) {
|
|
2694
4042
|
[self rebuildSlots];
|
|
@@ -2711,6 +4059,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2711
4059
|
}
|
|
2712
4060
|
[self updateScrollEdgeContentMasks];
|
|
2713
4061
|
[_mountingRemovedScrollViews removeAllObjects];
|
|
4062
|
+
[self logHomeVisualGeometry:@"did-mount" scrollView:_observedScrollView];
|
|
2714
4063
|
if (!_nativeSmoothHeaderScrollEnabled || _isBeingRecycled || self.window == nil ||
|
|
2715
4064
|
_currentIndex < 0 || _currentIndex >= _pageControllers.count) return;
|
|
2716
4065
|
// Prepare newly mounted owned scrollers before their first frame, even while
|
|
@@ -2728,6 +4077,23 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2728
4077
|
[self applyInsetsToScrollView:scrollView pageIndex:index restore:YES];
|
|
2729
4078
|
}
|
|
2730
4079
|
}
|
|
4080
|
+
UIView *page = _pageControllers[_currentIndex].view;
|
|
4081
|
+
if (_scrollResolveRetryAttempt >= 12 &&
|
|
4082
|
+
_releasedPageScrollStates[self.currentPageKey] != nil) {
|
|
4083
|
+
for (const auto &mutation : transaction.getMutations()) {
|
|
4084
|
+
if (mutation.type == ShadowViewMutation::Insert && mutation.parentTag > 0 &&
|
|
4085
|
+
[page viewWithTag:mutation.parentTag] != nil) {
|
|
4086
|
+
// A new current-page insertion starts a bounded recovery round after
|
|
4087
|
+
// the previous replacement search has scheduled its final retry.
|
|
4088
|
+
_scrollResolveRetryToken += 1;
|
|
4089
|
+
_scrollResolveRetryScheduled = NO;
|
|
4090
|
+
_scrollResolveRetryAttempt = 0;
|
|
4091
|
+
break;
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
// Record recovery during transitions; ownership still waits for settlement.
|
|
2731
4097
|
if (_transitioning || _isPagerDragging) return;
|
|
2732
4098
|
|
|
2733
4099
|
// OneKey patch: a release must recover even when the changed parent is above
|
|
@@ -2736,7 +4102,6 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2736
4102
|
[self attachScrollObserverForCurrentPage];
|
|
2737
4103
|
return;
|
|
2738
4104
|
}
|
|
2739
|
-
UIView *page = _pageControllers[_currentIndex].view;
|
|
2740
4105
|
BOOL headerIsAttached = [_sharedHeaderHostView isDescendantOfView:self];
|
|
2741
4106
|
BOOL currentListIsAttached = _observedScrollView != nil &&
|
|
2742
4107
|
[_observedScrollView isDescendantOfView:page] && headerIsAttached;
|
|
@@ -2827,6 +4192,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2827
4192
|
}
|
|
2828
4193
|
_needsSlotRebuild = NO;
|
|
2829
4194
|
_deferTopEdgeSlotRebuild = NO;
|
|
4195
|
+
[self cancelPendingNativePagerScroll];
|
|
2830
4196
|
[self restoreScrollEdgeContentMasks];
|
|
2831
4197
|
[self detachScrollObserver];
|
|
2832
4198
|
[self restoreSharedHeadersToContainer];
|
|
@@ -2899,28 +4265,40 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2899
4265
|
animated:NO
|
|
2900
4266
|
completion:nil];
|
|
2901
4267
|
}
|
|
2902
|
-
[
|
|
4268
|
+
[self updateNativeTabProgress:_currentIndex];
|
|
2903
4269
|
}
|
|
2904
4270
|
if (_stickyHeaderView != nil) [_sharedHeaderHostView bringSubviewToFront:_stickyHeaderView];
|
|
2905
4271
|
if (!_nativeTabBarView.hidden) [_sharedHeaderHostView bringSubviewToFront:_nativeTabBarView];
|
|
2906
4272
|
if (!_nativeSubHeaderView.hidden) [_sharedHeaderHostView bringSubviewToFront:_nativeSubHeaderView];
|
|
4273
|
+
[self bringReservedStickyControlToFront];
|
|
2907
4274
|
[_containerView bringSubviewToFront:_sharedHeaderHostView];
|
|
2908
4275
|
if (_stickyHeaderIsPinned) {
|
|
2909
4276
|
[_pinnedStickyHostView.superview bringSubviewToFront:_pinnedStickyHostView];
|
|
2910
4277
|
}
|
|
2911
4278
|
if (self.hasFixedTopOverlay) [_containerView bringSubviewToFront:_topOverlayHostView];
|
|
2912
4279
|
[self setNeedsLayout];
|
|
2913
|
-
|
|
2914
|
-
if (!self->_isBeingRecycled) {
|
|
2915
|
-
[self prepareAdjacentPageInsets];
|
|
2916
|
-
[self attachScrollObserverForCurrentPage];
|
|
2917
|
-
}
|
|
2918
|
-
});
|
|
4280
|
+
[self scheduleCoalescedScrollReconcile];
|
|
2919
4281
|
}
|
|
2920
4282
|
|
|
2921
4283
|
- (void)layoutSubviews
|
|
2922
4284
|
{
|
|
2923
4285
|
[super layoutSubviews];
|
|
4286
|
+
if (_tabProgressDisplayLink != nil && fabs(CGRectGetWidth(self.bounds) - _tabProgressWidth) >= 0.5) {
|
|
4287
|
+
[self stopProgrammaticTabProgress];
|
|
4288
|
+
}
|
|
4289
|
+
void (^resizedPagerCompletion)(BOOL) = nil;
|
|
4290
|
+
NSInteger resizedPagerDestination = -1;
|
|
4291
|
+
NSUInteger resizedPagerGeneration = 0;
|
|
4292
|
+
NSUInteger resizedPagerTransition = 0;
|
|
4293
|
+
if (_directNativePagerEnabled && _pendingNativePagerScrollCompletion != nil &&
|
|
4294
|
+
CGRectGetWidth(_pagerScrollView.bounds) != CGRectGetWidth(self.bounds)) {
|
|
4295
|
+
resizedPagerCompletion = [_pendingNativePagerScrollCompletion copy];
|
|
4296
|
+
resizedPagerDestination = _destinationIndex;
|
|
4297
|
+
resizedPagerGeneration = _pendingNativePagerScrollGeneration;
|
|
4298
|
+
resizedPagerTransition = _pendingNativePagerScrollTransition;
|
|
4299
|
+
// Clear the old target before frame changes can deliver an animation end.
|
|
4300
|
+
[self cancelPendingNativePagerScroll];
|
|
4301
|
+
}
|
|
2924
4302
|
[self syncScrollEdgeAppearance];
|
|
2925
4303
|
_containerView.frame = self.bounds;
|
|
2926
4304
|
[self registerExternalOuterPager];
|
|
@@ -2950,7 +4328,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2950
4328
|
animated:NO
|
|
2951
4329
|
completion:nil];
|
|
2952
4330
|
}
|
|
2953
|
-
[
|
|
4331
|
+
[self updateNativeTabProgress:_currentIndex];
|
|
2954
4332
|
}
|
|
2955
4333
|
// UIKit frame assignment is undefined while a view has a non-identity transform.
|
|
2956
4334
|
// Restore transforms before settling page and shared-header frames.
|
|
@@ -2991,16 +4369,24 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
2991
4369
|
[self updateTopScrollEdgeForScrollView:_observedScrollView];
|
|
2992
4370
|
[self updateScrollEdgeContentMasks];
|
|
2993
4371
|
[self updateHeaderSettledStateForceBusy:NO];
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
4372
|
+
[self logHomeVisualGeometry:@"layout" scrollView:_observedScrollView];
|
|
4373
|
+
[self scheduleCoalescedScrollReconcile];
|
|
4374
|
+
if (resizedPagerCompletion != nil && _directNativePagerEnabled &&
|
|
4375
|
+
!_isBeingRecycled && !_isPagerDragging && _generation == resizedPagerGeneration &&
|
|
4376
|
+
_transitionId == resizedPagerTransition && resizedPagerDestination >= 0 &&
|
|
4377
|
+
resizedPagerDestination < _pageControllers.count) {
|
|
4378
|
+
[_pagerScrollView setContentOffset:CGPointMake(
|
|
4379
|
+
[self directPagerOffsetForIndex:resizedPagerDestination], 0
|
|
4380
|
+
) animated:NO];
|
|
4381
|
+
resizedPagerCompletion(YES);
|
|
4382
|
+
}
|
|
4383
|
+
[self syncNativeToolbarState];
|
|
3000
4384
|
}
|
|
3001
4385
|
|
|
3002
4386
|
- (void)prepareForRecycle
|
|
3003
4387
|
{
|
|
4388
|
+
[self cancelNativeToolbarSettlement];
|
|
4389
|
+
[self cancelPendingNativePagerScroll];
|
|
3004
4390
|
[_externalOuterPager removeNestedOverlayObserver:self];
|
|
3005
4391
|
_externalOuterPager = nil;
|
|
3006
4392
|
[self cancelTopInsetReboundCheck];
|
|
@@ -3009,11 +4395,15 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3009
4395
|
[self cancelHeaderSettledCheck];
|
|
3010
4396
|
[self publishHeaderSettledAtTop:NO identityChanged:NO];
|
|
3011
4397
|
_isBeingRecycled = YES;
|
|
4398
|
+
_toolbarTransitionPending = NO;
|
|
4399
|
+
[_nativeTabBarView updateToolbarPagerIndex:-1 busy:YES];
|
|
3012
4400
|
_pendingTopOverlayAppearanceCommit = NO;
|
|
3013
4401
|
[self syncScrollEdgeAppearance];
|
|
3014
4402
|
_generation++;
|
|
3015
4403
|
[_mountingRemovedScrollViews removeAllObjects];
|
|
3016
4404
|
_needsScrollObserverReattachAfterMount = NO;
|
|
4405
|
+
_awaitingScrollOwnerForCurrentPage = NO;
|
|
4406
|
+
_scrollReconcileScheduled = NO;
|
|
3017
4407
|
[_releasedPageScrollStates removeAllObjects];
|
|
3018
4408
|
[self detachSharedHeaderPressCancellationGesture];
|
|
3019
4409
|
[self detachScrollObserver];
|
|
@@ -3102,6 +4492,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3102
4492
|
_pendingInitialPage = 0;
|
|
3103
4493
|
_headerHeight = 0;
|
|
3104
4494
|
_stickyHeaderHeight = 0;
|
|
4495
|
+
_stickyHeaderHeights = nil;
|
|
3105
4496
|
_topOverlayHeight = 0;
|
|
3106
4497
|
_externalTopOverlayTag = 0;
|
|
3107
4498
|
_externalTopOverlayView = nil;
|
|
@@ -3110,7 +4501,12 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3110
4501
|
_externalOuterTransitioning = NO;
|
|
3111
4502
|
_topScrollEdgeEnabled = NO;
|
|
3112
4503
|
_topScrollEdgeEffect = RNCCollapsiblePagerViewTopScrollEdgeEffect::None;
|
|
4504
|
+
_homeVisualStartMono = 0;
|
|
4505
|
+
_homeVisualLastScrollLog = 0;
|
|
4506
|
+
_homeVisualLastLayoutLog = 0;
|
|
4507
|
+
_homeVisualLastGeometrySignature = nil;
|
|
3113
4508
|
_nativeTabBarHeight = 44;
|
|
4509
|
+
_nativeTabBarTrailingReservedWidth = 0;
|
|
3114
4510
|
_nativeSubHeaderHeight = 74;
|
|
3115
4511
|
_headerOffset = 0;
|
|
3116
4512
|
_currentLogicalOffset = 0;
|
|
@@ -3139,7 +4535,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3139
4535
|
_needsPropsReapply = YES;
|
|
3140
4536
|
_layoutDirection = @"ltr";
|
|
3141
4537
|
[_nativeTabBarView updateItemsJSON:@"[]"];
|
|
3142
|
-
[_nativeTabBarView
|
|
4538
|
+
[_nativeTabBarView updateConfigJSON:@"{}"];
|
|
4539
|
+
[self updateNativeTabProgress:0];
|
|
3143
4540
|
[_nativeSubHeaderView updateConfigJSON:@"{}"];
|
|
3144
4541
|
_isBeingRecycled = NO;
|
|
3145
4542
|
}
|
|
@@ -3192,6 +4589,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3192
4589
|
_layoutDirection = RCTNSStringFromString(toString(newViewProps.layoutDirection));
|
|
3193
4590
|
[_nativeTabBarView setLeftToRight:self.isLtrLayout];
|
|
3194
4591
|
[_nativeSubHeaderView setLeftToRight:self.isLtrLayout];
|
|
4592
|
+
[self setNeedsLayout];
|
|
4593
|
+
}
|
|
4594
|
+
if (_needsPropsReapply ||
|
|
4595
|
+
oldViewProps.nativeTabBarTrailingReservedWidth != newViewProps.nativeTabBarTrailingReservedWidth) {
|
|
4596
|
+
double reserved = newViewProps.nativeTabBarTrailingReservedWidth;
|
|
4597
|
+
_nativeTabBarTrailingReservedWidth = std::isfinite(reserved) && reserved >= 0 ? reserved : 0;
|
|
4598
|
+
[self setNeedsLayout];
|
|
3195
4599
|
}
|
|
3196
4600
|
BOOL insetsChanged = NO;
|
|
3197
4601
|
if (_needsPropsReapply || oldViewProps.headerHeight != newViewProps.headerHeight) {
|
|
@@ -3203,6 +4607,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3203
4607
|
_stickyHeaderHeight = MAX(0, newViewProps.stickyHeaderHeight);
|
|
3204
4608
|
insetsChanged = YES;
|
|
3205
4609
|
}
|
|
4610
|
+
if (_needsPropsReapply || oldViewProps.stickyHeaderHeights != newViewProps.stickyHeaderHeights) {
|
|
4611
|
+
NSString *json = RCTNSStringFromString(newViewProps.stickyHeaderHeights);
|
|
4612
|
+
NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
|
|
4613
|
+
id parsed = data.length == 0 ? nil : [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
|
4614
|
+
_stickyHeaderHeights = [parsed isKindOfClass:NSArray.class] ? parsed : nil;
|
|
4615
|
+
insetsChanged = YES;
|
|
4616
|
+
}
|
|
3206
4617
|
if (_needsPropsReapply || oldViewProps.topScrollEdgeEffect != newViewProps.topScrollEdgeEffect) {
|
|
3207
4618
|
BOOL enabled = newViewProps.topScrollEdgeEffect != RNCCollapsiblePagerViewTopScrollEdgeEffect::None;
|
|
3208
4619
|
BOOL enabledChanged = _topScrollEdgeEnabled != enabled;
|
|
@@ -3239,6 +4650,10 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3239
4650
|
}
|
|
3240
4651
|
if (_needsPropsReapply ||
|
|
3241
4652
|
oldViewProps.externalTopOverlayTag != newViewProps.externalTopOverlayTag) {
|
|
4653
|
+
if (_topOverlayView == nil && _externalTopOverlayTag > 0 &&
|
|
4654
|
+
_externalTopOverlayTag != newViewProps.externalTopOverlayTag) {
|
|
4655
|
+
[self clearProgrammaticScrollEdges];
|
|
4656
|
+
}
|
|
3242
4657
|
_externalTopOverlayTag = newViewProps.externalTopOverlayTag;
|
|
3243
4658
|
[self registerExternalOuterPager];
|
|
3244
4659
|
insetsChanged = [self resolveExternalTopOverlay] || insetsChanged;
|
|
@@ -3257,6 +4672,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3257
4672
|
_retainedPages = RCTNSStringFromString(newViewProps.retainedPages);
|
|
3258
4673
|
[self setNeedsLayout];
|
|
3259
4674
|
}
|
|
4675
|
+
if (_needsPropsReapply || oldViewProps.nativeTabBarConfig != newViewProps.nativeTabBarConfig) {
|
|
4676
|
+
[_nativeTabBarView updateConfigJSON:RCTNSStringFromString(newViewProps.nativeTabBarConfig)];
|
|
4677
|
+
}
|
|
3260
4678
|
if (_needsPropsReapply || oldViewProps.nativeTabBarItems != newViewProps.nativeTabBarItems) {
|
|
3261
4679
|
NSString *itemsJSON = RCTNSStringFromString(newViewProps.nativeTabBarItems);
|
|
3262
4680
|
[_nativeTabBarView updateItemsJSON:itemsJSON];
|
|
@@ -3272,7 +4690,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3272
4690
|
}
|
|
3273
4691
|
if (_needsPropsReapply ||
|
|
3274
4692
|
oldViewProps.nativeTabBarHeight != newViewProps.nativeTabBarHeight ||
|
|
4693
|
+
oldViewProps.nativeTabBarVariant != newViewProps.nativeTabBarVariant ||
|
|
3275
4694
|
oldViewProps.nativeTabBarContentPaddingHorizontal != newViewProps.nativeTabBarContentPaddingHorizontal ||
|
|
4695
|
+
oldViewProps.nativeTabBarContentPaddingVertical != newViewProps.nativeTabBarContentPaddingVertical ||
|
|
3276
4696
|
oldViewProps.nativeTabBarItemSpacing != newViewProps.nativeTabBarItemSpacing ||
|
|
3277
4697
|
oldViewProps.nativeTabBarFontSize != newViewProps.nativeTabBarFontSize ||
|
|
3278
4698
|
oldViewProps.nativeTabBarFontFamily != newViewProps.nativeTabBarFontFamily ||
|
|
@@ -3289,7 +4709,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3289
4709
|
NSString *fontFamily = RCTNSStringFromString(newViewProps.nativeTabBarFontFamily);
|
|
3290
4710
|
[_nativeTabBarView
|
|
3291
4711
|
updateStyleWithHeight:_nativeTabBarHeight
|
|
4712
|
+
variant:RCTNSStringFromString(newViewProps.nativeTabBarVariant)
|
|
3292
4713
|
contentPaddingHorizontal:MAX(0, newViewProps.nativeTabBarContentPaddingHorizontal)
|
|
4714
|
+
contentPaddingVertical:MAX(0, newViewProps.nativeTabBarContentPaddingVertical)
|
|
3293
4715
|
itemSpacing:MAX(0, newViewProps.nativeTabBarItemSpacing)
|
|
3294
4716
|
fontSize:newViewProps.nativeTabBarFontSize > 0 ? newViewProps.nativeTabBarFontSize : 16
|
|
3295
4717
|
fontFamily:fontFamily
|
|
@@ -3314,14 +4736,17 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3314
4736
|
if (insetsChanged) {
|
|
3315
4737
|
[self reapplyInsetsToObservedScrollView];
|
|
3316
4738
|
[self setNeedsLayout];
|
|
4739
|
+
[self logHomeVisualGeometry:@"props-inset" scrollView:_observedScrollView];
|
|
3317
4740
|
}
|
|
3318
4741
|
_applyingTopOverlayInsetChange = NO;
|
|
4742
|
+
[self syncNativeToolbarState];
|
|
3319
4743
|
if (!_nativeTabBarView.hidden) {
|
|
3320
4744
|
[_nativeTabBarView.superview bringSubviewToFront:_nativeTabBarView];
|
|
3321
4745
|
}
|
|
3322
4746
|
if (!_nativeSubHeaderView.hidden) {
|
|
3323
4747
|
[_nativeSubHeaderView.superview bringSubviewToFront:_nativeSubHeaderView];
|
|
3324
4748
|
}
|
|
4749
|
+
[self bringReservedStickyControlToFront];
|
|
3325
4750
|
[_sharedHeaderHostView.superview bringSubviewToFront:_sharedHeaderHostView];
|
|
3326
4751
|
if (_stickyHeaderIsPinned) {
|
|
3327
4752
|
[_pinnedStickyHostView.superview bringSubviewToFront:_pinnedStickyHostView];
|
|
@@ -3349,12 +4774,107 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3349
4774
|
|
|
3350
4775
|
- (UIScrollView *)verticalScrollViewForPageAtIndex:(NSInteger)pageIndex
|
|
3351
4776
|
{
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
4777
|
+
return [self resolveScrollCandidateForPageAtIndex:pageIndex].scrollView;
|
|
4778
|
+
}
|
|
4779
|
+
|
|
4780
|
+
- (RNCScrollCandidateResolution)resolveScrollCandidateForPageAtIndex:(NSInteger)pageIndex
|
|
4781
|
+
{
|
|
4782
|
+
if (pageIndex < 0 || pageIndex >= _pageControllers.count) return {};
|
|
4783
|
+
return [self resolveScrollCandidateInView:_pageControllers[pageIndex].view];
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4786
|
+
// Single-pass tiered resolution replaces three separate subtree walks while
|
|
4787
|
+
// distinguishing genuinely static pages from pages with unready scroll hosts.
|
|
4788
|
+
- (RNCScrollCandidateResolution)resolveScrollCandidateInView:(UIView *)view
|
|
4789
|
+
{
|
|
4790
|
+
RNCScrollCandidateResolution resolution;
|
|
4791
|
+
if (view == nil || view == _sharedHeaderHostView) return resolution;
|
|
4792
|
+
if (view != self &&
|
|
4793
|
+
[view isKindOfClass:RNCCollapsiblePagerViewComponentView.class]) {
|
|
4794
|
+
UIScrollView *nested = [(RNCCollapsiblePagerViewComponentView *)view
|
|
4795
|
+
currentVerticalScrollViewForParentPager];
|
|
4796
|
+
if (nested != nil) {
|
|
4797
|
+
resolution.scrollView = nested;
|
|
4798
|
+
resolution.tier = RNCScrollCandidateTierExplicitScroller;
|
|
4799
|
+
} else {
|
|
4800
|
+
resolution.hasUnreadyScrollHost = YES;
|
|
4801
|
+
}
|
|
4802
|
+
return resolution;
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4805
|
+
Class nativeListClass = NSClassFromString(@"HybridNativeListComponent");
|
|
4806
|
+
if (nativeListClass != Nil && [view isKindOfClass:nativeListClass]) {
|
|
4807
|
+
resolution.hasUnreadyScrollHost = YES;
|
|
4808
|
+
}
|
|
4809
|
+
|
|
4810
|
+
if ([view isKindOfClass:RNCNativeScrollerComponentView.class]) {
|
|
4811
|
+
UIScrollView *scrollView = ((RNCNativeScrollerComponentView *)view).scrollView;
|
|
4812
|
+
if (![_mountingRemovedScrollViews containsObject:scrollView]) {
|
|
4813
|
+
resolution.scrollView = scrollView;
|
|
4814
|
+
resolution.tier = RNCScrollCandidateTierExplicitScroller;
|
|
4815
|
+
return resolution;
|
|
4816
|
+
}
|
|
4817
|
+
} else if ([view isKindOfClass:RCTScrollViewComponentView.class]) {
|
|
4818
|
+
RCTScrollViewComponentView *componentView = (RCTScrollViewComponentView *)view;
|
|
4819
|
+
UIScrollView *scrollView = componentView.scrollView;
|
|
4820
|
+
if (![_mountingRemovedScrollViews containsObject:scrollView]) {
|
|
4821
|
+
if ([componentView.nativeId hasPrefix:RNCCollapsiblePagerNativeScrollerIDPrefix]) {
|
|
4822
|
+
resolution.scrollView = scrollView;
|
|
4823
|
+
resolution.tier = RNCScrollCandidateTierExplicitScroller;
|
|
4824
|
+
return resolution;
|
|
4825
|
+
}
|
|
4826
|
+
if (!scrollView.alwaysBounceHorizontal) {
|
|
4827
|
+
resolution.scrollView = scrollView;
|
|
4828
|
+
resolution.tier = RNCScrollCandidateTierFabricScrollView;
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
} else if ([view isKindOfClass:UICollectionView.class]) {
|
|
4832
|
+
UICollectionView *collectionView = (UICollectionView *)view;
|
|
4833
|
+
if (![_mountingRemovedScrollViews containsObject:collectionView]) {
|
|
4834
|
+
UICollectionViewLayout *layout = collectionView.collectionViewLayout;
|
|
4835
|
+
BOOL isVerticalLayout = ![layout isKindOfClass:UICollectionViewFlowLayout.class] ||
|
|
4836
|
+
((UICollectionViewFlowLayout *)layout).scrollDirection == UICollectionViewScrollDirectionVertical;
|
|
4837
|
+
if (isVerticalLayout) {
|
|
4838
|
+
BOOL hasNativeListHost = RNCNativeListComponentForScrollView(collectionView) != nil;
|
|
4839
|
+
BOOL isMountedNativeList = hasNativeListHost && RNCIsMountedNativeListScrollView(collectionView);
|
|
4840
|
+
BOOL hasUsableBounds = CGRectGetWidth(collectionView.bounds) > 0 &&
|
|
4841
|
+
CGRectGetHeight(collectionView.bounds) > 0;
|
|
4842
|
+
if (hasNativeListHost && !isMountedNativeList) {
|
|
4843
|
+
resolution.hasUnreadyScrollHost = YES;
|
|
4844
|
+
} else if (!hasUsableBounds) {
|
|
4845
|
+
resolution.hasUnreadyScrollHost = YES;
|
|
4846
|
+
} else {
|
|
4847
|
+
resolution.scrollView = collectionView;
|
|
4848
|
+
resolution.tier = isMountedNativeList
|
|
4849
|
+
? RNCScrollCandidateTierVerifiedNativeList
|
|
4850
|
+
: RNCScrollCandidateTierGenericFallback;
|
|
4851
|
+
// React slots inside a verified list may own independent scroll views.
|
|
4852
|
+
if (isMountedNativeList) return resolution;
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
} else if ([view isKindOfClass:UIScrollView.class]) {
|
|
4857
|
+
UIScrollView *scrollView = (UIScrollView *)view;
|
|
4858
|
+
if (![_mountingRemovedScrollViews containsObject:scrollView] &&
|
|
4859
|
+
!scrollView.alwaysBounceHorizontal &&
|
|
4860
|
+
scrollView.contentSize.width <= scrollView.bounds.size.width + 1) {
|
|
4861
|
+
resolution.scrollView = scrollView;
|
|
4862
|
+
resolution.tier = RNCScrollCandidateTierGenericFallback;
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4866
|
+
for (UIView *subview in view.subviews) {
|
|
4867
|
+
RNCScrollCandidateResolution child = [self resolveScrollCandidateInView:subview];
|
|
4868
|
+
resolution.hasUnreadyScrollHost |= child.hasUnreadyScrollHost;
|
|
4869
|
+
if (child.tier > resolution.tier) {
|
|
4870
|
+
resolution.scrollView = child.scrollView;
|
|
4871
|
+
resolution.tier = child.tier;
|
|
4872
|
+
if (resolution.tier == RNCScrollCandidateTierExplicitScroller) {
|
|
4873
|
+
return resolution;
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
return resolution;
|
|
3358
4878
|
}
|
|
3359
4879
|
|
|
3360
4880
|
- (UIScrollView *)findExplicitNativeScrollerInView:(UIView *)view
|
|
@@ -3450,6 +4970,19 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3450
4970
|
return nil;
|
|
3451
4971
|
}
|
|
3452
4972
|
|
|
4973
|
+
- (void)scheduleCoalescedScrollReconcile
|
|
4974
|
+
{
|
|
4975
|
+
if (_isBeingRecycled || _scrollReconcileScheduled) return;
|
|
4976
|
+
_scrollReconcileScheduled = YES;
|
|
4977
|
+
NSUInteger generation = _generation;
|
|
4978
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
4979
|
+
self->_scrollReconcileScheduled = NO;
|
|
4980
|
+
if (self->_isBeingRecycled || self->_generation != generation) return;
|
|
4981
|
+
[self prepareAdjacentPageInsets];
|
|
4982
|
+
[self attachScrollObserverForCurrentPage];
|
|
4983
|
+
});
|
|
4984
|
+
}
|
|
4985
|
+
|
|
3453
4986
|
- (void)scheduleScrollObserverRetryForCurrentPage
|
|
3454
4987
|
{
|
|
3455
4988
|
if (_scrollResolveRetryScheduled || _scrollResolveRetryAttempt >= 12 ||
|
|
@@ -3502,29 +5035,35 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3502
5035
|
_pendingFallbackScrollView = nil;
|
|
3503
5036
|
_pendingFallbackScrollViewDetectedAt = 0;
|
|
3504
5037
|
}
|
|
3505
|
-
|
|
5038
|
+
RNCScrollCandidateResolution resolution = [self resolveScrollCandidateForPageAtIndex:_currentIndex];
|
|
5039
|
+
UIScrollView *candidate = resolution.scrollView;
|
|
3506
5040
|
if (_nativeSmoothHeaderScrollEnabled && _currentIndex >= 0 && _currentIndex < _pageControllers.count) {
|
|
3507
5041
|
RNCGuardNestedHorizontalPans(_pageControllers[_currentIndex].view, _verticalPagerGesture);
|
|
3508
5042
|
}
|
|
3509
5043
|
if (candidate == nil) {
|
|
3510
5044
|
[self detachScrollObserver];
|
|
3511
5045
|
[self restoreSharedHeadersToContainer];
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
5046
|
+
_needsScrollObserverReattachAfterMount = NO;
|
|
5047
|
+
_pendingFallbackScrollView = nil;
|
|
5048
|
+
_pendingFallbackScrollViewDetectedAt = 0;
|
|
5049
|
+
_awaitingScrollOwnerForCurrentPage = YES;
|
|
5050
|
+
// Only schedule bounded retry when the page has an unready scroll host in
|
|
5051
|
+
// its subtree or a released scroll owner awaiting replacement. Static pages
|
|
5052
|
+
// without a scroll host do not spin retry timers, and late replacements on
|
|
5053
|
+
// any page also attach deterministically via readiness notifications.
|
|
5054
|
+
BOOL hasReleasedOwnerAwaitingReplacement = _releasedPageScrollStates[self.currentPageKey] != nil;
|
|
5055
|
+
if (resolution.hasUnreadyScrollHost || hasReleasedOwnerAwaitingReplacement) {
|
|
5056
|
+
[self scheduleScrollObserverRetryForCurrentPage];
|
|
5057
|
+
} else {
|
|
3516
5058
|
_scrollResolveRetryToken += 1;
|
|
3517
5059
|
_scrollResolveRetryScheduled = NO;
|
|
3518
5060
|
_scrollResolveRetryAttempt = 0;
|
|
3519
|
-
_pendingFallbackScrollView = nil;
|
|
3520
|
-
_pendingFallbackScrollViewDetectedAt = 0;
|
|
3521
|
-
} else {
|
|
3522
|
-
[self scheduleScrollObserverRetryForCurrentPage];
|
|
3523
5061
|
}
|
|
3524
5062
|
return;
|
|
3525
5063
|
}
|
|
3526
5064
|
if ([candidate isKindOfClass:UICollectionView.class] &&
|
|
3527
5065
|
candidate != _observedScrollView && !RNCIsMountedNativeListScrollView(candidate)) {
|
|
5066
|
+
_awaitingScrollOwnerForCurrentPage = YES;
|
|
3528
5067
|
if (_pendingFallbackScrollView != candidate) {
|
|
3529
5068
|
_pendingFallbackScrollView = candidate;
|
|
3530
5069
|
_pendingFallbackScrollViewDetectedAt = CACurrentMediaTime();
|
|
@@ -3536,6 +5075,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3536
5075
|
return;
|
|
3537
5076
|
}
|
|
3538
5077
|
}
|
|
5078
|
+
_awaitingScrollOwnerForCurrentPage = NO;
|
|
3539
5079
|
_scrollResolveRetryAttempt = 0;
|
|
3540
5080
|
_scrollResolveRetryPageIndex = _currentIndex;
|
|
3541
5081
|
_scrollResolveRetryToken += 1;
|
|
@@ -3894,8 +5434,105 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3894
5434
|
[_managedRefreshControls removeObjectForKey:scrollView];
|
|
3895
5435
|
if (current != nil) [_managedRefreshControls setObject:current forKey:scrollView];
|
|
3896
5436
|
}
|
|
3897
|
-
[RNCRefreshControlOffsetState setOffset:
|
|
5437
|
+
[RNCRefreshControlOffsetState setOffset:_headerHeight + self.currentStickyHeaderHeight
|
|
3898
5438
|
forControl:current owner:self];
|
|
5439
|
+
if (previous != current) [self logHomeVisualGeometry:@"refresh-bind" scrollView:scrollView];
|
|
5440
|
+
}
|
|
5441
|
+
|
|
5442
|
+
- (void)logHomeVisualGeometry:(NSString *)phase scrollView:(UIScrollView *)scrollView
|
|
5443
|
+
{
|
|
5444
|
+
#if DEBUG
|
|
5445
|
+
if (self.window == nil || _isBeingRecycled) return;
|
|
5446
|
+
CFTimeInterval now = CACurrentMediaTime();
|
|
5447
|
+
if (_homeVisualStartMono == 0) _homeVisualStartMono = now;
|
|
5448
|
+
if ([phase isEqualToString:@"pull"] && now - _homeVisualLastScrollLog < 0.2) return;
|
|
5449
|
+
if ([phase isEqualToString:@"pull"]) _homeVisualLastScrollLog = now;
|
|
5450
|
+
UIRefreshControl *control = scrollView.refreshControl;
|
|
5451
|
+
CGRect controlWindow = control != nil
|
|
5452
|
+
? [control convertRect:control.bounds toView:self.window] : CGRectZero;
|
|
5453
|
+
CGRect overlayWindow = [_topOverlayHostView convertRect:_topOverlayHostView.bounds
|
|
5454
|
+
toView:self.window];
|
|
5455
|
+
CGRect stickyWindow = [_stickyHeaderView convertRect:_stickyHeaderView.bounds
|
|
5456
|
+
toView:self.window];
|
|
5457
|
+
CGRect maskWindow = _sharedHeaderMaskView != nil
|
|
5458
|
+
? [_sharedHeaderHostView convertRect:_sharedHeaderMaskView.frame toView:self.window]
|
|
5459
|
+
: CGRectZero;
|
|
5460
|
+
CGFloat pageMaskWindowY = [_containerView convertPoint:
|
|
5461
|
+
CGPointMake(0, _pageMaskBoundary) toView:self.window].y;
|
|
5462
|
+
BOOL layoutPhase = [phase isEqualToString:@"layout"] ||
|
|
5463
|
+
[phase isEqualToString:@"did-mount"];
|
|
5464
|
+
NSString *signature = [NSString stringWithFormat:
|
|
5465
|
+
@"%.1f:%ld:%ld:%.1f:%d:%.1f:%.1f:%.1f:%d:%d",
|
|
5466
|
+
self.effectiveTopOverlayHeight, (long)_headerHeight,
|
|
5467
|
+
(long)self.currentStickyHeaderHeight, scrollView.contentInset.top, control != nil,
|
|
5468
|
+
CGRectGetMinY(maskWindow), CGRectGetHeight(maskWindow), _pageMaskBoundary,
|
|
5469
|
+
_stickyHeaderIsPinned, _topScrollEdgeEnabled];
|
|
5470
|
+
if (layoutPhase && now - _homeVisualStartMono >= 2.0 &&
|
|
5471
|
+
[_homeVisualLastGeometrySignature isEqualToString:signature] &&
|
|
5472
|
+
now - _homeVisualLastLayoutLog < 2.0) return;
|
|
5473
|
+
if (layoutPhase) {
|
|
5474
|
+
_homeVisualLastLayoutLog = now;
|
|
5475
|
+
_homeVisualLastGeometrySignature = signature;
|
|
5476
|
+
}
|
|
5477
|
+
CGFloat visualYEstimate = CGRectGetMinY(controlWindow) +
|
|
5478
|
+
(control != nil ? control.layer.sublayerTransform.m42 : 0);
|
|
5479
|
+
CALayer *firstChild = control.layer.sublayers.firstObject;
|
|
5480
|
+
BOOL childAttached = firstChild != nil && control.window == self.window;
|
|
5481
|
+
CGRect firstChildWindow = childAttached
|
|
5482
|
+
? [firstChild convertRect:firstChild.bounds toLayer:self.window.layer]
|
|
5483
|
+
: CGRectZero;
|
|
5484
|
+
CGFloat overscroll = scrollView != nil
|
|
5485
|
+
? -(scrollView.contentOffset.y + scrollView.contentInset.top) : 0;
|
|
5486
|
+
double epochMs = [NSDate.date timeIntervalSince1970] * 1000;
|
|
5487
|
+
double monoMs = now * 1000;
|
|
5488
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
5489
|
+
@"[IOS-HOME-VISUAL] epochMs=%.0f monoMs=%.0f phase=%@ pagerTag=%ld generation=%lu pageIndex=%ld window=%d edge=%d overlay=%.1f header=%ld sticky=%ld collapse=%.1f scrollY=%.1f insetTop=%.1f overscroll=%.1f refresh=%d refreshing=%d controlY=%.1f controlH=%.1f sublayerY=%.1f visualYEstimate=%.1f overlayY=%.1f overlayBottom=%.1f stickyY=%.1f stickyBottom=%.1f maskY=%.1f maskH=%.1f pageMaskWindowY=%.1f",
|
|
5490
|
+
epochMs, monoMs, phase, (long)self.tag, (unsigned long)_generation,
|
|
5491
|
+
(long)_currentIndex, self.window != nil, _topScrollEdgeEnabled,
|
|
5492
|
+
self.effectiveTopOverlayHeight, (long)_headerHeight, (long)self.currentStickyHeaderHeight,
|
|
5493
|
+
_headerOffset, scrollView.contentOffset.y, scrollView.contentInset.top,
|
|
5494
|
+
overscroll, control != nil, control.isRefreshing,
|
|
5495
|
+
CGRectGetMinY(controlWindow), CGRectGetHeight(controlWindow),
|
|
5496
|
+
control != nil ? control.layer.sublayerTransform.m42 : 0, visualYEstimate,
|
|
5497
|
+
CGRectGetMinY(overlayWindow), CGRectGetMaxY(overlayWindow),
|
|
5498
|
+
CGRectGetMinY(stickyWindow), CGRectGetMaxY(stickyWindow),
|
|
5499
|
+
CGRectGetMinY(maskWindow), CGRectGetHeight(maskWindow), pageMaskWindowY]);
|
|
5500
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
5501
|
+
@"[IOS-HOME-VISUAL] epochMs=%.0f monoMs=%.0f phase=%@-refresh-layer pagerTag=%ld generation=%lu pageIndex=%ld boundsY=%.1f boundsH=%.1f centerY=%.1f transformTY=%.1f layerPositionY=%.1f layerTransformY=%.1f directChildCount=%lu firstChildAttached=%d firstChildWindowY=%.1f firstChildWindowH=%.1f",
|
|
5502
|
+
epochMs, monoMs, phase, (long)self.tag, (unsigned long)_generation,
|
|
5503
|
+
(long)_currentIndex, control.bounds.origin.y, control.bounds.size.height,
|
|
5504
|
+
control.center.y, control.transform.ty, control.layer.position.y,
|
|
5505
|
+
control.layer.transform.m42, (unsigned long)control.layer.sublayers.count,
|
|
5506
|
+
childAttached, CGRectGetMinY(firstChildWindow), CGRectGetHeight(firstChildWindow)]);
|
|
5507
|
+
if (![phase isEqualToString:@"pull"]) {
|
|
5508
|
+
CALayer *topCover = _topEdgeSeparatorCover;
|
|
5509
|
+
CALayer *stickyCover = _stickyEdgeSeparatorCover;
|
|
5510
|
+
UIColor *color = topCover.backgroundColor != nil
|
|
5511
|
+
? [UIColor colorWithCGColor:topCover.backgroundColor] : nil;
|
|
5512
|
+
CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
5513
|
+
[color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
5514
|
+
CGRect topCoverWindow = topCover.superlayer != nil
|
|
5515
|
+
? [topCover convertRect:topCover.bounds toLayer:self.window.layer] : CGRectZero;
|
|
5516
|
+
CGRect stickyCoverWindow = stickyCover.superlayer != nil
|
|
5517
|
+
? [stickyCover convertRect:stickyCover.bounds toLayer:self.window.layer] : CGRectZero;
|
|
5518
|
+
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
5519
|
+
@"[IOS-HOME-VISUAL] epochMs=%.0f monoMs=%.0f phase=%@-edge pagerTag=%ld generation=%lu pageIndex=%ld trait=%ld override=%ld style=%ld pinned=%d topHostY=%.1f topHostBottom=%.1f stickyHostY=%.1f stickyHostBottom=%.1f topInteractionSameScroll=%d stickyInteractionSameScroll=%d topCover=%d topCoverHidden=%d topCoverY=%.1f topCoverH=%.3f stickyCover=%d stickyCoverHidden=%d stickyCoverY=%.1f stickyCoverH=%.3f coverRGBA=%.3f,%.3f,%.3f,%.3f scale=%.1f",
|
|
5520
|
+
epochMs, monoMs, phase, (long)self.tag, (unsigned long)_generation,
|
|
5521
|
+
(long)_currentIndex, (long)self.traitCollection.userInterfaceStyle,
|
|
5522
|
+
(long)_topOverlayHostView.overrideUserInterfaceStyle,
|
|
5523
|
+
(long)_topScrollEdgeEffect, _stickyHeaderIsPinned,
|
|
5524
|
+
CGRectGetMinY(overlayWindow), CGRectGetMaxY(overlayWindow),
|
|
5525
|
+
CGRectGetMinY(stickyWindow), CGRectGetMaxY(stickyWindow),
|
|
5526
|
+
_topEdgeInteraction.scrollView == scrollView,
|
|
5527
|
+
_stickyEdgeInteraction.scrollView == scrollView,
|
|
5528
|
+
topCover != nil, topCover.hidden, CGRectGetMinY(topCoverWindow),
|
|
5529
|
+
CGRectGetHeight(topCoverWindow), stickyCover != nil,
|
|
5530
|
+
stickyCover.hidden,
|
|
5531
|
+
CGRectGetMinY(stickyCoverWindow),
|
|
5532
|
+
CGRectGetHeight(stickyCoverWindow), red, green, blue, alpha,
|
|
5533
|
+
self.window.screen.scale]);
|
|
5534
|
+
}
|
|
5535
|
+
#endif
|
|
3899
5536
|
}
|
|
3900
5537
|
|
|
3901
5538
|
- (void)releaseRefreshControlForScrollView:(UIScrollView *)scrollView
|
|
@@ -3959,6 +5596,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
3959
5596
|
// still represents the old list, before Fabric applies its next owner's props.
|
|
3960
5597
|
- (void)restoreScrollViewState:(UIScrollView *)scrollView resetSavedOffset:(BOOL)resetSavedOffset
|
|
3961
5598
|
{
|
|
5599
|
+
[self releaseProgrammaticScrollEdge:scrollView];
|
|
3962
5600
|
[self updateNativeScrollerViewport:scrollView stickyHeight:0];
|
|
3963
5601
|
[self releaseRefreshControlForScrollView:scrollView];
|
|
3964
5602
|
if (scrollView == _observedScrollView) {
|
|
@@ -4086,7 +5724,8 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4086
5724
|
// suppress its later vertical movement while the pager is still pending.
|
|
4087
5725
|
scrollView.directionalLockEnabled = _nativeSmoothHeaderScrollEnabled
|
|
4088
5726
|
? NO : [_originalDirectionalLockEnabled objectForKey:scrollView].boolValue;
|
|
4089
|
-
|
|
5727
|
+
CGFloat stickyHeight = [self stickyHeaderHeightForPageIndex:pageIndex];
|
|
5728
|
+
[self updateNativeScrollerViewport:scrollView stickyHeight:stickyHeight + self.effectiveTopOverlayHeight];
|
|
4090
5729
|
[self updateRefreshControlForScrollView:scrollView];
|
|
4091
5730
|
CGFloat previousTopInset = scrollView.contentInset.top;
|
|
4092
5731
|
CGFloat previousLogicalOffset = scrollView.contentOffset.y + previousTopInset;
|
|
@@ -4097,13 +5736,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4097
5736
|
CGFloat refreshInset = appliedTop != nil && scrollView.refreshControl != nil
|
|
4098
5737
|
? MAX(0, previousTopInset - appliedTop.doubleValue) : 0;
|
|
4099
5738
|
UIEdgeInsets next = original;
|
|
4100
|
-
next.top += self.effectiveTopOverlayHeight + _headerHeight +
|
|
5739
|
+
next.top += self.effectiveTopOverlayHeight + _headerHeight + stickyHeight;
|
|
4101
5740
|
CGFloat pagerTopInset = next.top;
|
|
4102
5741
|
next.top += refreshInset;
|
|
4103
5742
|
[_appliedTopInsets setObject:@(pagerTopInset) forKey:scrollView];
|
|
4104
5743
|
// Short pages still need enough range to collapse the header; long pages
|
|
4105
5744
|
// must end at the last row rather than leave a header-sized blank footer.
|
|
4106
|
-
next.bottom += MAX(0, scrollView.bounds.size.height -
|
|
5745
|
+
next.bottom += MAX(0, scrollView.bounds.size.height - stickyHeight - self.effectiveTopOverlayHeight
|
|
4107
5746
|
- original.top - original.bottom - scrollView.contentSize.height);
|
|
4108
5747
|
if (UIEdgeInsetsEqualToEdgeInsets(scrollView.contentInset, next) && !restore) {
|
|
4109
5748
|
// UICollectionView may report contentSize during a bounce without changing
|
|
@@ -4189,8 +5828,9 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4189
5828
|
|
|
4190
5829
|
- (void)updateNativeScrollerViewport:(UIScrollView *)scrollView stickyHeight:(CGFloat)height
|
|
4191
5830
|
{
|
|
4192
|
-
|
|
4193
|
-
|
|
5831
|
+
id host = scrollView.superview;
|
|
5832
|
+
if ([host respondsToSelector:@selector(setPagerStickyHeight:forOwner:)]) {
|
|
5833
|
+
[host setPagerStickyHeight:height forOwner:self];
|
|
4194
5834
|
}
|
|
4195
5835
|
}
|
|
4196
5836
|
|
|
@@ -4262,6 +5902,66 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4262
5902
|
}
|
|
4263
5903
|
|
|
4264
5904
|
|
|
5905
|
+
- (void)nativeScrollViewDidBecomeReadyNotification:(NSNotification *)notification
|
|
5906
|
+
{
|
|
5907
|
+
if ([notification.object isKindOfClass:UIScrollView.class]) {
|
|
5908
|
+
[self nativeScrollViewDidBecomeReady:(UIScrollView *)notification.object];
|
|
5909
|
+
}
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
- (void)nativeScrollViewDidBecomeReady:(UIScrollView *)scrollView
|
|
5913
|
+
{
|
|
5914
|
+
if (_isBeingRecycled || self.window == nil || scrollView == nil ||
|
|
5915
|
+
[_mountingRemovedScrollViews containsObject:scrollView]) return;
|
|
5916
|
+
for (UIView *ancestor = scrollView.superview;
|
|
5917
|
+
ancestor != nil && ancestor != self;
|
|
5918
|
+
ancestor = ancestor.superview) {
|
|
5919
|
+
if ([ancestor isKindOfClass:RNCCollapsiblePagerViewComponentView.class]) {
|
|
5920
|
+
RNCCollapsiblePagerViewComponentView *nestedPager =
|
|
5921
|
+
(RNCCollapsiblePagerViewComponentView *)ancestor;
|
|
5922
|
+
if ([nestedPager currentVerticalScrollViewForParentPager] != scrollView) return;
|
|
5923
|
+
break;
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
NSInteger pageIndex = NSNotFound;
|
|
5927
|
+
for (NSInteger index = 0; index < _pageControllers.count; index++) {
|
|
5928
|
+
if ([scrollView isDescendantOfView:_pageControllers[index].view]) {
|
|
5929
|
+
pageIndex = index;
|
|
5930
|
+
break;
|
|
5931
|
+
}
|
|
5932
|
+
}
|
|
5933
|
+
if (pageIndex == NSNotFound) return;
|
|
5934
|
+
|
|
5935
|
+
NSString *pageKey = [self pageKeyForIndex:pageIndex];
|
|
5936
|
+
BOOL hasReleasedStateForPage = _releasedPageScrollStates[pageKey] != nil;
|
|
5937
|
+
BOOL currentPageNeedsOwner = pageIndex == _currentIndex &&
|
|
5938
|
+
(_awaitingScrollOwnerForCurrentPage || _needsScrollObserverReattachAfterMount ||
|
|
5939
|
+
hasReleasedStateForPage ||
|
|
5940
|
+
(_observedScrollView != nil &&
|
|
5941
|
+
[_observedScrollView isKindOfClass:UICollectionView.class] &&
|
|
5942
|
+
!RNCIsMountedNativeListScrollView(_observedScrollView) &&
|
|
5943
|
+
_observedScrollView != scrollView));
|
|
5944
|
+
|
|
5945
|
+
if (!hasReleasedStateForPage && !currentPageNeedsOwner &&
|
|
5946
|
+
!_needsScrollObserverReattachAfterMount) return;
|
|
5947
|
+
|
|
5948
|
+
if (_nativeSmoothHeaderScrollEnabled) {
|
|
5949
|
+
NSInteger first = MAX(0, _currentIndex - 1);
|
|
5950
|
+
NSInteger last = MIN((NSInteger)_pageControllers.count - 1, _currentIndex + 1);
|
|
5951
|
+
BOOL isOwnedScroller = [scrollView.superview isKindOfClass:RNCNativeScrollerComponentView.class] &&
|
|
5952
|
+
((RNCNativeScrollerComponentView *)scrollView.superview).scrollView == scrollView;
|
|
5953
|
+
if ((pageIndex >= first && pageIndex <= last || pageIndex == _destinationIndex) &&
|
|
5954
|
+
(RNCIsMountedNativeListScrollView(scrollView) || isOwnedScroller) &&
|
|
5955
|
+
[_originalInsets objectForKey:scrollView] == nil) {
|
|
5956
|
+
[self applyInsetsToScrollView:scrollView pageIndex:pageIndex restore:YES];
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
|
|
5960
|
+
if (currentPageNeedsOwner && !_transitioning && !_isPagerDragging) {
|
|
5961
|
+
[self attachScrollObserverForCurrentPage];
|
|
5962
|
+
}
|
|
5963
|
+
}
|
|
5964
|
+
|
|
4265
5965
|
- (void)nativeScroller:(RNCNativeScrollerComponentView *)scroller
|
|
4266
5966
|
callerInsetChangedFrom:(UIEdgeInsets)previous to:(UIEdgeInsets)next
|
|
4267
5967
|
{
|
|
@@ -4313,6 +6013,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4313
6013
|
if (context == RNCScrollRefreshControlContext) {
|
|
4314
6014
|
UIScrollView *scrollView = (UIScrollView *)object;
|
|
4315
6015
|
[self updateRefreshControlForScrollView:scrollView];
|
|
6016
|
+
[self logHomeVisualGeometry:@"refresh-control-change" scrollView:scrollView];
|
|
4316
6017
|
if (scrollView == _observedScrollView && !_syntheticPageRestore &&
|
|
4317
6018
|
(!_nativeSmoothHeaderScrollEnabled || (!_transitioning && _transitionPageOffsets == nil))) {
|
|
4318
6019
|
[self updateHeaderForScrollView:scrollView];
|
|
@@ -4320,6 +6021,11 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4320
6021
|
return;
|
|
4321
6022
|
}
|
|
4322
6023
|
if (context == RNCCollapsiblePagerContentOffsetContext && object == _observedScrollView) {
|
|
6024
|
+
if ([keyPath isEqualToString:@"contentOffset"] &&
|
|
6025
|
+
-(((UIScrollView *)object).contentOffset.y +
|
|
6026
|
+
((UIScrollView *)object).contentInset.top) > 5) {
|
|
6027
|
+
[self logHomeVisualGeometry:@"pull" scrollView:(UIScrollView *)object];
|
|
6028
|
+
}
|
|
4323
6029
|
if (_pendingTopInsetReboundScrollView == object &&
|
|
4324
6030
|
([keyPath isEqualToString:@"contentOffset"] || [keyPath isEqualToString:@"contentInset"])) {
|
|
4325
6031
|
if (((UIScrollView *)object).panGestureRecognizer.state == UIGestureRecognizerStateChanged) {
|
|
@@ -4458,6 +6164,18 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4458
6164
|
|
|
4459
6165
|
#pragma mark - Pager navigation
|
|
4460
6166
|
|
|
6167
|
+
- (void)cancelPendingNativePagerScroll
|
|
6168
|
+
{
|
|
6169
|
+
[self stopProgrammaticTabProgress];
|
|
6170
|
+
if (_pendingNativePagerScrollCompletion == nil) return;
|
|
6171
|
+
_pendingNativePagerScrollCompletion = nil;
|
|
6172
|
+
_pendingNativePagerScrollGeneration = 0;
|
|
6173
|
+
_pendingNativePagerScrollTransition = 0;
|
|
6174
|
+
_pendingNativePagerScrollTarget = 0;
|
|
6175
|
+
CGPoint offset = _pagerScrollView.contentOffset;
|
|
6176
|
+
[_pagerScrollView setContentOffset:offset animated:NO];
|
|
6177
|
+
}
|
|
6178
|
+
|
|
4461
6179
|
- (BOOL)isLtrLayout
|
|
4462
6180
|
{
|
|
4463
6181
|
return [_layoutDirection isEqualToString:@"ltr"];
|
|
@@ -4467,6 +6185,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4467
6185
|
{
|
|
4468
6186
|
[self cancelTopInsetReboundCheck];
|
|
4469
6187
|
if (_isBeingRecycled || index < 0 || index >= _pageControllers.count) return;
|
|
6188
|
+
[self cancelNativeToolbarSettlement];
|
|
4470
6189
|
_hasReceivedPageCommand = YES;
|
|
4471
6190
|
_hasAppliedInitialPage = YES;
|
|
4472
6191
|
if (_transitioning || _isPagerDragging) {
|
|
@@ -4488,14 +6207,21 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4488
6207
|
[self attachScrollObserverForCurrentPage];
|
|
4489
6208
|
[self emitPageSelected:index];
|
|
4490
6209
|
[self emitDiagnostics:@"page-selected"];
|
|
6210
|
+
[self syncNativeToolbarState];
|
|
4491
6211
|
return;
|
|
4492
6212
|
}
|
|
4493
6213
|
|
|
6214
|
+
if (_directNativePagerEnabled && animated && index != _currentIndex) {
|
|
6215
|
+
[self adoptCurrentScrollEdgeForProgrammaticTransition:NO];
|
|
6216
|
+
}
|
|
4494
6217
|
[self beginPageStateTransition];
|
|
4495
6218
|
[self preparePageForHorizontalTransitionAtIndex:index];
|
|
4496
6219
|
_destinationIndex = index;
|
|
4497
6220
|
[self liftSharedHeadersForPagerTransition:@"programmatic"];
|
|
4498
6221
|
[self detachScrollObserver];
|
|
6222
|
+
if (_directNativePagerEnabled && animated && index != _currentIndex) {
|
|
6223
|
+
[self beginProgrammaticScrollEdgesToIndex:index allowExternalOverlay:NO];
|
|
6224
|
+
}
|
|
4499
6225
|
BOOL forward = (index > _currentIndex && self.isLtrLayout) ||
|
|
4500
6226
|
(index < _currentIndex && !self.isLtrLayout);
|
|
4501
6227
|
UIPageViewControllerNavigationDirection direction = forward
|
|
@@ -4510,13 +6236,14 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4510
6236
|
CGFloat targetOffset = [self directPagerOffsetForIndex:index];
|
|
4511
6237
|
void (^animations)(void) = ^{
|
|
4512
6238
|
[self->_pagerScrollView setContentOffset:CGPointMake(targetOffset, 0)];
|
|
4513
|
-
[self->_nativeTabBarView setProgress:index];
|
|
6239
|
+
if (self->_tabProgressDisplayLink == nil) [self->_nativeTabBarView setProgress:index];
|
|
4514
6240
|
[self updatePageStateTransitionProgress:index];
|
|
4515
6241
|
};
|
|
4516
6242
|
void (^completion)(BOOL) = ^(BOOL finished) {
|
|
4517
6243
|
__strong __typeof__(weakSelf) self = weakSelf;
|
|
4518
6244
|
if (self == nil || self->_generation != capturedGeneration ||
|
|
4519
6245
|
self->_transitionId != capturedTransition || self->_isBeingRecycled) return;
|
|
6246
|
+
[self stopProgrammaticTabProgress];
|
|
4520
6247
|
self->_pagerScrollView.scrollEnabled = self->_scrollEnabled;
|
|
4521
6248
|
if (finished) {
|
|
4522
6249
|
[self detachScrollObserver];
|
|
@@ -4535,13 +6262,42 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4535
6262
|
};
|
|
4536
6263
|
|
|
4537
6264
|
if (animated && index != _currentIndex) {
|
|
6265
|
+
BOOL useNativeAnimatedScroll = NO;
|
|
6266
|
+
if (@available(iOS 27.0, *)) {
|
|
6267
|
+
useNativeAnimatedScroll = _nativeSmoothHeaderScrollEnabled && _topScrollEdgeEnabled &&
|
|
6268
|
+
_topScrollEdgeEffect == RNCCollapsiblePagerViewTopScrollEdgeEffect::Hard &&
|
|
6269
|
+
_topOverlayView != nil && _externalTopOverlayTag <= 0 && self.window != nil;
|
|
6270
|
+
}
|
|
6271
|
+
if (useNativeAnimatedScroll) {
|
|
6272
|
+
// Keep the traversed pages owned until UIKit finishes scrolling.
|
|
6273
|
+
NSInteger first = MIN(_currentIndex, index);
|
|
6274
|
+
NSInteger last = MAX(_currentIndex, index);
|
|
6275
|
+
_programmaticPageMaskIndexes = [NSIndexSet indexSetWithIndexesInRange:
|
|
6276
|
+
NSMakeRange(first, last - first + 1)];
|
|
6277
|
+
[self updateScrollEdgeContentMasks];
|
|
6278
|
+
}
|
|
4538
6279
|
_pagerScrollView.scrollEnabled = NO;
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
6280
|
+
if (useNativeAnimatedScroll) {
|
|
6281
|
+
if (fabs(_pagerScrollView.contentOffset.x - targetOffset) <= 0.5) {
|
|
6282
|
+
[self updateNativeTabProgress:index];
|
|
6283
|
+
[self updatePageStateTransitionProgress:index];
|
|
6284
|
+
completion(YES);
|
|
6285
|
+
} else {
|
|
6286
|
+
_pendingNativePagerScrollCompletion = [completion copy];
|
|
6287
|
+
_pendingNativePagerScrollGeneration = capturedGeneration;
|
|
6288
|
+
_pendingNativePagerScrollTransition = capturedTransition;
|
|
6289
|
+
_pendingNativePagerScrollTarget = targetOffset;
|
|
6290
|
+
[_pagerScrollView setContentOffset:CGPointMake(targetOffset, 0) animated:YES];
|
|
6291
|
+
}
|
|
6292
|
+
} else {
|
|
6293
|
+
if ([_nativeTabBarView usesControlledTextProgress]) [self startProgrammaticTabProgress];
|
|
6294
|
+
[UIView animateWithDuration:0.28
|
|
6295
|
+
delay:0
|
|
6296
|
+
options:UIViewAnimationOptionCurveEaseInOut |
|
|
6297
|
+
UIViewAnimationOptionAllowUserInteraction
|
|
6298
|
+
animations:animations
|
|
6299
|
+
completion:completion];
|
|
6300
|
+
}
|
|
4545
6301
|
} else {
|
|
4546
6302
|
[UIView performWithoutAnimation:animations];
|
|
4547
6303
|
completion(YES);
|
|
@@ -4583,7 +6339,10 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4583
6339
|
if (self->_generation != generation || self->_transitionId != transition ||
|
|
4584
6340
|
self->_isBeingRecycled) return;
|
|
4585
6341
|
[self finishPageStateTransition];
|
|
6342
|
+
self->_programmaticPageMaskIndexes = nil;
|
|
4586
6343
|
self->_transitioning = NO;
|
|
6344
|
+
BOOL hadProgrammaticScrollEdges = self->_programmaticScrollEdgeOwners.count > 0;
|
|
6345
|
+
[self finishProgrammaticScrollEdges];
|
|
4587
6346
|
if (self->_hasPendingDirectNativePagerChange) {
|
|
4588
6347
|
BOOL enabled = self->_pendingDirectNativePagerEnabled;
|
|
4589
6348
|
self->_hasPendingDirectNativePagerChange = NO;
|
|
@@ -4592,11 +6351,16 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4592
6351
|
[self rebuildSlots];
|
|
4593
6352
|
}
|
|
4594
6353
|
if (!self->_hasAppliedInitialPage) [self setNeedsLayout];
|
|
6354
|
+
if (hadProgrammaticScrollEdges && !self->_transitioning && !self->_needsSlotRebuild) {
|
|
6355
|
+
[self attachScrollObserverForCurrentPage];
|
|
6356
|
+
}
|
|
4595
6357
|
[self drainPendingGoTo];
|
|
4596
|
-
if (!self->_transitioning && !self->
|
|
6358
|
+
if (!self->_transitioning && !self->_isPagerDragging && self->_pendingGoToIndex < 0) self->_toolbarTransitionPending = NO;
|
|
6359
|
+
if (!hadProgrammaticScrollEdges && !self->_transitioning && !self->_needsSlotRebuild) {
|
|
4597
6360
|
[self attachScrollObserverForCurrentPage];
|
|
4598
6361
|
}
|
|
4599
6362
|
[self updateScrollEdgeContentMasks];
|
|
6363
|
+
[self syncNativeToolbarState];
|
|
4600
6364
|
});
|
|
4601
6365
|
}
|
|
4602
6366
|
|
|
@@ -4647,21 +6411,30 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4647
6411
|
|
|
4648
6412
|
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
|
4649
6413
|
{
|
|
6414
|
+
if (scrollView == _pagerScrollView) [self cancelPendingNativePagerScroll];
|
|
6415
|
+
++_transitionId;
|
|
4650
6416
|
[self updateHeaderSettledStateForceBusy:YES];
|
|
4651
6417
|
if (_nativeSmoothHeaderScrollEnabled && scrollView == _pagerScrollView) {
|
|
4652
6418
|
[_contentPressCancellationGesture cancelPressForPan:scrollView.panGestureRecognizer];
|
|
4653
6419
|
}
|
|
6420
|
+
if (_directNativePagerEnabled) [self adoptCurrentScrollEdgeForProgrammaticTransition:YES];
|
|
4654
6421
|
[self beginPageStateTransition];
|
|
4655
6422
|
if (_directNativePagerEnabled) {
|
|
4656
6423
|
[self preparePageForHorizontalTransitionAtIndex:_currentIndex - 1];
|
|
4657
6424
|
[self preparePageForHorizontalTransitionAtIndex:_currentIndex + 1];
|
|
4658
6425
|
}
|
|
4659
6426
|
// A user drag owns the result even if UIKit later completes the old animation.
|
|
4660
|
-
|
|
6427
|
+
_programmaticPageMaskIndexes = nil;
|
|
4661
6428
|
[self liftSharedHeadersForPagerTransition:@"interactive"];
|
|
4662
6429
|
[self detachScrollObserver];
|
|
4663
6430
|
_isPagerDragging = YES;
|
|
4664
6431
|
_transitioning = YES;
|
|
6432
|
+
if (_directNativePagerEnabled) {
|
|
6433
|
+
if (_currentIndex > 0) [self beginProgrammaticScrollEdgesToIndex:_currentIndex - 1 allowExternalOverlay:YES];
|
|
6434
|
+
if (_currentIndex + 1 < _pageControllers.count) {
|
|
6435
|
+
[self beginProgrammaticScrollEdgesToIndex:_currentIndex + 1 allowExternalOverlay:YES];
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
4665
6438
|
if (_nativeSmoothHeaderScrollEnabled) {
|
|
4666
6439
|
RNCCollapsiblePagerLog([NSString stringWithFormat:
|
|
4667
6440
|
@"gesture-owner=pager page=%ld",
|
|
@@ -4707,7 +6480,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4707
6480
|
[self directPagerOffsetForIndex:index],
|
|
4708
6481
|
0
|
|
4709
6482
|
) animated:NO];
|
|
4710
|
-
[
|
|
6483
|
+
[self updateNativeTabProgress:index];
|
|
4711
6484
|
[self attachScrollObserverForCurrentPageAfterTransition:YES];
|
|
4712
6485
|
if (emitSelection &&
|
|
4713
6486
|
(_pendingGoToIndex < 0 || _pendingGoToIndex == index)) {
|
|
@@ -4758,7 +6531,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4758
6531
|
[self detachScrollObserver];
|
|
4759
6532
|
_currentIndex = index;
|
|
4760
6533
|
_destinationIndex = index;
|
|
4761
|
-
[
|
|
6534
|
+
[self updateNativeTabProgress:index];
|
|
4762
6535
|
[self attachScrollObserverForCurrentPageAfterTransition:YES];
|
|
4763
6536
|
// A newer tab tap remains authoritative while its queued command runs.
|
|
4764
6537
|
if (emitSelection &&
|
|
@@ -4794,6 +6567,20 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4794
6567
|
[self finishPagerScrollEmittingSelection:YES];
|
|
4795
6568
|
}
|
|
4796
6569
|
|
|
6570
|
+
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
|
|
6571
|
+
{
|
|
6572
|
+
if (scrollView != _pagerScrollView || _pendingNativePagerScrollCompletion == nil ||
|
|
6573
|
+
scrollView.isDragging || _generation != _pendingNativePagerScrollGeneration ||
|
|
6574
|
+
_transitionId != _pendingNativePagerScrollTransition ||
|
|
6575
|
+
fabs(scrollView.contentOffset.x - _pendingNativePagerScrollTarget) > 0.5) return;
|
|
6576
|
+
void (^completion)(BOOL) = _pendingNativePagerScrollCompletion;
|
|
6577
|
+
_pendingNativePagerScrollCompletion = nil;
|
|
6578
|
+
_pendingNativePagerScrollGeneration = 0;
|
|
6579
|
+
_pendingNativePagerScrollTransition = 0;
|
|
6580
|
+
_pendingNativePagerScrollTarget = 0;
|
|
6581
|
+
completion(YES);
|
|
6582
|
+
}
|
|
6583
|
+
|
|
4797
6584
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
|
4798
6585
|
{
|
|
4799
6586
|
CGFloat width = scrollView.bounds.size.width;
|
|
@@ -4805,7 +6592,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4805
6592
|
position = MAX(0, MIN(position, (NSInteger)_pageControllers.count - 1));
|
|
4806
6593
|
[self updatePageStateTransitionProgress:progress];
|
|
4807
6594
|
[self updateScrollEdgeContentMasks];
|
|
4808
|
-
[
|
|
6595
|
+
if (_tabProgressDisplayLink == nil) [self updateNativeTabProgress:progress];
|
|
4809
6596
|
const auto emitter = [self eventEmitter];
|
|
4810
6597
|
if (emitter) {
|
|
4811
6598
|
emitter->onPageScroll({.position = (double)position, .offset = (double)offset});
|
|
@@ -4824,7 +6611,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4824
6611
|
}
|
|
4825
6612
|
[self updatePageStateTransitionProgress:tabProgress];
|
|
4826
6613
|
[self updateScrollEdgeContentMasks];
|
|
4827
|
-
[
|
|
6614
|
+
[self updateNativeTabProgress:tabProgress];
|
|
4828
6615
|
const auto emitter = [self eventEmitter];
|
|
4829
6616
|
if (emitter) {
|
|
4830
6617
|
emitter->onPageScroll({.position = (double)position, .offset = (double)offset});
|
|
@@ -4895,7 +6682,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4895
6682
|
UIEdgeInsets adjustedInset = owner.adjustedContentInset;
|
|
4896
6683
|
NSString *geometry = [NSString stringWithFormat:
|
|
4897
6684
|
@"%.4f:%ld:%ld:%@:%@:%@:%@:%@:%@:%@",
|
|
4898
|
-
_headerOffset, (long)_headerHeight, (long)
|
|
6685
|
+
_headerOffset, (long)_headerHeight, (long)self.currentStickyHeaderHeight,
|
|
4899
6686
|
NSStringFromCGPoint(owner.contentOffset), NSStringFromCGSize(owner.contentSize),
|
|
4900
6687
|
NSStringFromCGRect(owner.bounds), NSStringFromUIEdgeInsets(inset),
|
|
4901
6688
|
NSStringFromUIEdgeInsets(adjustedInset), NSStringFromCGRect(headerRect), NSStringFromCGRect(ownerRect)];
|
|
@@ -4978,6 +6765,13 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4978
6765
|
{
|
|
4979
6766
|
UIScrollView *scrollView = _pagerTopScrollView;
|
|
4980
6767
|
if (_dispatchingPagerTop || ![self matchesPagerTop:scrollView]) return;
|
|
6768
|
+
CGFloat clampedTarget = MIN(MAX(_pagerTopLogicalTarget, 0), _headerHeight);
|
|
6769
|
+
if (clampedTarget != _pagerTopLogicalTarget) {
|
|
6770
|
+
_pagerTopLogicalTarget = clampedTarget;
|
|
6771
|
+
CGFloat physicalTarget = RNCLimitRestoredScrollOffset(clampedTarget - scrollView.contentInset.top,
|
|
6772
|
+
scrollView.contentSize.height, scrollView.bounds.size.height, scrollView.contentInset.top, scrollView.contentInset.bottom);
|
|
6773
|
+
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, physicalTarget) animated:NO];
|
|
6774
|
+
}
|
|
4981
6775
|
CGFloat logical = scrollView.contentOffset.y + scrollView.contentInset.top;
|
|
4982
6776
|
if (fabs(logical - _pagerTopLogicalTarget) > 0.5) return;
|
|
4983
6777
|
_pageOffsets[_pagerTopPageKey] = @(_nativeSmoothHeaderScrollEnabled ? 0 : _pagerTopLogicalTarget);
|
|
@@ -4989,11 +6783,29 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
4989
6783
|
}
|
|
4990
6784
|
|
|
4991
6785
|
- (void)scrollToTop:(NSInteger)target animated:(BOOL)animated
|
|
6786
|
+
{
|
|
6787
|
+
if (target != 0 && target != 1) return;
|
|
6788
|
+
[self scrollHeaderToOffset:(target == 1 ? _headerHeight : 0) animated:animated];
|
|
6789
|
+
}
|
|
6790
|
+
|
|
6791
|
+
- (void)scrollHeaderBy:(double)delta
|
|
6792
|
+
{
|
|
6793
|
+
if (!std::isfinite(delta)) return;
|
|
6794
|
+
[self scrollHeaderToOffset:MIN(MAX(_headerOffset + delta, 0), _headerHeight) animated:NO];
|
|
6795
|
+
}
|
|
6796
|
+
|
|
6797
|
+
- (void)scrollHeaderToOffset:(double)offset
|
|
6798
|
+
{
|
|
6799
|
+
if (!std::isfinite(offset)) return;
|
|
6800
|
+
[self scrollHeaderToOffset:MIN(MAX(offset, 0), _headerHeight) animated:NO];
|
|
6801
|
+
}
|
|
6802
|
+
|
|
6803
|
+
- (void)scrollHeaderToOffset:(CGFloat)logicalTarget animated:(BOOL)animated
|
|
4992
6804
|
{
|
|
4993
6805
|
[self cancelTopInsetReboundCheck];
|
|
4994
6806
|
UIScrollView *scrollView = _observedScrollView;
|
|
4995
6807
|
NSString *key = _observedPageKey;
|
|
4996
|
-
if (
|
|
6808
|
+
if (_isBeingRecycled || _transitioning || _isPagerDragging ||
|
|
4997
6809
|
_transitionPageOffsets != nil || _syntheticPageRestore || scrollView == nil || scrollView.window == nil ||
|
|
4998
6810
|
key == nil || ![key isEqualToString:self.currentPageKey] || _observedPageIndex != _currentIndex ||
|
|
4999
6811
|
_observedPageGeneration != _generation || self.window == nil) return;
|
|
@@ -5009,7 +6821,7 @@ static void RNCLogNativeTabScrollBoundary(NSString *owner,
|
|
|
5009
6821
|
[_alignedBodyKeys removeObject:key];
|
|
5010
6822
|
[_suspendedBodyKeys removeObject:key];
|
|
5011
6823
|
[_displayBodyOverrides removeObjectForKey:key];
|
|
5012
|
-
|
|
6824
|
+
logicalTarget = MIN(MAX(logicalTarget, 0), _headerHeight);
|
|
5013
6825
|
_pageOffsets[key] = @(_nativeSmoothHeaderScrollEnabled ? 0 : logicalTarget);
|
|
5014
6826
|
_pagerTopScrollView = scrollView;
|
|
5015
6827
|
_pagerTopPageKey = [key copy];
|