@onekeyfe/react-native-pager-view 6.7.0-alpha.359 → 6.7.0-alpha.363

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.
@@ -2,35 +2,13 @@
2
2
 
3
3
  #import "RNCCollapsiblePagerViewComponentView.h"
4
4
  #import "RNCPagerViewComponentView.h"
5
- #import <React/RCTViewComponentView.h>
6
5
  #import <react/renderer/components/pagerview/Props.h>
7
- #import <react/renderer/components/view/ViewProps.h>
8
6
 
9
7
  using namespace facebook::react;
10
8
 
11
9
  @interface RNCCollapsiblePagerViewComponentView (ScrollEdgeTesting)
12
10
  - (void)updateTopScrollEdgeForScrollView:(UIScrollView *)scrollView;
13
11
  - (void)updateScrollEdgeContentMasks;
14
- - (void)layoutSharedHeaders;
15
- @end
16
-
17
- @interface UIView (NativeTabReservationTesting)
18
- - (void)updateItemsJSON:(NSString *)itemsJSON;
19
- - (void)updateStyleWithHeight:(CGFloat)height
20
- variant:(NSString *)variant
21
- contentPaddingHorizontal:(CGFloat)contentPaddingHorizontal
22
- contentPaddingVertical:(CGFloat)contentPaddingVertical
23
- itemSpacing:(CGFloat)itemSpacing
24
- fontSize:(CGFloat)fontSize
25
- fontFamily:(NSString *)fontFamily
26
- backgroundColor:(UIColor *)backgroundColor
27
- activeTextColor:(UIColor *)activeTextColor
28
- inactiveTextColor:(UIColor *)inactiveTextColor
29
- indicatorColor:(UIColor *)indicatorColor
30
- indicatorHeight:(CGFloat)indicatorHeight
31
- indicatorBottom:(CGFloat)indicatorBottom;
32
- - (void)setProgress:(CGFloat)progress;
33
- - (void)setLeftToRight:(BOOL)leftToRight;
34
12
  @end
35
13
 
36
14
  @interface RNCCollapsiblePagerHitTestTests : XCTestCase
@@ -78,162 +56,6 @@ using namespace facebook::react;
78
56
  XCTAssertEqual([self.root hitTest:CGPointMake(20, 80) withEvent:nil], self.toolbar);
79
57
  }
80
58
 
81
- - (void)testNativeTabReservationKeepsReactToolbarAboveTabsAndResetsInRTL
82
- {
83
- UIView *sharedHost = [self.pager valueForKey:@"sharedHeaderHostView"];
84
- UIView *tabBar = [self.pager valueForKey:@"nativeTabBarView"];
85
- [tabBar updateItemsJSON:@"[{\"key\":\"a\",\"title\":\"Overview\"},"
86
- @"{\"key\":\"b\",\"title\":\"Ethereum\"},"
87
- @"{\"key\":\"c\",\"title\":\"BNB Chain\"},"
88
- @"{\"key\":\"d\",\"title\":\"Polygon\"}]"];
89
- RCTViewComponentView *sticky = [RCTViewComponentView new];
90
- auto stickyProps = std::make_shared<ViewProps>();
91
- stickyProps->pointerEvents = PointerEventsMode::BoxNone;
92
- [sticky updateProps:stickyProps oldProps:nullptr];
93
- UIButton *trailingControl = [[UIButton alloc] initWithFrame:CGRectMake(250, 0, 70, 44)];
94
- [sticky addSubview:trailingControl];
95
- [sharedHost addSubview:sticky];
96
- [sharedHost addSubview:tabBar];
97
- [self.pager setValue:sticky forKey:@"stickyHeaderView"];
98
- [self.pager setValue:@0 forKey:@"headerHeight"];
99
- [self.pager setValue:@44 forKey:@"stickyHeaderHeight"];
100
- tabBar.hidden = NO;
101
-
102
- [self.pager setValue:@64 forKey:@"nativeTabBarTrailingReservedWidth"];
103
- [self.pager layoutSharedHeaders];
104
- XCTAssertEqualWithAccuracy(CGRectGetWidth(sticky.frame), 320, 0.001);
105
- XCTAssertEqualWithAccuracy(CGRectGetWidth(tabBar.frame), 256, 0.001);
106
- XCTAssertEqualWithAccuracy(CGRectGetMinX(tabBar.frame), 0, 0.001);
107
- XCTAssertEqual(sharedHost.subviews.lastObject, sticky);
108
- XCTAssertEqual([sharedHost hitTest:CGPointMake(300, 22) withEvent:nil], trailingControl);
109
- XCTAssertTrue([tabBar pointInside:CGPointMake(250, 22) withEvent:nil]);
110
- [tabBar layoutIfNeeded];
111
- [tabBar setProgress:3];
112
- UIScrollView *tabScroll = (UIScrollView *)tabBar.subviews.firstObject;
113
- NSArray<UIButton *> *buttons = [tabScroll.subviews filteredArrayUsingPredicate:
114
- [NSPredicate predicateWithBlock:^BOOL(UIView *view, NSDictionary *bindings) {
115
- return [view isKindOfClass:UIButton.class];
116
- }]];
117
- UIButton *lastTab = buttons.lastObject;
118
- XCTAssertNotNil(lastTab);
119
- XCTAssertGreaterThanOrEqual(CGRectGetMinX(lastTab.frame), tabScroll.contentOffset.x - 1);
120
- XCTAssertLessThanOrEqual(CGRectGetMaxX(lastTab.frame),
121
- tabScroll.contentOffset.x + CGRectGetWidth(tabScroll.bounds) + 1);
122
-
123
- [self.pager setValue:@"rtl" forKey:@"layoutDirection"];
124
- [tabBar setLeftToRight:NO];
125
- trailingControl.frame = CGRectMake(0, 0, 70, 44);
126
- [self.pager layoutSharedHeaders];
127
- XCTAssertEqualWithAccuracy(CGRectGetMinX(tabBar.frame), 64, 0.001);
128
- XCTAssertEqualWithAccuracy(CGRectGetMaxX(tabBar.frame), 320, 0.001);
129
- XCTAssertEqual([sharedHost hitTest:CGPointMake(20, 22) withEvent:nil], trailingControl);
130
-
131
- [self.pager setValue:@500 forKey:@"nativeTabBarTrailingReservedWidth"];
132
- [self.pager layoutSharedHeaders];
133
- XCTAssertEqualWithAccuracy(CGRectGetMinX(tabBar.frame), 320, 0.001);
134
- XCTAssertEqualWithAccuracy(CGRectGetWidth(tabBar.frame), 0, 0.001);
135
-
136
- [self.pager setValue:@0 forKey:@"nativeTabBarTrailingReservedWidth"];
137
- [self.pager layoutSharedHeaders];
138
- XCTAssertEqualWithAccuracy(CGRectGetMinX(tabBar.frame), 0, 0.001);
139
- XCTAssertEqualWithAccuracy(CGRectGetWidth(tabBar.frame), 320, 0.001);
140
- XCTAssertEqual(sharedHost.subviews.lastObject, tabBar);
141
- }
142
-
143
- - (void)testNativeTabReservationPropsRestoreDefaultOnRemoval
144
- {
145
- auto reservedProps = std::make_shared<RNCCollapsiblePagerViewProps>();
146
- reservedProps->nativeSmoothHeaderScrollEnabled = true;
147
- reservedProps->nativeTabBarTrailingReservedWidth = 64;
148
- [self.pager updateProps:reservedProps oldProps:nullptr];
149
- XCTAssertEqualWithAccuracy(
150
- [[self.pager valueForKey:@"nativeTabBarTrailingReservedWidth"] doubleValue], 64, 0.001);
151
-
152
- auto defaultProps = std::make_shared<RNCCollapsiblePagerViewProps>();
153
- defaultProps->nativeSmoothHeaderScrollEnabled = true;
154
- [self.pager updateProps:defaultProps oldProps:reservedProps];
155
- XCTAssertEqualWithAccuracy(
156
- [[self.pager valueForKey:@"nativeTabBarTrailingReservedWidth"] doubleValue], 0, 0.001);
157
- }
158
-
159
- - (void)testSegmentedNativeTabsFollowFractionalProgressAndResetToUnderline
160
- {
161
- UIView *tabBar = [self.pager valueForKey:@"nativeTabBarView"];
162
- [tabBar updateItemsJSON:@"[{\"key\":\"recent\",\"title\":\"Recents\"},"
163
- @"{\"key\":\"account\",\"title\":\"Accounts\"},"
164
- @"{\"key\":\"book\",\"title\":\"Address Book\"}]"];
165
- [tabBar updateStyleWithHeight:56 variant:@"segmented"
166
- contentPaddingHorizontal:20 contentPaddingVertical:12 itemSpacing:0
167
- fontSize:14 fontFamily:nil backgroundColor:UIColor.lightGrayColor
168
- activeTextColor:UIColor.blackColor inactiveTextColor:UIColor.grayColor
169
- indicatorColor:UIColor.whiteColor indicatorHeight:2 indicatorBottom:0];
170
- tabBar.frame = CGRectMake(0, 0, 320, 56);
171
- [tabBar layoutIfNeeded];
172
- UIScrollView *scroll = (UIScrollView *)tabBar.subviews.firstObject;
173
- UIView *track = scroll.subviews.firstObject;
174
- UIView *thumb = [tabBar valueForKey:@"indicatorView"];
175
- NSArray<UIButton *> *buttons = [scroll.subviews filteredArrayUsingPredicate:
176
- [NSPredicate predicateWithBlock:^BOOL(UIView *view, NSDictionary *bindings) {
177
- return [view isKindOfClass:UIButton.class];
178
- }]];
179
- XCTAssertEqual(buttons.count, 3);
180
- XCTAssertFalse(scroll.scrollEnabled);
181
- XCTAssertEqualWithAccuracy(CGRectGetMinX(track.frame), 20, 0.01);
182
- XCTAssertEqualWithAccuracy(CGRectGetHeight(track.frame), 32, 0.01);
183
- XCTAssertEqualWithAccuracy(CGRectGetWidth(buttons[0].frame),
184
- CGRectGetWidth(buttons[1].frame), 0.01);
185
- [tabBar setProgress:0];
186
- CGFloat firstX = CGRectGetMinX(thumb.frame);
187
- [tabBar setProgress:1];
188
- CGFloat secondX = CGRectGetMinX(thumb.frame);
189
- [tabBar setProgress:0.25];
190
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame), firstX + (secondX - firstX) * 0.25, 0.01);
191
- [tabBar setProgress:0.5];
192
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame), (firstX + secondX) / 2, 0.01);
193
- [tabBar setProgress:0];
194
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame), firstX, 0.01);
195
-
196
- [tabBar setLeftToRight:NO];
197
- [tabBar layoutIfNeeded];
198
- XCTAssertGreaterThan(CGRectGetMinX(buttons[0].frame), CGRectGetMinX(buttons[1].frame));
199
- [tabBar updateItemsJSON:@"[{\"key\":\"recent\",\"title\":\"Recents (8)\"},"
200
- @"{\"key\":\"account\",\"title\":\"Accounts\"}]"];
201
- [tabBar layoutIfNeeded];
202
- NSArray<UIButton *> *twoButtons = [scroll.subviews filteredArrayUsingPredicate:
203
- [NSPredicate predicateWithBlock:^BOOL(UIView *view, NSDictionary *bindings) {
204
- return [view isKindOfClass:UIButton.class];
205
- }]];
206
- XCTAssertEqual(twoButtons.count, 2);
207
- XCTAssertEqualWithAccuracy(CGRectGetWidth(twoButtons[0].frame),
208
- CGRectGetWidth(track.frame) / 2, 0.01);
209
- [tabBar updateStyleWithHeight:56 variant:@"segmented"
210
- contentPaddingHorizontal:20 contentPaddingVertical:40 itemSpacing:0
211
- fontSize:14 fontFamily:nil backgroundColor:UIColor.lightGrayColor
212
- activeTextColor:UIColor.blackColor inactiveTextColor:UIColor.grayColor
213
- indicatorColor:UIColor.whiteColor indicatorHeight:2 indicatorBottom:0];
214
- tabBar.frame = CGRectMake(0, 0, 30, 56);
215
- [tabBar layoutIfNeeded];
216
- XCTAssertEqualWithAccuracy(CGRectGetMinX(track.frame), 15, 0.01);
217
- XCTAssertEqualWithAccuracy(CGRectGetWidth(track.frame), 0, 0.01);
218
- XCTAssertEqualWithAccuracy(CGRectGetMinY(track.frame), 28, 0.01);
219
- XCTAssertEqualWithAccuracy(CGRectGetHeight(track.frame), 0, 0.01);
220
- XCTAssertTrue(thumb.hidden);
221
- [tabBar updateItemsJSON:@"[]"];
222
- XCTAssertTrue(tabBar.hidden);
223
-
224
- [tabBar updateItemsJSON:@"[{\"key\":\"recent\",\"title\":\"Recents\"}]"];
225
- [tabBar updateStyleWithHeight:44 variant:@"underline"
226
- contentPaddingHorizontal:20 contentPaddingVertical:0 itemSpacing:8
227
- fontSize:16 fontFamily:nil backgroundColor:UIColor.clearColor
228
- activeTextColor:UIColor.blackColor inactiveTextColor:UIColor.grayColor
229
- indicatorColor:UIColor.blackColor indicatorHeight:2 indicatorBottom:0];
230
- tabBar.frame = CGRectMake(0, 0, 320, 44);
231
- [tabBar layoutIfNeeded];
232
- XCTAssertTrue(scroll.scrollEnabled);
233
- XCTAssertTrue(track.hidden);
234
- XCTAssertEqualWithAccuracy(CGRectGetHeight(thumb.frame), 2, 0.01);
235
- }
236
-
237
59
  - (void)testPinnedChildOutsideHeaderHostStillReceivesViewportTouches
238
60
  {
239
61
  XCTAssertEqual([self.pager hitTest:CGPointMake(20, 90) withEvent:nil], self.sticky);
@@ -763,26 +763,6 @@ typedef struct __IOHIDEvent *RNCTestHIDEventRef;
763
763
  XCTAssertTrue([pager isKindOfClass:NSClassFromString(@"RNCCollapsiblePagerDirectScrollView")]);
764
764
  }
765
765
 
766
- - (void)configureSegmentedTabsForTwoPages
767
- {
768
- auto baseline = std::make_shared<RNCCollapsiblePagerViewProps>();
769
- baseline->nativeSmoothHeaderScrollEnabled = true;
770
- baseline->headerHeight = 120;
771
- baseline->stickyHeaderHeight = 44;
772
- auto segmented = std::make_shared<RNCCollapsiblePagerViewProps>();
773
- segmented->nativeSmoothHeaderScrollEnabled = true;
774
- segmented->headerHeight = 120;
775
- segmented->stickyHeaderHeight = 56;
776
- segmented->nativeTabBarItems =
777
- R"([{"key":"recent","title":"Recents"},{"key":"account","title":"Accounts"}])";
778
- segmented->nativeTabBarVariant = "segmented";
779
- segmented->nativeTabBarHeight = 56;
780
- segmented->nativeTabBarContentPaddingHorizontal = 20;
781
- segmented->nativeTabBarContentPaddingVertical = 12;
782
- [self.pager updateProps:segmented oldProps:baseline];
783
- [self.window layoutIfNeeded];
784
- }
785
-
786
766
  - (void)recordPagerPan:(UIPanGestureRecognizer *)pan
787
767
  {
788
768
  if (pan.state == UIGestureRecognizerStateBegan) self.pagerPanBegins += 1;
@@ -924,51 +904,6 @@ typedef struct __IOHIDEvent *RNCTestHIDEventRef;
924
904
  XCTAssertEqual(self.handler.events.count, eventsBeforeLift);
925
905
  }
926
906
 
927
- - (void)testSegmentedThumbTracksDeliveredPagerDragAndReverseBeforeLift
928
- {
929
- [self assertFixtureIsReadyForDelivery];
930
- [self assertDirectPagerForRegression];
931
- [self configureSegmentedTabsForTwoPages];
932
-
933
- UIScrollView *pagerScrollView = [self.pager valueForKey:@"pagerScrollView"];
934
- UIView *tabBar = [self.pager valueForKey:@"nativeTabBarView"];
935
- UIView *thumb = [tabBar valueForKey:@"indicatorView"];
936
- NSArray<UIButton *> *buttons = [tabBar valueForKey:@"buttons"];
937
- XCTAssertEqual(buttons.count, 2);
938
- XCTAssertFalse(tabBar.hidden);
939
- XCTAssertEqualWithAccuracy(CGRectGetHeight(tabBar.bounds), 56, 0.01);
940
- CGFloat firstThumbX = CGRectGetMinX(buttons[0].frame) + 2;
941
- CGFloat secondThumbX = CGRectGetMinX(buttons[1].frame) + 2;
942
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame), firstThumbX, 1);
943
-
944
- CGPoint point = CGPointMake(350, 600);
945
- UITouch *touch = [self.driver beginAt:point];
946
- CGFloat largestOffset = 0;
947
- NSUInteger intermediateFrames = 0;
948
- for (NSInteger step = 1; step <= 18; ++step) {
949
- [self.driver move:touch to:CGPointMake(point.x - 14 * step, point.y)];
950
- CGFloat offset = pagerScrollView.contentOffset.x;
951
- largestOffset = MAX(largestOffset, offset);
952
- if (offset > 1 && offset < CGRectGetWidth(pagerScrollView.bounds) - 1) {
953
- CGFloat progress = offset / CGRectGetWidth(pagerScrollView.bounds);
954
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame),
955
- firstThumbX + (secondThumbX - firstThumbX) * progress, 1);
956
- intermediateFrames += 1;
957
- }
958
- }
959
- XCTAssertTrue(pagerScrollView.isDragging);
960
- XCTAssertGreaterThan(largestOffset, 80);
961
- XCTAssertGreaterThan(intermediateFrames, 2);
962
-
963
- for (NSInteger step = 17; step >= 0; --step) {
964
- [self.driver move:touch to:CGPointMake(point.x - 14 * step, point.y)];
965
- }
966
- // UIKit can briefly bounce past the leading edge before the finger lifts.
967
- XCTAssertLessThan(fabs(pagerScrollView.contentOffset.x), 10);
968
- XCTAssertEqualWithAccuracy(CGRectGetMinX(thumb.frame), firstThumbX, 1);
969
- [self.driver end:touch];
970
- }
971
-
972
907
  - (void)testStationaryTapKeepsReactPress
973
908
  {
974
909
  [self assertFixtureIsReadyForDelivery];
@@ -82,12 +82,6 @@ export class CollapsiblePagerView extends React.PureComponent {
82
82
  scrollToPageTop = options => {
83
83
  if (this.nativeRef) CollapsiblePagerViewNativeCommands.scrollToTop(this.nativeRef, 0, options?.animated ?? true);
84
84
  };
85
- scrollHeaderBy = delta => {
86
- if (this.nativeRef && Number.isFinite(delta)) CollapsiblePagerViewNativeCommands.scrollHeaderBy(this.nativeRef, delta);
87
- };
88
- scrollHeaderToOffset = offset => {
89
- if (this.nativeRef && Number.isFinite(offset)) CollapsiblePagerViewNativeCommands.scrollHeaderToOffset(this.nativeRef, offset);
90
- };
91
85
  scrollToStickyTop = options => {
92
86
  if (this.nativeRef) CollapsiblePagerViewNativeCommands.scrollToTop(this.nativeRef, 1, options?.animated ?? true);
93
87
  };
@@ -102,7 +96,7 @@ export class CollapsiblePagerView extends React.PureComponent {
102
96
  nativeTabBarEnabled() {
103
97
  return (Platform.OS === "ios" || Platform.OS === "android") && !!this.props.nativeTabBar?.items.length;
104
98
  }
105
- dispatchNativeTabPageCommand(position, animated, expectedKey) {
99
+ dispatchNativeTabPageCommand(position, animated) {
106
100
  const commandId = ++this.nativeTabCommandId;
107
101
  this.nativeTabCommandQueuedDuringScroll = this.nativePagerScrollState !== "idle";
108
102
  this.latestNativeTabTarget = position;
@@ -110,7 +104,7 @@ export class CollapsiblePagerView extends React.PureComponent {
110
104
  transientRetainedPages: state.transientRetainedPages.includes(position) ? state.transientRetainedPages : [...state.transientRetainedPages, position]
111
105
  }), () => {
112
106
  requestAnimationFrame(() => {
113
- if (commandId !== this.nativeTabCommandId || !this.nativeRef || expectedKey !== undefined && (!this.nativeTabBarEnabled() || this.props.nativeTabBar?.items[position]?.key !== expectedKey)) {
107
+ if (commandId !== this.nativeTabCommandId || !this.nativeRef) {
114
108
  return;
115
109
  }
116
110
  this.dispatchedNativeTabTarget = position;
@@ -192,13 +186,10 @@ export class CollapsiblePagerView extends React.PureComponent {
192
186
  };
193
187
  onNativeTabPress = event => {
194
188
  const position = pageIndex(event.nativeEvent.position);
195
- if (!this.nativeTabBarEnabled() || position === null || this.props.nativeTabBar?.items[position]?.key !== event.nativeEvent.key) {
196
- return;
197
- }
198
- if (position >= 0 && position < this.pages().length && (position !== this.state.selectedPage || this.latestNativeTabTarget !== null)) {
189
+ if (position !== null && position >= 0 && position < this.pages().length && (position !== this.state.selectedPage || this.latestNativeTabTarget !== null)) {
199
190
  // Selection state lags an in-flight transition until native reports it.
200
191
  const currentPage = this.dispatchedNativeTabTarget ?? this.state.selectedPage;
201
- this.dispatchNativeTabPageCommand(position, this.props.nativeTabPressAnimationEnabled ?? Math.abs(position - currentPage) <= 1, event.nativeEvent.key);
192
+ this.dispatchNativeTabPageCommand(position, this.props.nativeTabPressAnimationEnabled ?? Math.abs(position - currentPage) <= 1);
202
193
  }
203
194
  this.props.onNativeTabPress?.(event);
204
195
  };
@@ -242,10 +233,6 @@ export class CollapsiblePagerView extends React.PureComponent {
242
233
  const deducedLayoutDirection = !layoutDirection || layoutDirection === "locale" ? I18nManager.isRTL ? "rtl" : "ltr" : layoutDirection;
243
234
  const nativeTabBarEnabled = (Platform.OS === "ios" || Platform.OS === "android") && !!nativeTabBar?.items.length;
244
235
  const nativeTabBarStyle = nativeTabBar?.style;
245
- const requestedContentPaddingVertical = nativeTabBarStyle?.contentPaddingVertical;
246
- const nativeTabBarContentPaddingVertical = typeof requestedContentPaddingVertical === "number" && Number.isFinite(requestedContentPaddingVertical) && requestedContentPaddingVertical >= 0 ? requestedContentPaddingVertical : 0;
247
- const requestedTrailingReservedWidth = nativeTabBarStyle?.trailingReservedWidth;
248
- const nativeTabBarTrailingReservedWidth = typeof requestedTrailingReservedWidth === "number" && Number.isFinite(requestedTrailingReservedWidth) && requestedTrailingReservedWidth >= 0 ? requestedTrailingReservedWidth : 0;
249
236
  const nativeSubHeaderEnabled = (Platform.OS === "ios" || Platform.OS === "android") && !!nativeSubHeader?.items.length;
250
237
  const nativeSubHeaderStyle = nativeSubHeader?.style;
251
238
  const nativeSubHeaderConfig = nativeSubHeaderEnabled ? JSON.stringify({
@@ -276,10 +263,7 @@ export class CollapsiblePagerView extends React.PureComponent {
276
263
  onPageScrollStateChanged: this.onPageScrollStateChanged,
277
264
  nativeTabBarItems: nativeTabBarEnabled ? JSON.stringify(nativeTabBar.items) : undefined,
278
265
  nativeTabBarHeight: nativeTabBarEnabled ? nativeTabBarStyle?.height ?? 44 : undefined,
279
- nativeTabBarVariant: nativeTabBarEnabled ? nativeTabBarStyle?.variant ?? "underline" : undefined,
280
- nativeTabBarTrailingReservedWidth: nativeTabBarEnabled ? nativeTabBarTrailingReservedWidth : 0,
281
266
  nativeTabBarContentPaddingHorizontal: nativeTabBarEnabled ? nativeTabBarStyle?.contentPaddingHorizontal ?? 20 : undefined,
282
- nativeTabBarContentPaddingVertical: nativeTabBarEnabled ? nativeTabBarContentPaddingVertical : undefined,
283
267
  nativeTabBarItemSpacing: nativeTabBarEnabled ? nativeTabBarStyle?.itemSpacing ?? 8 : undefined,
284
268
  nativeTabBarFontSize: nativeTabBarEnabled ? nativeTabBarStyle?.fontSize ?? 16 : undefined,
285
269
  nativeTabBarFontFamily: nativeTabBarEnabled ? nativeTabBarStyle?.fontFamily : undefined,
@@ -335,15 +335,6 @@ export class CollapsiblePagerView extends React.PureComponent {
335
335
  scrollToPageTop = options => {
336
336
  this.scrollCurrentPageToTop(0, options?.animated ?? true);
337
337
  };
338
- scrollHeaderBy = delta => {
339
- if (!Number.isFinite(delta)) return;
340
- const offset = Math.min(this.headerHeight, Math.max(0, this.sharedHeaderOffset + delta));
341
- this.scrollCurrentPageToTop(offset, false);
342
- };
343
- scrollHeaderToOffset = offset => {
344
- if (!Number.isFinite(offset)) return;
345
- this.scrollCurrentPageToTop(Math.min(this.headerHeight, Math.max(0, offset)), false);
346
- };
347
338
  scrollToStickyTop = options => {
348
339
  this.scrollCurrentPageToTop(this.headerHeight, options?.animated ?? true);
349
340
  };
@@ -395,13 +386,13 @@ export class CollapsiblePagerView extends React.PureComponent {
395
386
  this.pendingTopFrame = null;
396
387
  if (!element.isConnected || this.horizontalTouch || this.transitionTimer !== null || this.pageScrollElement(this.state.selectedPage) !== element || this.pages().map(pageKey)[this.state.selectedPage] !== key) return;
397
388
  this.pageOffsets.set(key, 0);
398
- this.sharedHeaderOffset = Math.min(this.headerHeight, Math.max(0, offset));
389
+ this.sharedHeaderOffset = offset;
399
390
  this.bodyAlignment = {
400
391
  element,
401
392
  key
402
393
  };
403
394
  scrollElementTo(element, {
404
- top: this.sharedHeaderOffset,
395
+ top: offset,
405
396
  behavior: animated ? "smooth" : "instant"
406
397
  });
407
398
  this.syncFallbackHeader();
@@ -67,10 +67,7 @@ export interface NativeProps extends ViewProps {
67
67
  retainedPages?: string;
68
68
  nativeTabBarItems?: string;
69
69
  nativeTabBarHeight?: Double;
70
- nativeTabBarVariant?: string;
71
- nativeTabBarTrailingReservedWidth?: WithDefault<Double, 0>;
72
70
  nativeTabBarContentPaddingHorizontal?: Double;
73
- nativeTabBarContentPaddingVertical?: Double;
74
71
  nativeTabBarItemSpacing?: Double;
75
72
  nativeTabBarFontSize?: Double;
76
73
  nativeTabBarFontFamily?: string;
@@ -94,14 +91,6 @@ export interface NativeProps extends ViewProps {
94
91
  type CollapsiblePagerViewNativeType = HostComponent<NativeProps>;
95
92
 
96
93
  export interface NativeCommands {
97
- scrollHeaderToOffset: (
98
- viewRef: React.ElementRef<CollapsiblePagerViewNativeType>,
99
- offset: Double
100
- ) => void;
101
- scrollHeaderBy: (
102
- viewRef: React.ElementRef<CollapsiblePagerViewNativeType>,
103
- delta: Double
104
- ) => void;
105
94
  scrollToTop: (
106
95
  viewRef: React.ElementRef<CollapsiblePagerViewNativeType>,
107
96
  target: Int32,
@@ -123,8 +112,6 @@ export interface NativeCommands {
123
112
 
124
113
  export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
125
114
  supportedCommands: [
126
- "scrollHeaderToOffset",
127
- "scrollHeaderBy",
128
115
  "scrollToTop",
129
116
  "setPage",
130
117
  "setPageWithoutAnimation",
@@ -16,11 +16,8 @@ export type CollapsiblePagerNativeTabBarItem = Readonly<{
16
16
  testID?: string;
17
17
  }>;
18
18
  export type CollapsiblePagerNativeTabBarStyle = Readonly<{
19
- variant?: "underline" | "segmented";
20
19
  height?: number;
21
- trailingReservedWidth?: number;
22
20
  contentPaddingHorizontal?: number;
23
- contentPaddingVertical?: number;
24
21
  itemSpacing?: number;
25
22
  fontSize?: number;
26
23
  fontFamily?: string;
@@ -59,7 +56,7 @@ export type CollapsiblePagerNativeSubHeaderConfig = Readonly<{
59
56
  }>;
60
57
  export type CollapsiblePagerViewOnNativeTabPressEvent = ReactNative.NativeSyntheticEvent<OnNativeTabPressEventData>;
61
58
  export type CollapsiblePagerViewOnNativeSubHeaderPressEvent = ReactNative.NativeSyntheticEvent<OnNativeTabPressEventData>;
62
- export interface CollapsiblePagerViewProps extends Omit<NativeProps, "children" | "headerHeight" | "stickyHeaderHeight" | "topScrollEdgeEffect" | "topOverlayHeight" | "externalTopOverlayTag" | "pageKeys" | "retainedPages" | "nativeTabBarItems" | "nativeTabBarHeight" | "nativeTabBarVariant" | "nativeTabBarTrailingReservedWidth" | "nativeTabBarContentPaddingHorizontal" | "nativeTabBarContentPaddingVertical" | "nativeTabBarItemSpacing" | "nativeTabBarFontSize" | "nativeTabBarFontFamily" | "nativeTabBarBackgroundColor" | "nativeTabBarActiveTextColor" | "nativeTabBarInactiveTextColor" | "nativeTabBarIndicatorColor" | "nativeTabBarIndicatorHeight" | "nativeTabBarIndicatorBottom" | "nativeSubHeaderConfig" | "nativeSubHeaderSelectedBackgroundColor" | "onNativeTabPress" | "onNativeSubHeaderPress" | "layoutDirection"> {
59
+ export interface CollapsiblePagerViewProps extends Omit<NativeProps, "children" | "headerHeight" | "stickyHeaderHeight" | "topScrollEdgeEffect" | "topOverlayHeight" | "externalTopOverlayTag" | "pageKeys" | "retainedPages" | "nativeTabBarItems" | "nativeTabBarHeight" | "nativeTabBarContentPaddingHorizontal" | "nativeTabBarItemSpacing" | "nativeTabBarFontSize" | "nativeTabBarFontFamily" | "nativeTabBarBackgroundColor" | "nativeTabBarActiveTextColor" | "nativeTabBarInactiveTextColor" | "nativeTabBarIndicatorColor" | "nativeTabBarIndicatorHeight" | "nativeTabBarIndicatorBottom" | "nativeSubHeaderConfig" | "nativeSubHeaderSelectedBackgroundColor" | "onNativeTabPress" | "onNativeSubHeaderPress" | "layoutDirection"> {
63
60
  /** Collapsible content rendered above the sticky bar. */
64
61
  header: React.ReactNode;
65
62
  /** Bar which remains pinned after the header has collapsed. */
@@ -131,8 +128,6 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
131
128
  scrollToPageTop: (options?: Readonly<{
132
129
  animated?: boolean;
133
130
  }>) => void;
134
- scrollHeaderBy: (delta: number) => void;
135
- scrollHeaderToOffset: (offset: number) => void;
136
131
  scrollToStickyTop: (options?: Readonly<{
137
132
  animated?: boolean;
138
133
  }>) => void;
@@ -132,8 +132,6 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
132
132
  scrollToPageTop: (options?: Readonly<{
133
133
  animated?: boolean;
134
134
  }>) => void;
135
- scrollHeaderBy: (delta: number) => void;
136
- scrollHeaderToOffset: (offset: number) => void;
137
135
  scrollToStickyTop: (options?: Readonly<{
138
136
  animated?: boolean;
139
137
  }>) => void;
@@ -50,10 +50,7 @@ export interface NativeProps extends ViewProps {
50
50
  retainedPages?: string;
51
51
  nativeTabBarItems?: string;
52
52
  nativeTabBarHeight?: Double;
53
- nativeTabBarVariant?: string;
54
- nativeTabBarTrailingReservedWidth?: WithDefault<Double, 0>;
55
53
  nativeTabBarContentPaddingHorizontal?: Double;
56
- nativeTabBarContentPaddingVertical?: Double;
57
54
  nativeTabBarItemSpacing?: Double;
58
55
  nativeTabBarFontSize?: Double;
59
56
  nativeTabBarFontFamily?: string;
@@ -75,8 +72,6 @@ export interface NativeProps extends ViewProps {
75
72
  }
76
73
  type CollapsiblePagerViewNativeType = HostComponent<NativeProps>;
77
74
  export interface NativeCommands {
78
- scrollHeaderToOffset: (viewRef: React.ElementRef<CollapsiblePagerViewNativeType>, offset: Double) => void;
79
- scrollHeaderBy: (viewRef: React.ElementRef<CollapsiblePagerViewNativeType>, delta: Double) => void;
80
75
  scrollToTop: (viewRef: React.ElementRef<CollapsiblePagerViewNativeType>, target: Int32, animated: boolean) => void;
81
76
  setPage: (viewRef: React.ElementRef<CollapsiblePagerViewNativeType>, selectedPage: Int32) => void;
82
77
  setPageWithoutAnimation: (viewRef: React.ElementRef<CollapsiblePagerViewNativeType>, selectedPage: Int32) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-pager-view",
3
- "version": "6.7.0-alpha.359",
3
+ "version": "6.7.0-alpha.363",
4
4
  "description": "React Native wrapper for Android and iOS ViewPager",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -73,7 +73,7 @@
73
73
  "typescript": "^5.9.2"
74
74
  },
75
75
  "peerDependencies": {
76
- "@onekeyfe/react-native-native-logger": "6.7.0-alpha.359",
76
+ "@onekeyfe/react-native-native-logger": "6.7.0-alpha.363",
77
77
  "react": "*",
78
78
  "react-native": "*"
79
79
  },
@@ -32,11 +32,8 @@ export type CollapsiblePagerNativeTabBarItem = Readonly<{
32
32
  }>;
33
33
 
34
34
  export type CollapsiblePagerNativeTabBarStyle = Readonly<{
35
- variant?: "underline" | "segmented";
36
35
  height?: number;
37
- trailingReservedWidth?: number;
38
36
  contentPaddingHorizontal?: number;
39
- contentPaddingVertical?: number;
40
37
  itemSpacing?: number;
41
38
  fontSize?: number;
42
39
  fontFamily?: string;
@@ -97,10 +94,7 @@ export interface CollapsiblePagerViewProps
97
94
  | "retainedPages"
98
95
  | "nativeTabBarItems"
99
96
  | "nativeTabBarHeight"
100
- | "nativeTabBarVariant"
101
- | "nativeTabBarTrailingReservedWidth"
102
97
  | "nativeTabBarContentPaddingHorizontal"
103
- | "nativeTabBarContentPaddingVertical"
104
98
  | "nativeTabBarItemSpacing"
105
99
  | "nativeTabBarFontSize"
106
100
  | "nativeTabBarFontFamily"
@@ -296,22 +290,6 @@ export class CollapsiblePagerView extends React.PureComponent<
296
290
  );
297
291
  };
298
292
 
299
- public scrollHeaderBy = (delta: number) => {
300
- if (this.nativeRef && Number.isFinite(delta))
301
- CollapsiblePagerViewNativeCommands.scrollHeaderBy(
302
- this.nativeRef,
303
- delta
304
- );
305
- };
306
-
307
- public scrollHeaderToOffset = (offset: number) => {
308
- if (this.nativeRef && Number.isFinite(offset))
309
- CollapsiblePagerViewNativeCommands.scrollHeaderToOffset(
310
- this.nativeRef,
311
- offset
312
- );
313
- };
314
-
315
293
  public scrollToStickyTop = (options?: Readonly<{ animated?: boolean }>) => {
316
294
  if (this.nativeRef)
317
295
  CollapsiblePagerViewNativeCommands.scrollToTop(
@@ -341,11 +319,7 @@ export class CollapsiblePagerView extends React.PureComponent<
341
319
  );
342
320
  }
343
321
 
344
- private dispatchNativeTabPageCommand(
345
- position: number,
346
- animated: boolean,
347
- expectedKey?: string
348
- ) {
322
+ private dispatchNativeTabPageCommand(position: number, animated: boolean) {
349
323
  const commandId = ++this.nativeTabCommandId;
350
324
  this.nativeTabCommandQueuedDuringScroll =
351
325
  this.nativePagerScrollState !== "idle";
@@ -358,13 +332,7 @@ export class CollapsiblePagerView extends React.PureComponent<
358
332
  }),
359
333
  () => {
360
334
  requestAnimationFrame(() => {
361
- if (
362
- commandId !== this.nativeTabCommandId ||
363
- !this.nativeRef ||
364
- (expectedKey !== undefined &&
365
- (!this.nativeTabBarEnabled() ||
366
- this.props.nativeTabBar?.items[position]?.key !== expectedKey))
367
- ) {
335
+ if (commandId !== this.nativeTabCommandId || !this.nativeRef) {
368
336
  return;
369
337
  }
370
338
  this.dispatchedNativeTabTarget = position;
@@ -490,13 +458,7 @@ export class CollapsiblePagerView extends React.PureComponent<
490
458
  ) => {
491
459
  const position = pageIndex(event.nativeEvent.position);
492
460
  if (
493
- !this.nativeTabBarEnabled() ||
494
- position === null ||
495
- this.props.nativeTabBar?.items[position]?.key !== event.nativeEvent.key
496
- ) {
497
- return;
498
- }
499
- if (
461
+ position !== null &&
500
462
  position >= 0 &&
501
463
  position < this.pages().length &&
502
464
  (position !== this.state.selectedPage ||
@@ -508,8 +470,7 @@ export class CollapsiblePagerView extends React.PureComponent<
508
470
  this.dispatchNativeTabPageCommand(
509
471
  position,
510
472
  this.props.nativeTabPressAnimationEnabled ??
511
- Math.abs(position - currentPage) <= 1,
512
- event.nativeEvent.key
473
+ Math.abs(position - currentPage) <= 1
513
474
  );
514
475
  }
515
476
  this.props.onNativeTabPress?.(event);
@@ -572,22 +533,6 @@ export class CollapsiblePagerView extends React.PureComponent<
572
533
  (Platform.OS === "ios" || Platform.OS === "android") &&
573
534
  !!nativeTabBar?.items.length;
574
535
  const nativeTabBarStyle = nativeTabBar?.style;
575
- const requestedContentPaddingVertical =
576
- nativeTabBarStyle?.contentPaddingVertical;
577
- const nativeTabBarContentPaddingVertical =
578
- typeof requestedContentPaddingVertical === "number" &&
579
- Number.isFinite(requestedContentPaddingVertical) &&
580
- requestedContentPaddingVertical >= 0
581
- ? requestedContentPaddingVertical
582
- : 0;
583
- const requestedTrailingReservedWidth =
584
- nativeTabBarStyle?.trailingReservedWidth;
585
- const nativeTabBarTrailingReservedWidth =
586
- typeof requestedTrailingReservedWidth === "number" &&
587
- Number.isFinite(requestedTrailingReservedWidth) &&
588
- requestedTrailingReservedWidth >= 0
589
- ? requestedTrailingReservedWidth
590
- : 0;
591
536
  const nativeSubHeaderEnabled =
592
537
  (Platform.OS === "ios" || Platform.OS === "android") &&
593
538
  !!nativeSubHeader?.items.length;
@@ -641,20 +586,11 @@ export class CollapsiblePagerView extends React.PureComponent<
641
586
  nativeTabBarHeight={
642
587
  nativeTabBarEnabled ? nativeTabBarStyle?.height ?? 44 : undefined
643
588
  }
644
- nativeTabBarVariant={
645
- nativeTabBarEnabled ? nativeTabBarStyle?.variant ?? "underline" : undefined
646
- }
647
- nativeTabBarTrailingReservedWidth={
648
- nativeTabBarEnabled ? nativeTabBarTrailingReservedWidth : 0
649
- }
650
589
  nativeTabBarContentPaddingHorizontal={
651
590
  nativeTabBarEnabled
652
591
  ? nativeTabBarStyle?.contentPaddingHorizontal ?? 20
653
592
  : undefined
654
593
  }
655
- nativeTabBarContentPaddingVertical={
656
- nativeTabBarEnabled ? nativeTabBarContentPaddingVertical : undefined
657
- }
658
594
  nativeTabBarItemSpacing={
659
595
  nativeTabBarEnabled ? nativeTabBarStyle?.itemSpacing ?? 8 : undefined
660
596
  }