@onekeyfe/react-native-bottom-tabs 6.7.0-62 → 6.7.0-63

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.
@@ -0,0 +1,231 @@
1
+ import UIKit
2
+ import XCTest
3
+ @testable import BottomTabsModule
4
+
5
+ /// Reduce Motion cross-fades: when a faded transition reports, and what takes
6
+ /// it over. Runs without an app host.
7
+ @MainActor
8
+ final class BottomTabsDrawerReduceMotionTests: XCTestCase {
9
+ func testUserCloseReportsOnceWhenTheFadeEnds() throws {
10
+ let fixture = Fixture(open: true)
11
+ defer { fixture.close() }
12
+
13
+ XCTAssertTrue(fixture.drawer.accessibilityPerformEscape())
14
+ try fixture.requireFade()
15
+ XCTAssertEqual(fixture.progress, 0, "the final state shows under the snapshot")
16
+ XCTAssertEqual(fixture.events, [], "nothing is reported while the fade runs")
17
+ XCTAssertEqual(fixture.stableOpen, true)
18
+
19
+ XCTAssertTrue(fixture.waitUntil { !fixture.isFading })
20
+ XCTAssertEqual(fixture.events, [false])
21
+ XCTAssertEqual(fixture.fadingAtEvent, [false], "the report waits for the snapshot to go")
22
+ XCTAssertEqual(fixture.stableOpen, false)
23
+ }
24
+
25
+ func testDragTakingOverTheFadeDropsItsStaleClose() throws {
26
+ let fixture = Fixture(open: true)
27
+ defer { fixture.close() }
28
+ XCTAssertTrue(fixture.drawer.accessibilityPerformEscape())
29
+ try fixture.requireFade()
30
+
31
+ fixture.pan(.began)
32
+ XCTAssertFalse(fixture.isFading)
33
+ // A close reported here would echo back as `open = false` and cancel the drag.
34
+ XCTAssertEqual(fixture.events, [])
35
+ fixture.pan(.changed, dx: fixture.menuWidth * 0.9)
36
+ XCTAssertEqual(fixture.progress, 0.9, accuracy: 0.001)
37
+ fixture.pan(.ended)
38
+ XCTAssertTrue(fixture.waitUntil { !fixture.isAnimating })
39
+
40
+ XCTAssertEqual(fixture.progress, 1)
41
+ XCTAssertEqual(fixture.stableOpen, true)
42
+ XCTAssertEqual(fixture.events, [], "reopening lands on the state JS already has")
43
+ fixture.wait(0.3)
44
+ XCTAssertEqual(fixture.events, [])
45
+ }
46
+
47
+ func testDragTakingOverTheFadeReportsItsOwnClose() throws {
48
+ let fixture = Fixture(open: true)
49
+ defer { fixture.close() }
50
+ XCTAssertTrue(fixture.drawer.accessibilityPerformEscape())
51
+ try fixture.requireFade()
52
+
53
+ fixture.pan(.began)
54
+ fixture.pan(.changed, dx: fixture.menuWidth * 0.2)
55
+ fixture.pan(.ended)
56
+ XCTAssertTrue(fixture.waitUntil { !fixture.isAnimating })
57
+
58
+ XCTAssertEqual(fixture.progress, 0)
59
+ XCTAssertEqual(fixture.events, [false])
60
+ fixture.wait(0.3)
61
+ XCTAssertEqual(fixture.events, [false])
62
+ }
63
+
64
+ func testResizeLandsTheFadeAtOnce() throws {
65
+ let fixture = Fixture(open: true)
66
+ defer { fixture.close() }
67
+ XCTAssertTrue(fixture.drawer.accessibilityPerformEscape())
68
+ try fixture.requireFade()
69
+
70
+ fixture.drawer.frame.size.width = 420
71
+ fixture.drawer.layoutIfNeeded()
72
+ XCTAssertFalse(fixture.isFading)
73
+ XCTAssertEqual(fixture.events, [false])
74
+ XCTAssertEqual(fixture.stableOpen, false)
75
+ fixture.wait(0.3)
76
+ XCTAssertEqual(fixture.events, [false], "the replaced fade does not report again")
77
+ }
78
+
79
+ func testNewerRequestsTakeOverTheFadeAndItsCompletion() throws {
80
+ let fixture = Fixture(open: true)
81
+ defer { fixture.close() }
82
+ XCTAssertTrue(fixture.drawer.accessibilityPerformEscape())
83
+ try fixture.requireFade()
84
+
85
+ // JS closes too: same target, so the landing is no longer a user event.
86
+ fixture.drawer.open = false
87
+ // JS reopens: a newer fade replaces the first, keeping one snapshot.
88
+ fixture.drawer.open = true
89
+ try fixture.requireFade()
90
+ XCTAssertEqual(fixture.drawer.subviews.count, 3)
91
+ XCTAssertEqual(fixture.progress, 1)
92
+
93
+ XCTAssertTrue(fixture.waitUntil { !fixture.isFading })
94
+ fixture.wait(0.3)
95
+ XCTAssertEqual(fixture.events, [])
96
+ XCTAssertEqual(fixture.stableOpen, true)
97
+ XCTAssertEqual(fixture.drawer.subviews.count, 2)
98
+ }
99
+
100
+ func testTouchesLandOnTheHostUntilTheFadeEnds() throws {
101
+ // Closing: the menu still shows, over a page already back in place.
102
+ let closing = Fixture(open: true)
103
+ defer { closing.close() }
104
+ let inMenu = CGPoint(x: closing.menuWidth / 2, y: 100)
105
+ XCTAssertTrue(closing.drawer.accessibilityPerformEscape())
106
+ try closing.requireFade()
107
+ XCTAssertTrue(closing.hit(inMenu) === closing.drawer, "not the page under the shown menu")
108
+ XCTAssertTrue(closing.waitUntil { !closing.isFading })
109
+ XCTAssertTrue(closing.hit(inMenu) === closing.page)
110
+
111
+ // Opening: the page still shows, over a menu and dim already open.
112
+ let opening = Fixture(open: false)
113
+ defer { opening.close() }
114
+ let onDim = CGPoint(x: opening.menuWidth + 20, y: 100)
115
+ opening.drawer.open = true
116
+ try opening.requireFade()
117
+ XCTAssertTrue(opening.hit(inMenu) === opening.drawer, "not the menu under the shown page")
118
+ XCTAssertTrue(opening.hit(onDim) === opening.drawer, "not the dim, which would close")
119
+ XCTAssertTrue(opening.waitUntil { !opening.isFading })
120
+ XCTAssertTrue(opening.hit(inMenu) === opening.menu)
121
+ XCTAssertTrue(opening.hit(onDim) is UIButton)
122
+ }
123
+
124
+ func testDisablingOrDetachingDropsThePendingClose() throws {
125
+ let disabled = Fixture(open: true)
126
+ defer { disabled.close() }
127
+ XCTAssertTrue(disabled.drawer.accessibilityPerformEscape())
128
+ try disabled.requireFade()
129
+ disabled.drawer.enabled = false
130
+ XCTAssertFalse(disabled.isFading)
131
+ disabled.wait(0.3)
132
+ XCTAssertEqual(disabled.events, [])
133
+
134
+ let detached = Fixture(open: true)
135
+ defer { detached.close() }
136
+ XCTAssertTrue(detached.drawer.accessibilityPerformEscape())
137
+ try detached.requireFade()
138
+ detached.drawer.removeFromSuperview()
139
+ XCTAssertFalse(detached.isFading)
140
+ // Like an interrupted settle, it returns to the last state JS was told.
141
+ XCTAssertEqual(detached.progress, 1)
142
+ detached.wait(0.3)
143
+ XCTAssertEqual(detached.events, [])
144
+ detached.window.addSubview(detached.drawer)
145
+ XCTAssertEqual(detached.progress, 1)
146
+ XCTAssertEqual(detached.events, [])
147
+ }
148
+ }
149
+
150
+ @MainActor
151
+ private final class Fixture {
152
+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 844))
153
+ let drawer = RCTBottomTabsDrawerContainerView(frame: CGRect(x: 0, y: 0, width: 390, height: 844))
154
+ let menu = UIView()
155
+ let page = UIView()
156
+ private(set) var events: [Bool] = []
157
+ private(set) var fadingAtEvent: [Bool] = []
158
+ private let recognizer = FakePan(target: nil, action: nil)
159
+
160
+ /// An enabled drawer that already rests at `open`, as the prop echo leaves it.
161
+ init(open: Bool) {
162
+ drawer.isReduceMotionEnabled = { true }
163
+ drawer.makeFadeSnapshot = { _ in UIView() }
164
+ drawer.insertChild(menu, atIndex: 0)
165
+ drawer.insertChild(page, atIndex: 1)
166
+ drawer.swipeEnabled = true
167
+ drawer.enabled = true
168
+ // Outside a window, the drawer lands on a target without animating.
169
+ drawer.open = open
170
+ window.addSubview(drawer)
171
+ window.isHidden = false
172
+ drawer.layoutIfNeeded()
173
+ drawer.onDrawerOpenChange = { [unowned self] open in
174
+ self.events.append(open)
175
+ self.fadingAtEvent.append(self.isFading)
176
+ }
177
+ }
178
+
179
+ var menuWidth: CGFloat { drawer.bounds.width * 0.8 }
180
+ var progress: CGFloat { value("progress") ?? -1 }
181
+ var stableOpen: Bool? { value("stableOpen") }
182
+ var isFading: Bool { value("fadeSnapshot") as UIView? != nil }
183
+ var isAnimating: Bool { value("displayLink") as CADisplayLink? != nil }
184
+
185
+ func requireFade(file: StaticString = #filePath, line: UInt = #line) throws {
186
+ _ = try XCTUnwrap(value("fadeSnapshot") as UIView?, "Reduce Motion should cross-fade",
187
+ file: file, line: line)
188
+ }
189
+
190
+ /// The view UIKit would deliver a touch at `point` to.
191
+ func hit(_ point: CGPoint) -> UIView? { drawer.hitTest(point, with: nil) }
192
+
193
+ /// Delivers one recognizer callback, as UIKit does for the drawer's pan.
194
+ func pan(_ state: UIGestureRecognizer.State, dx: CGFloat = 0) {
195
+ recognizer.fakeState = state
196
+ recognizer.fakeTranslation = CGPoint(x: dx, y: 0)
197
+ drawer.perform(NSSelectorFromString("handlePan:"), with: recognizer)
198
+ }
199
+
200
+ func wait(_ seconds: TimeInterval) {
201
+ RunLoop.main.run(until: Date().addingTimeInterval(seconds))
202
+ }
203
+
204
+ func waitUntil(timeout: TimeInterval = 2, _ condition: () -> Bool) -> Bool {
205
+ let deadline = Date().addingTimeInterval(timeout)
206
+ while !condition() && Date() < deadline { wait(0.01) }
207
+ return condition()
208
+ }
209
+
210
+ func close() {
211
+ drawer.removeFromSuperview()
212
+ window.isHidden = true
213
+ }
214
+
215
+ private func value<T>(_ name: String) -> T? {
216
+ Mirror(reflecting: drawer).descendant(name) as? T
217
+ }
218
+ }
219
+
220
+ private final class FakePan: UIPanGestureRecognizer {
221
+ var fakeState: UIGestureRecognizer.State = .possible
222
+ var fakeTranslation = CGPoint.zero
223
+
224
+ override var state: UIGestureRecognizer.State {
225
+ get { fakeState }
226
+ set { fakeState = newValue }
227
+ }
228
+ override var numberOfTouches: Int { 1 }
229
+ override func translation(in view: UIView?) -> CGPoint { fakeTranslation }
230
+ override func velocity(in view: UIView?) -> CGPoint { .zero }
231
+ }
@@ -117,6 +117,24 @@ const defaultGetIcon = ({
117
117
  focused
118
118
  }) => route.unfocusedIcon ? focused ? route.focusedIcon : route.unfocusedIcon : route.focusedIcon;
119
119
  const ANDROID_MAX_TABS = 100;
120
+ // Progress events start one commit after mount: during the mount itself the
121
+ // iOS event emitter and an animated host's worklet handler are not attached
122
+ // yet, so the current position native sends on enabling would be lost. The
123
+ // state lives here so that commit re-renders only the host, not the tabs.
124
+ function DrawerHostWithProgress({
125
+ host: Host,
126
+ ...props
127
+ }) {
128
+ const hasProgressHandler = props.onDrawerProgress != null;
129
+ const [mounted, setMounted] = React.useState(false);
130
+ React.useEffect(() => {
131
+ if (hasProgressHandler) setMounted(true);
132
+ }, [hasProgressHandler]);
133
+ return /*#__PURE__*/_jsx(Host, {
134
+ ...props,
135
+ progressEventsEnabled: mounted && hasProgressHandler
136
+ });
137
+ }
120
138
  const BottomTabs = ({
121
139
  navigationState,
122
140
  renderScene,
@@ -127,6 +145,9 @@ const BottomTabs = ({
127
145
  drawerOpen = false,
128
146
  drawerSwipeEnabled = false,
129
147
  onDrawerOpenChange,
148
+ onDrawerProgress,
149
+ drawerHostComponent: DrawerHost = NativeBottomTabsDrawer,
150
+ drawerColorScheme,
130
151
  rippleColor,
131
152
  tabBarActiveTintColor: activeTintColor,
132
153
  tabBarInactiveTintColor: inactiveTintColor,
@@ -306,14 +327,17 @@ const BottomTabs = ({
306
327
  }, [renderCustomTabBar]);
307
328
  return /*#__PURE__*/_jsx(BottomTabBarHeightContext.Provider, {
308
329
  value: tabBarHeight,
309
- children: /*#__PURE__*/_jsxs(NativeBottomTabsDrawer, {
330
+ children: /*#__PURE__*/_jsxs(DrawerHostWithProgress, {
331
+ host: DrawerHost,
310
332
  style: styles.fullWidth,
311
333
  enabled: !!renderDrawerContent,
312
334
  open: drawerOpen,
313
335
  swipeEnabled: drawerSwipeEnabled,
314
336
  hapticFeedbackEnabled: hapticFeedbackEnabled,
315
337
  bottomBarHeight: tabBarHeight ?? 0,
338
+ colorScheme: drawerColorScheme,
316
339
  onDrawerOpenChange: event => onDrawerOpenChange?.(event.nativeEvent.open),
340
+ onDrawerProgress: onDrawerProgress,
317
341
  children: [/*#__PURE__*/_jsx(View, {
318
342
  collapsable: false,
319
343
  style: styles.drawerMenu,
@@ -401,7 +425,8 @@ const styles = StyleSheet.create({
401
425
  },
402
426
  drawerMenu: {
403
427
  position: "absolute",
404
- width: "78%",
428
+ // Must match the native drawer width so menu descendants lay out to its edge.
429
+ width: "80%",
405
430
  height: "100%"
406
431
  },
407
432
  screen: {
@@ -11,7 +11,10 @@ export interface BottomTabsDrawerNativeProps extends ViewProps {
11
11
  swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
12
12
  hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
13
13
  bottomBarHeight?: CodegenTypes.Double;
14
+ colorScheme?: CodegenTypes.WithDefault<"system" | "light" | "dark", "system">;
15
+ progressEventsEnabled?: CodegenTypes.WithDefault<boolean, false>;
14
16
  onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{ open: boolean }>>;
17
+ onDrawerProgress?: CodegenTypes.DirectEventHandler<Readonly<{ progress: CodegenTypes.Double }>>;
15
18
  }
16
19
 
17
20
  export default codegenNativeComponent<BottomTabsDrawerNativeProps>(
@@ -11,6 +11,7 @@ export default BottomTabs;
11
11
  * Utilities
12
12
  */
13
13
  export { SceneMap } from "./SceneMap.js";
14
+ export { default as BottomTabsDrawerNative } from './BottomTabsDrawerNativeComponent';
14
15
  export { useBottomTabBarHeight } from "./utils/useBottomTabBarHeight.js";
15
16
  export { BottomTabBarHeightContext } from "./utils/BottomTabBarHeightContext.js";
16
17
 
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
+ import type { NativeSyntheticEvent } from "react-native";
2
3
  import { type ColorValue, type ImageSourcePropType, type StyleProp, type ViewStyle } from "react-native";
3
4
  import type { BaseRoute, BottomTabIconSource, NamedIcon, NavigationState, TabBarPlacement, TabRole } from "./types";
5
+ import NativeBottomTabsDrawer from "./BottomTabsDrawerNativeComponent";
4
6
  import { type RNBottomTabsAccessoryViewProps } from "./BottomAccessoryView";
5
7
  type ResolvedTabIconSource = {
6
8
  uri: string;
@@ -19,6 +21,22 @@ interface Props<Route extends BaseRoute> {
19
21
  drawerSwipeEnabled?: boolean;
20
22
  /** Reports a completed user target so the external open state can follow it. */
21
23
  onDrawerOpenChange?: (open: boolean) => void;
24
+ /**
25
+ * The drawer's visual progress (0 closed, 1 open) on every frame it moves.
26
+ * Passed to the drawer host as is, so a Reanimated handler can run it on the
27
+ * UI thread when `drawerHostComponent` is an animated component. Native sends
28
+ * no progress events without this handler.
29
+ */
30
+ onDrawerProgress?: (event: NativeSyntheticEvent<Readonly<{
31
+ progress: number;
32
+ }>>) => void;
33
+ /** Host for the native drawer, e.g. `Animated.createAnimatedComponent(BottomTabsDrawerNative)`. */
34
+ drawerHostComponent?: React.ComponentType<React.ComponentProps<typeof NativeBottomTabsDrawer>>;
35
+ /**
36
+ * Palette for the page's overlay, shadow and edge while the drawer is open.
37
+ * Defaults to the platform appearance; pass the app theme when it can differ.
38
+ */
39
+ drawerColorScheme?: "light" | "dark";
22
40
  /**
23
41
  * A tab bar style that adapts to each platform.
24
42
  *
@@ -239,6 +257,6 @@ interface Props<Route extends BaseRoute> {
239
257
  */
240
258
  onSideAccessoryPress?: () => void;
241
259
  }
242
- declare const BottomTabs: <Route extends BaseRoute>({ navigationState, renderScene, renderLazyPlaceholder, onIndexChange, onTabDoublePress, renderDrawerContent, drawerOpen, drawerSwipeEnabled, onDrawerOpenChange, rippleColor, tabBarActiveTintColor: activeTintColor, tabBarInactiveTintColor: inactiveTintColor, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getLazy, getLabelText, getIcon, getHidden, getActiveTintColor, getTestID, getRole, getSceneStyle, getPreventsDefault, hapticFeedbackEnabled, labeled, getFreezeOnBlur, tabBar: renderCustomTabBar, tabBarStyle, tabLabelStyle, renderBottomAccessoryView, activeIndicatorColor, androidBottomBlurEnabled, delayedFreeze, onTabBarPlacementChange, sideAccessoryIcon, sideAccessoryLabel, onSideAccessoryPress, ...props }: Props<Route>) => React.JSX.Element;
260
+ declare const BottomTabs: <Route extends BaseRoute>({ navigationState, renderScene, renderLazyPlaceholder, onIndexChange, onTabDoublePress, renderDrawerContent, drawerOpen, drawerSwipeEnabled, onDrawerOpenChange, onDrawerProgress, drawerHostComponent: DrawerHost, drawerColorScheme, rippleColor, tabBarActiveTintColor: activeTintColor, tabBarInactiveTintColor: inactiveTintColor, getBadge, getBadgeBackgroundColor, getBadgeTextColor, getLazy, getLabelText, getIcon, getHidden, getActiveTintColor, getTestID, getRole, getSceneStyle, getPreventsDefault, hapticFeedbackEnabled, labeled, getFreezeOnBlur, tabBar: renderCustomTabBar, tabBarStyle, tabLabelStyle, renderBottomAccessoryView, activeIndicatorColor, androidBottomBlurEnabled, delayedFreeze, onTabBarPlacementChange, sideAccessoryIcon, sideAccessoryLabel, onSideAccessoryPress, ...props }: Props<Route>) => React.JSX.Element;
243
261
  export default BottomTabs;
244
262
  //# sourceMappingURL=BottomTabs.d.ts.map
@@ -5,9 +5,14 @@ export interface BottomTabsDrawerNativeProps extends ViewProps {
5
5
  swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
6
6
  hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
7
7
  bottomBarHeight?: CodegenTypes.Double;
8
+ colorScheme?: CodegenTypes.WithDefault<"system" | "light" | "dark", "system">;
9
+ progressEventsEnabled?: CodegenTypes.WithDefault<boolean, false>;
8
10
  onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{
9
11
  open: boolean;
10
12
  }>>;
13
+ onDrawerProgress?: CodegenTypes.DirectEventHandler<Readonly<{
14
+ progress: CodegenTypes.Double;
15
+ }>>;
11
16
  }
12
17
  declare const _default: import("react-native").HostComponent<BottomTabsDrawerNativeProps>;
13
18
  export default _default;
@@ -7,6 +7,7 @@ export default BottomTabs;
7
7
  * Utilities
8
8
  */
9
9
  export { SceneMap } from './SceneMap';
10
+ export { default as BottomTabsDrawerNative } from './BottomTabsDrawerNativeComponent';
10
11
  export { useBottomTabBarHeight } from './utils/useBottomTabBarHeight';
11
12
  export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
12
13
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-bottom-tabs",
3
- "version": "6.7.0-62",
3
+ "version": "6.7.0-63",
4
4
  "description": "Native bottom tabs (tab bar + scene container) for React Native on iOS and Android",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -19,6 +19,7 @@ Pod::Spec.new do |s|
19
19
  "ios/**/*.{swift}",
20
20
  "ios/**/*.{h,m,mm,cpp}",
21
21
  ]
22
+ s.exclude_files = "ios/tests/**/*"
22
23
 
23
24
  s.static_framework = true
24
25
 
@@ -34,5 +35,10 @@ Pod::Spec.new do |s|
34
35
 
35
36
  s.dependency "OneKeyImage"
36
37
 
38
+ s.test_spec "Tests" do |test_spec|
39
+ test_spec.source_files = "ios/tests/**/*.swift"
40
+ test_spec.pod_target_xcconfig = { "PRODUCT_MODULE_NAME" => "BottomTabsModuleTests" }
41
+ end
42
+
37
43
  install_modules_dependencies(s)
38
44
  end
@@ -128,6 +128,24 @@ interface Props<Route extends BaseRoute> {
128
128
  drawerSwipeEnabled?: boolean;
129
129
  /** Reports a completed user target so the external open state can follow it. */
130
130
  onDrawerOpenChange?: (open: boolean) => void;
131
+ /**
132
+ * The drawer's visual progress (0 closed, 1 open) on every frame it moves.
133
+ * Passed to the drawer host as is, so a Reanimated handler can run it on the
134
+ * UI thread when `drawerHostComponent` is an animated component. Native sends
135
+ * no progress events without this handler.
136
+ */
137
+ onDrawerProgress?: (
138
+ event: NativeSyntheticEvent<Readonly<{ progress: number }>>
139
+ ) => void;
140
+ /** Host for the native drawer, e.g. `Animated.createAnimatedComponent(BottomTabsDrawerNative)`. */
141
+ drawerHostComponent?: React.ComponentType<
142
+ React.ComponentProps<typeof NativeBottomTabsDrawer>
143
+ >;
144
+ /**
145
+ * Palette for the page's overlay, shadow and edge while the drawer is open.
146
+ * Defaults to the platform appearance; pass the app theme when it can differ.
147
+ */
148
+ drawerColorScheme?: "light" | "dark";
131
149
  /**
132
150
  * A tab bar style that adapts to each platform.
133
151
  *
@@ -368,6 +386,26 @@ const defaultGetIcon = ({
368
386
 
369
387
  const ANDROID_MAX_TABS = 100;
370
388
 
389
+ type DrawerHostProps = React.ComponentProps<typeof NativeBottomTabsDrawer>;
390
+
391
+ // Progress events start one commit after mount: during the mount itself the
392
+ // iOS event emitter and an animated host's worklet handler are not attached
393
+ // yet, so the current position native sends on enabling would be lost. The
394
+ // state lives here so that commit re-renders only the host, not the tabs.
395
+ function DrawerHostWithProgress({
396
+ host: Host,
397
+ ...props
398
+ }: DrawerHostProps & { host: React.ComponentType<DrawerHostProps> }) {
399
+ const hasProgressHandler = props.onDrawerProgress != null;
400
+ const [mounted, setMounted] = React.useState(false);
401
+ React.useEffect(() => {
402
+ if (hasProgressHandler) setMounted(true);
403
+ }, [hasProgressHandler]);
404
+ return (
405
+ <Host {...props} progressEventsEnabled={mounted && hasProgressHandler} />
406
+ );
407
+ }
408
+
371
409
  const BottomTabs = <Route extends BaseRoute>({
372
410
  navigationState,
373
411
  renderScene,
@@ -378,6 +416,9 @@ const BottomTabs = <Route extends BaseRoute>({
378
416
  drawerOpen = false,
379
417
  drawerSwipeEnabled = false,
380
418
  onDrawerOpenChange,
419
+ onDrawerProgress,
420
+ drawerHostComponent: DrawerHost = NativeBottomTabsDrawer,
421
+ drawerColorScheme,
381
422
  rippleColor,
382
423
  tabBarActiveTintColor: activeTintColor,
383
424
  tabBarInactiveTintColor: inactiveTintColor,
@@ -607,16 +648,19 @@ const BottomTabs = <Route extends BaseRoute>({
607
648
 
608
649
  return (
609
650
  <BottomTabBarHeightContext.Provider value={tabBarHeight}>
610
- <NativeBottomTabsDrawer
651
+ <DrawerHostWithProgress
652
+ host={DrawerHost}
611
653
  style={styles.fullWidth}
612
654
  enabled={!!renderDrawerContent}
613
655
  open={drawerOpen}
614
656
  swipeEnabled={drawerSwipeEnabled}
615
657
  hapticFeedbackEnabled={hapticFeedbackEnabled}
616
658
  bottomBarHeight={tabBarHeight ?? 0}
659
+ colorScheme={drawerColorScheme}
617
660
  onDrawerOpenChange={(event) =>
618
661
  onDrawerOpenChange?.(event.nativeEvent.open)
619
662
  }
663
+ onDrawerProgress={onDrawerProgress}
620
664
  >
621
665
  <View collapsable={false} style={styles.drawerMenu}>
622
666
  {Platform.OS !== "web" ? renderDrawerContent?.() : null}
@@ -722,7 +766,7 @@ const BottomTabs = <Route extends BaseRoute>({
722
766
  </View>
723
767
  ) : null}
724
768
  </View>
725
- </NativeBottomTabsDrawer>
769
+ </DrawerHostWithProgress>
726
770
  </BottomTabBarHeightContext.Provider>
727
771
  );
728
772
  };
@@ -735,7 +779,8 @@ const styles = StyleSheet.create({
735
779
  },
736
780
  drawerMenu: {
737
781
  position: "absolute",
738
- width: "78%",
782
+ // Must match the native drawer width so menu descendants lay out to its edge.
783
+ width: "80%",
739
784
  height: "100%",
740
785
  },
741
786
  screen: {
@@ -11,7 +11,10 @@ export interface BottomTabsDrawerNativeProps extends ViewProps {
11
11
  swipeEnabled?: CodegenTypes.WithDefault<boolean, false>;
12
12
  hapticFeedbackEnabled?: CodegenTypes.WithDefault<boolean, false>;
13
13
  bottomBarHeight?: CodegenTypes.Double;
14
+ colorScheme?: CodegenTypes.WithDefault<"system" | "light" | "dark", "system">;
15
+ progressEventsEnabled?: CodegenTypes.WithDefault<boolean, false>;
14
16
  onDrawerOpenChange?: CodegenTypes.DirectEventHandler<Readonly<{ open: boolean }>>;
17
+ onDrawerProgress?: CodegenTypes.DirectEventHandler<Readonly<{ progress: CodegenTypes.Double }>>;
15
18
  }
16
19
 
17
20
  export default codegenNativeComponent<BottomTabsDrawerNativeProps>(
package/src/index.tsx CHANGED
@@ -9,6 +9,7 @@ export default BottomTabs;
9
9
  * Utilities
10
10
  */
11
11
  export { SceneMap } from './SceneMap';
12
+ export { default as BottomTabsDrawerNative } from './BottomTabsDrawerNativeComponent';
12
13
  export { useBottomTabBarHeight } from './utils/useBottomTabBarHeight';
13
14
  export { BottomTabBarHeightContext } from './utils/BottomTabBarHeightContext';
14
15