@onekeyfe/react-native-pager-view 6.7.0-alpha.436 → 6.7.0-alpha.449
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 +16 -0
- package/android/build.gradle +1 -0
- package/android/src/androidTest/java/com/reactnativepagerview/CollapsiblePagerTabReservationTest.kt +135 -0
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerHost.kt +88 -12
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerNativeHeaders.kt +442 -15
- package/android/src/main/java/com/reactnativepagerview/CollapsiblePagerViewManager.kt +11 -1
- package/android/src/main/java/com/reactnativepagerview/event/NativeHeaderPressEvent.kt +8 -0
- package/docs/SPEC.md +298 -3
- package/ios/RNCCollapsiblePagerViewComponentView.mm +834 -20
- package/ios/tests/RNCCollapsiblePagerFirstFrameTests.mm +61 -0
- package/ios/tests/RNCCollapsiblePagerHitTestTests.mm +22 -0
- package/lib/module/CollapsiblePagerView.js +37 -5
- package/lib/module/CollapsiblePagerView.web.js +519 -6
- package/lib/module/CollapsiblePagerViewNativeComponent.ts +6 -0
- package/lib/module/NativeScrollerNativeComponent.ts +0 -1
- package/lib/typescript/src/CollapsiblePagerView.d.ts +31 -2
- package/lib/typescript/src/CollapsiblePagerView.web.d.ts +44 -1
- package/lib/typescript/src/CollapsiblePagerViewNativeComponent.d.ts +11 -0
- package/lib/typescript/src/NativeScroller.d.ts +2 -2
- package/package.json +3 -2
- package/src/CollapsiblePagerView.tsx +68 -5
- package/src/CollapsiblePagerView.web.tsx +464 -5
- package/src/CollapsiblePagerViewNativeComponent.ts +6 -0
- package/src/NativeScroller.tsx +2 -3
- package/src/NativeScrollerNativeComponent.ts +0 -1
|
@@ -16,7 +16,7 @@ export type CollapsiblePagerNativeTabBarItem = Readonly<{
|
|
|
16
16
|
testID?: string;
|
|
17
17
|
}>;
|
|
18
18
|
export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
19
|
-
variant?: "underline" | "segmented";
|
|
19
|
+
variant?: "underline" | "segmented" | "text";
|
|
20
20
|
height?: number;
|
|
21
21
|
trailingReservedWidth?: number;
|
|
22
22
|
contentPaddingHorizontal?: number;
|
|
@@ -24,6 +24,7 @@ export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
|
24
24
|
itemSpacing?: number;
|
|
25
25
|
fontSize?: number;
|
|
26
26
|
fontFamily?: string;
|
|
27
|
+
activeFontFamily?: string;
|
|
27
28
|
backgroundColor?: ReactNative.ColorValue;
|
|
28
29
|
activeTextColor?: ReactNative.ColorValue;
|
|
29
30
|
inactiveTextColor?: ReactNative.ColorValue;
|
|
@@ -31,7 +32,33 @@ export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
|
31
32
|
indicatorHeight?: number;
|
|
32
33
|
indicatorBottom?: number;
|
|
33
34
|
}>;
|
|
35
|
+
export type CollapsiblePagerToolbarItem = Readonly<{
|
|
36
|
+
iconName: string;
|
|
37
|
+
selected?: boolean;
|
|
38
|
+
accessibilityLabel?: string;
|
|
39
|
+
testID?: string;
|
|
40
|
+
iconColor?: string;
|
|
41
|
+
selectedBackgroundColor?: string;
|
|
42
|
+
hoverBackgroundColor?: string;
|
|
43
|
+
pressedBackgroundColor?: string;
|
|
44
|
+
size?: number;
|
|
45
|
+
iconSize?: number;
|
|
46
|
+
contentWidth?: number;
|
|
47
|
+
trailingInset?: number;
|
|
48
|
+
}>;
|
|
49
|
+
export type CollapsiblePagerToolbarPress = Readonly<{
|
|
50
|
+
key: string;
|
|
51
|
+
anchorRect: Readonly<{
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}>;
|
|
57
|
+
}>;
|
|
34
58
|
export type CollapsiblePagerNativeTabBarConfig = Readonly<{
|
|
59
|
+
controlled?: boolean;
|
|
60
|
+
selectedKey?: string;
|
|
61
|
+
toolbar?: Readonly<Record<string, CollapsiblePagerToolbarItem>>;
|
|
35
62
|
items: readonly CollapsiblePagerNativeTabBarItem[];
|
|
36
63
|
style?: CollapsiblePagerNativeTabBarStyle;
|
|
37
64
|
}>;
|
|
@@ -59,7 +86,7 @@ export type CollapsiblePagerNativeSubHeaderConfig = Readonly<{
|
|
|
59
86
|
}>;
|
|
60
87
|
export type CollapsiblePagerViewOnNativeTabPressEvent = ReactNative.NativeSyntheticEvent<OnNativeTabPressEventData>;
|
|
61
88
|
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"> {
|
|
89
|
+
export interface CollapsiblePagerViewProps extends Omit<NativeProps, "children" | "headerHeight" | "stickyHeaderHeight" | "topScrollEdgeEffect" | "topOverlayHeight" | "externalTopOverlayTag" | "pageKeys" | "retainedPages" | "nativeTabBarConfig" | "onNativeToolbarPress" | "nativeTabBarItems" | "nativeTabBarHeight" | "nativeTabBarVariant" | "nativeTabBarTrailingReservedWidth" | "nativeTabBarContentPaddingHorizontal" | "nativeTabBarContentPaddingVertical" | "nativeTabBarItemSpacing" | "nativeTabBarFontSize" | "nativeTabBarFontFamily" | "nativeTabBarBackgroundColor" | "nativeTabBarActiveTextColor" | "nativeTabBarInactiveTextColor" | "nativeTabBarIndicatorColor" | "nativeTabBarIndicatorHeight" | "nativeTabBarIndicatorBottom" | "nativeSubHeaderConfig" | "nativeSubHeaderSelectedBackgroundColor" | "onNativeTabPress" | "onNativeSubHeaderPress" | "layoutDirection"> {
|
|
63
90
|
/** Collapsible content rendered above the sticky bar. */
|
|
64
91
|
header: React.ReactNode;
|
|
65
92
|
/** Bar which remains pinned after the header has collapsed. */
|
|
@@ -92,6 +119,7 @@ export interface CollapsiblePagerViewProps extends Omit<NativeProps, "children"
|
|
|
92
119
|
layoutDirection?: "ltr" | "rtl" | "locale";
|
|
93
120
|
/** Optional native tab bar for iOS and Android. */
|
|
94
121
|
nativeTabBar?: CollapsiblePagerNativeTabBarConfig;
|
|
122
|
+
onNativeToolbarPress?: (event: ReactNative.NativeSyntheticEvent<CollapsiblePagerToolbarPress>) => void;
|
|
95
123
|
onNativeTabPress?: (event: CollapsiblePagerViewOnNativeTabPressEvent) => void;
|
|
96
124
|
/**
|
|
97
125
|
* Defaults to animating adjacent native tab presses and jumping directly to
|
|
@@ -146,6 +174,7 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
146
174
|
private onPageSelected;
|
|
147
175
|
private onPageScrollStateChanged;
|
|
148
176
|
private onNativeTabPress;
|
|
177
|
+
private onNativeToolbarPress;
|
|
149
178
|
private onNativeSubHeaderPress;
|
|
150
179
|
render(): React.JSX.Element;
|
|
151
180
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ScrollEdgeEffect } from "./ScrollEdgeEffect";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import type { CollapsiblePagerNativeTabBarConfig, CollapsiblePagerToolbarPress, CollapsiblePagerViewOnNativeTabPressEvent } from "./CollapsiblePagerView";
|
|
4
|
+
export type { CollapsiblePagerNativeTabBarConfig, CollapsiblePagerNativeTabBarItem, CollapsiblePagerNativeTabBarStyle, CollapsiblePagerToolbarItem, CollapsiblePagerToolbarPress } from "./CollapsiblePagerView";
|
|
3
5
|
import type * as ReactNative from "react-native";
|
|
4
6
|
export type OnPageScrollEventData = Readonly<{
|
|
5
7
|
position: number;
|
|
@@ -36,6 +38,10 @@ export type CollapsiblePagerMountState = Readonly<{
|
|
|
36
38
|
pageKeys: readonly string[];
|
|
37
39
|
}>;
|
|
38
40
|
export interface CollapsiblePagerViewProps extends Omit<WebCollapsiblePagerNativeProps, "children" | "headerHeight" | "stickyHeaderHeight" | "pageKeys" | "retainedPages" | "layoutDirection"> {
|
|
41
|
+
nativeTabBar?: CollapsiblePagerNativeTabBarConfig;
|
|
42
|
+
nativeTabPressAnimationEnabled?: boolean;
|
|
43
|
+
onNativeTabPress?: (event: CollapsiblePagerViewOnNativeTabPressEvent) => void;
|
|
44
|
+
onNativeToolbarPress?: (event: ReactNative.NativeSyntheticEvent<CollapsiblePagerToolbarPress>) => void;
|
|
39
45
|
header: React.ReactNode;
|
|
40
46
|
stickyHeader: React.ReactNode;
|
|
41
47
|
headerHeight?: number;
|
|
@@ -66,6 +72,10 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
66
72
|
state: State;
|
|
67
73
|
private root;
|
|
68
74
|
private track;
|
|
75
|
+
private tabProgress;
|
|
76
|
+
private tabProgressFrame;
|
|
77
|
+
private tabProgressGeneration;
|
|
78
|
+
private tabButtons;
|
|
69
79
|
private headerSlot;
|
|
70
80
|
private stickySlot;
|
|
71
81
|
private cssTimelineSupported;
|
|
@@ -98,6 +108,7 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
98
108
|
private configureFrame;
|
|
99
109
|
private pendingTopFrame;
|
|
100
110
|
private transitionTimer;
|
|
111
|
+
private transitionGeneration;
|
|
101
112
|
private pageScrollState;
|
|
102
113
|
private configuredScrollElement;
|
|
103
114
|
private readonly timelineName;
|
|
@@ -152,6 +163,13 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
152
163
|
private beginPageTransition;
|
|
153
164
|
private onTrackTransitionEnd;
|
|
154
165
|
private setTrack;
|
|
166
|
+
private cancelTabProgressFrame;
|
|
167
|
+
private readTabProgress;
|
|
168
|
+
private startTabProgressFrames;
|
|
169
|
+
private tabColorWeights;
|
|
170
|
+
private tabFontOwnerKey;
|
|
171
|
+
private tabColor;
|
|
172
|
+
private syncTabColors;
|
|
155
173
|
private pageScrollElement;
|
|
156
174
|
private setRoot;
|
|
157
175
|
private overlayTarget;
|
|
@@ -180,10 +198,35 @@ export declare class CollapsiblePagerView extends React.PureComponent<Collapsibl
|
|
|
180
198
|
private onTouchMove;
|
|
181
199
|
private onTouchEnd;
|
|
182
200
|
private onTouchCancel;
|
|
201
|
+
private toolbarSlot;
|
|
202
|
+
private toolbarButton;
|
|
203
|
+
private toolbarOwnerKey;
|
|
204
|
+
private toolbarOwnerEntry;
|
|
205
|
+
private toolbarIconIdentity;
|
|
206
|
+
private toolbarLoadedIcon;
|
|
207
|
+
private toolbarPendingIdentity;
|
|
208
|
+
private toolbarReadyIcon;
|
|
209
|
+
private toolbarFailedIdentity;
|
|
210
|
+
private toolbarAnimation;
|
|
211
|
+
private toolbarPresence;
|
|
212
|
+
private toolbarPresenceInterrupted;
|
|
213
|
+
private toolbarImage;
|
|
214
|
+
private toolbarGeneration;
|
|
215
|
+
private toolbarTouchKey;
|
|
216
|
+
private ownsSettledToolbar;
|
|
217
|
+
private toolbarCanCommit;
|
|
218
|
+
private cancelToolbarPending;
|
|
219
|
+
private setToolbarInteractive;
|
|
220
|
+
private suspendToolbar;
|
|
221
|
+
private setToolbarSlot;
|
|
222
|
+
private animateToolbar;
|
|
223
|
+
private hideToolbar;
|
|
224
|
+
private commitToolbar;
|
|
225
|
+
private syncToolbar;
|
|
226
|
+
private renderNativeTabBar;
|
|
183
227
|
render(): React.JSX.Element;
|
|
184
228
|
}
|
|
185
229
|
export type CollapsiblePagerViewOnPageScrollEvent = ReactNative.NativeSyntheticEvent<OnPageScrollEventData>;
|
|
186
230
|
export type CollapsiblePagerViewOnPageSelectedEvent = ReactNative.NativeSyntheticEvent<OnPageSelectedEventData>;
|
|
187
231
|
export type CollapsiblePagerViewOnPageScrollStateChangedEvent = ReactNative.NativeSyntheticEvent<OnPageScrollStateChangedEventData>;
|
|
188
|
-
export {};
|
|
189
232
|
//# sourceMappingURL=CollapsiblePagerView.web.d.ts.map
|
|
@@ -25,6 +25,15 @@ export type OnNativeTabPressEventData = Readonly<{
|
|
|
25
25
|
position: CodegenTypes.Int32;
|
|
26
26
|
key: string;
|
|
27
27
|
}>;
|
|
28
|
+
export type OnNativeToolbarPressEventData = Readonly<{
|
|
29
|
+
key: string;
|
|
30
|
+
anchorRect: Readonly<{
|
|
31
|
+
x: CodegenTypes.Double;
|
|
32
|
+
y: CodegenTypes.Double;
|
|
33
|
+
width: CodegenTypes.Double;
|
|
34
|
+
height: CodegenTypes.Double;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
28
37
|
export type OnScrollEdgeCapabilityEventData = Readonly<{
|
|
29
38
|
available: boolean;
|
|
30
39
|
}>;
|
|
@@ -47,6 +56,7 @@ export interface NativeProps extends ViewProps {
|
|
|
47
56
|
externalTopOverlayTag?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
48
57
|
pageKeys?: string;
|
|
49
58
|
retainedPages?: string;
|
|
59
|
+
nativeTabBarConfig?: string;
|
|
50
60
|
nativeTabBarItems?: string;
|
|
51
61
|
nativeTabBarHeight?: CodegenTypes.Double;
|
|
52
62
|
nativeTabBarVariant?: string;
|
|
@@ -68,6 +78,7 @@ export interface NativeProps extends ViewProps {
|
|
|
68
78
|
onPageSelected?: CodegenTypes.DirectEventHandler<OnPageSelectedEventData>;
|
|
69
79
|
onPageScrollStateChanged?: CodegenTypes.DirectEventHandler<OnPageScrollStateChangedEventData>;
|
|
70
80
|
onCollapsibleStateChanged?: CodegenTypes.DirectEventHandler<OnCollapsibleStateChangedEventData>;
|
|
81
|
+
onNativeToolbarPress?: CodegenTypes.DirectEventHandler<OnNativeToolbarPressEventData>;
|
|
71
82
|
onNativeTabPress?: CodegenTypes.DirectEventHandler<OnNativeTabPressEventData>;
|
|
72
83
|
onNativeSubHeaderPress?: CodegenTypes.DirectEventHandler<OnNativeTabPressEventData>;
|
|
73
84
|
onScrollEdgeCapability?: CodegenTypes.DirectEventHandler<OnScrollEdgeCapabilityEventData>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { type
|
|
2
|
+
import { type RefreshControlProps, type ScrollView, type ScrollViewProps, type ViewProps } from "react-native";
|
|
3
3
|
import NativeScrollerHost from "./NativeScrollerNativeComponent";
|
|
4
4
|
import type { ScrollEdgeEffect } from "./ScrollEdgeEffect";
|
|
5
5
|
export declare const NATIVE_SCROLLER_NATIVE_ID_PREFIX = "rnc-collapsible-pager-native-scroller";
|
|
@@ -18,7 +18,7 @@ export interface NativeScrollerProps extends ViewProps, Pick<ScrollViewProps, "c
|
|
|
18
18
|
keyboardShouldPersistTaps?: ScrollViewProps["keyboardShouldPersistTaps"] | boolean;
|
|
19
19
|
}
|
|
20
20
|
type HostRef = React.ElementRef<typeof NativeScrollerHost>;
|
|
21
|
-
export interface NativeScrollerRef extends Pick<
|
|
21
|
+
export interface NativeScrollerRef extends Pick<HostRef, "measure" | "measureInWindow" | "measureLayout" | "setNativeProps" | "focus" | "blur">, Pick<React.ElementRef<typeof ScrollView>, "scrollTo" | "scrollToEnd" | "flashScrollIndicators"> {
|
|
22
22
|
getNativeScrollRef(): HostRef | null;
|
|
23
23
|
getScrollableNode(): number | null;
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-pager-view",
|
|
3
|
-
"version": "6.7.0-alpha.
|
|
3
|
+
"version": "6.7.0-alpha.449",
|
|
4
4
|
"description": "React Native wrapper for Android and iOS ViewPager",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
"typescript": "^5.9.2"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@onekeyfe/react-native-
|
|
77
|
+
"@onekeyfe/react-native-image": "*",
|
|
78
|
+
"@onekeyfe/react-native-native-logger": "*",
|
|
78
79
|
"react": "*",
|
|
79
80
|
"react-native": "*"
|
|
80
81
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ScrollEdgeEffect } from "./ScrollEdgeEffect";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { I18nManager, Platform, StyleSheet, View } from "react-native";
|
|
3
|
+
import { I18nManager, Platform, StyleSheet, View, processColor } from "react-native";
|
|
4
4
|
import type * as ReactNative from "react-native";
|
|
5
5
|
|
|
6
6
|
import CollapsiblePagerViewNativeComponent, {
|
|
@@ -32,7 +32,7 @@ export type CollapsiblePagerNativeTabBarItem = Readonly<{
|
|
|
32
32
|
}>;
|
|
33
33
|
|
|
34
34
|
export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
35
|
-
variant?: "underline" | "segmented";
|
|
35
|
+
variant?: "underline" | "segmented" | "text";
|
|
36
36
|
height?: number;
|
|
37
37
|
trailingReservedWidth?: number;
|
|
38
38
|
contentPaddingHorizontal?: number;
|
|
@@ -40,6 +40,7 @@ export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
|
40
40
|
itemSpacing?: number;
|
|
41
41
|
fontSize?: number;
|
|
42
42
|
fontFamily?: string;
|
|
43
|
+
activeFontFamily?: string;
|
|
43
44
|
backgroundColor?: ReactNative.ColorValue;
|
|
44
45
|
activeTextColor?: ReactNative.ColorValue;
|
|
45
46
|
inactiveTextColor?: ReactNative.ColorValue;
|
|
@@ -48,7 +49,30 @@ export type CollapsiblePagerNativeTabBarStyle = Readonly<{
|
|
|
48
49
|
indicatorBottom?: number;
|
|
49
50
|
}>;
|
|
50
51
|
|
|
52
|
+
export type CollapsiblePagerToolbarItem = Readonly<{
|
|
53
|
+
iconName: string;
|
|
54
|
+
selected?: boolean;
|
|
55
|
+
accessibilityLabel?: string;
|
|
56
|
+
testID?: string;
|
|
57
|
+
iconColor?: string;
|
|
58
|
+
selectedBackgroundColor?: string;
|
|
59
|
+
hoverBackgroundColor?: string;
|
|
60
|
+
pressedBackgroundColor?: string;
|
|
61
|
+
size?: number;
|
|
62
|
+
iconSize?: number;
|
|
63
|
+
contentWidth?: number;
|
|
64
|
+
trailingInset?: number;
|
|
65
|
+
}>;
|
|
66
|
+
|
|
67
|
+
export type CollapsiblePagerToolbarPress = Readonly<{
|
|
68
|
+
key: string;
|
|
69
|
+
anchorRect: Readonly<{ x: number; y: number; width: number; height: number }>;
|
|
70
|
+
}>;
|
|
71
|
+
|
|
51
72
|
export type CollapsiblePagerNativeTabBarConfig = Readonly<{
|
|
73
|
+
controlled?: boolean;
|
|
74
|
+
selectedKey?: string;
|
|
75
|
+
toolbar?: Readonly<Record<string, CollapsiblePagerToolbarItem>>;
|
|
52
76
|
items: readonly CollapsiblePagerNativeTabBarItem[];
|
|
53
77
|
style?: CollapsiblePagerNativeTabBarStyle;
|
|
54
78
|
}>;
|
|
@@ -95,6 +119,8 @@ export interface CollapsiblePagerViewProps
|
|
|
95
119
|
| "externalTopOverlayTag"
|
|
96
120
|
| "pageKeys"
|
|
97
121
|
| "retainedPages"
|
|
122
|
+
| "nativeTabBarConfig"
|
|
123
|
+
| "onNativeToolbarPress"
|
|
98
124
|
| "nativeTabBarItems"
|
|
99
125
|
| "nativeTabBarHeight"
|
|
100
126
|
| "nativeTabBarVariant"
|
|
@@ -148,6 +174,7 @@ export interface CollapsiblePagerViewProps
|
|
|
148
174
|
layoutDirection?: "ltr" | "rtl" | "locale";
|
|
149
175
|
/** Optional native tab bar for iOS and Android. */
|
|
150
176
|
nativeTabBar?: CollapsiblePagerNativeTabBarConfig;
|
|
177
|
+
onNativeToolbarPress?: (event: ReactNative.NativeSyntheticEvent<CollapsiblePagerToolbarPress>) => void;
|
|
151
178
|
onNativeTabPress?: (event: CollapsiblePagerViewOnNativeTabPressEvent) => void;
|
|
152
179
|
/**
|
|
153
180
|
* Defaults to animating adjacent native tab presses and jumping directly to
|
|
@@ -169,6 +196,20 @@ type State = {
|
|
|
169
196
|
topOverlayHeight: number | null;
|
|
170
197
|
};
|
|
171
198
|
|
|
199
|
+
const nativeToolbar = (toolbar: CollapsiblePagerNativeTabBarConfig["toolbar"]) => {
|
|
200
|
+
if (!toolbar) return undefined;
|
|
201
|
+
return Object.fromEntries(Object.entries(toolbar).map(([key, item]) => {
|
|
202
|
+
const color = processColor(item.iconColor ?? "#000000");
|
|
203
|
+
const argb = typeof color === "number" ? color >>> 0 : 0xff000000;
|
|
204
|
+
return [key, { ...item,
|
|
205
|
+
iconColor: `rgba(${(argb >>> 16) & 255},${(argb >>> 8) & 255},${argb & 255},${Math.round(((argb >>> 24) / 255) * 1000000) / 1000000})`,
|
|
206
|
+
selectedBackgroundColor: processColor(item.selectedBackgroundColor ?? "transparent"),
|
|
207
|
+
hoverBackgroundColor: processColor(item.hoverBackgroundColor ?? "transparent"),
|
|
208
|
+
pressedBackgroundColor: processColor(item.pressedBackgroundColor ?? "transparent"),
|
|
209
|
+
}];
|
|
210
|
+
}));
|
|
211
|
+
};
|
|
212
|
+
|
|
172
213
|
const pageIndex = (value: number) => {
|
|
173
214
|
const index = Math.trunc(value);
|
|
174
215
|
return Number.isFinite(index) ? index : null;
|
|
@@ -260,7 +301,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
260
301
|
position >= 0 &&
|
|
261
302
|
position < this.pages().length
|
|
262
303
|
) {
|
|
263
|
-
if (this.nativeTabBarEnabled()) {
|
|
304
|
+
if (this.nativeTabBarEnabled() && !this.props.nativeTabBar?.controlled) {
|
|
264
305
|
this.dispatchNativeTabPageCommand(position, true);
|
|
265
306
|
} else {
|
|
266
307
|
CollapsiblePagerViewNativeCommands.setPage(this.nativeRef, position);
|
|
@@ -276,7 +317,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
276
317
|
position >= 0 &&
|
|
277
318
|
position < this.pages().length
|
|
278
319
|
) {
|
|
279
|
-
if (this.nativeTabBarEnabled()) {
|
|
320
|
+
if (this.nativeTabBarEnabled() && !this.props.nativeTabBar?.controlled) {
|
|
280
321
|
this.dispatchNativeTabPageCommand(position, false);
|
|
281
322
|
} else {
|
|
282
323
|
CollapsiblePagerViewNativeCommands.setPageWithoutAnimation(
|
|
@@ -497,6 +538,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
497
538
|
return;
|
|
498
539
|
}
|
|
499
540
|
if (
|
|
541
|
+
!this.props.nativeTabBar?.controlled &&
|
|
500
542
|
position >= 0 &&
|
|
501
543
|
position < this.pages().length &&
|
|
502
544
|
(position !== this.state.selectedPage ||
|
|
@@ -515,6 +557,13 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
515
557
|
this.props.onNativeTabPress?.(event);
|
|
516
558
|
};
|
|
517
559
|
|
|
560
|
+
private onNativeToolbarPress = (
|
|
561
|
+
event: ReactNative.NativeSyntheticEvent<CollapsiblePagerToolbarPress>
|
|
562
|
+
) => {
|
|
563
|
+
if (!this.props.nativeTabBar?.toolbar?.[event.nativeEvent.key]?.iconName) return;
|
|
564
|
+
this.props.onNativeToolbarPress?.(event);
|
|
565
|
+
};
|
|
566
|
+
|
|
518
567
|
private onNativeSubHeaderPress = (
|
|
519
568
|
event: ReactNative.NativeSyntheticEvent<OnNativeTabPressEventData>
|
|
520
569
|
) => {
|
|
@@ -635,6 +684,20 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
635
684
|
retainedPages={JSON.stringify([...retained])}
|
|
636
685
|
onPageSelected={this.onPageSelected}
|
|
637
686
|
onPageScrollStateChanged={this.onPageScrollStateChanged}
|
|
687
|
+
nativeTabBarConfig={nativeTabBarEnabled ? JSON.stringify({
|
|
688
|
+
controlled: nativeTabBar.controlled,
|
|
689
|
+
selectedKey: nativeTabBar.selectedKey,
|
|
690
|
+
pageKeys: (() => {
|
|
691
|
+
const keys: string[] = [];
|
|
692
|
+
React.Children.forEach(this.props.children, (child) => {
|
|
693
|
+
if (child !== null && child !== undefined && typeof child !== "boolean") keys.push(pageKey(child, keys.length));
|
|
694
|
+
});
|
|
695
|
+
return keys;
|
|
696
|
+
})(),
|
|
697
|
+
toolbar: nativeToolbar(nativeTabBar.toolbar),
|
|
698
|
+
activeFontFamily: nativeTabBar.style?.activeFontFamily,
|
|
699
|
+
}) : undefined}
|
|
700
|
+
onNativeToolbarPress={this.onNativeToolbarPress}
|
|
638
701
|
nativeTabBarItems={
|
|
639
702
|
nativeTabBarEnabled ? JSON.stringify(nativeTabBar.items) : undefined
|
|
640
703
|
}
|
|
@@ -659,7 +722,7 @@ export class CollapsiblePagerView extends React.PureComponent<
|
|
|
659
722
|
nativeTabBarEnabled ? nativeTabBarStyle?.itemSpacing ?? 8 : undefined
|
|
660
723
|
}
|
|
661
724
|
nativeTabBarFontSize={
|
|
662
|
-
nativeTabBarEnabled ? nativeTabBarStyle?.fontSize ?? 16 : undefined
|
|
725
|
+
nativeTabBarEnabled ? nativeTabBarStyle?.fontSize ?? (nativeTabBarStyle?.variant === "text" ? 18 : 16) : undefined
|
|
663
726
|
}
|
|
664
727
|
nativeTabBarFontFamily={
|
|
665
728
|
nativeTabBarEnabled ? nativeTabBarStyle?.fontFamily : undefined
|