@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.
package/docs/SPEC.md CHANGED
@@ -74,6 +74,11 @@ The static Home example also passed a focused TypeScript check.
74
74
  Detailed iOS runtime evidence is recorded separately; physical-device and exact
75
75
  reference-video acceptance remain pending.
76
76
 
77
+ Reference-recording motion revision: implemented on iOS and Android. iOS is
78
+ runtime verified in the consumer app on an iPhone 17 simulator; Android is
79
+ source-complete with updated native tests that still need an emulator run (see
80
+ Conformance below).
81
+
77
82
  `renderDrawerContent?: () => React.ReactNode` supplies an optional menu slot.
78
83
  `drawerOpen?: boolean` defaults to false and requests its stable open state.
79
84
  `onDrawerOpenChange?: (open: boolean) => void` reports a completed user transition;
@@ -86,8 +91,28 @@ screen). Existing `hapticFeedbackEnabled` enables one light native haptic after
86
91
  a completed user transition changes the stable state. Programmatic updates and
87
92
  cancelled gestures do not vibrate.
88
93
 
94
+ `onDrawerProgress?: (event) => void` receives `{ progress }`, the displayed
95
+ progress clamped to [0, 1], while the drawer moves. Native emits it only while
96
+ a handler is set (the wrapper derives the internal `progressEventsEnabled` prop
97
+ from the handler's presence), at most once per frame, when progress changed by
98
+ at least .002, and always on reaching 0 or 1. Enabling it emits the current
99
+ value once, so a new subscriber starts in sync. The wrapper enables it one
100
+ commit after mount, once the host's event emitter and an animated host's
101
+ worklet handler are attached; on iOS the host also re-sends the current value
102
+ when Fabric attaches the event emitter after a mount's first props. The handler is passed to the
103
+ host unchanged, so `drawerHostComponent?` (default: the native host) can be an
104
+ animated wrapper such as `Animated.createAnimatedComponent(BottomTabsDrawerNative)`
105
+ whose worklet handler consumes the event on the UI thread. The package does
106
+ not depend on Reanimated; `BottomTabsDrawerNative` is exported for this use.
107
+ `drawerColorScheme?: "light" | "dark"` selects the page palette below; when
108
+ omitted the internal `colorScheme` prop is `"system"` and follows the iOS trait
109
+ collection or the Android configuration's night mode. Pass the app theme when
110
+ it can differ from those (an app-level iOS window style override is followed
111
+ without it).
112
+
89
113
  The drawer is physically left on both iOS and Android, including RTL. Its width
90
- is 78 percent of the host. The foreground is the full tab container, including
114
+ is 80 percent of the host, and the React menu slot is laid out at the same
115
+ 80 percent so its descendants reach the menu's edge. The foreground is the full tab container, including
91
116
  the native tab bar and an optional custom JS bar. It keeps its full width and
92
117
  height while moving right, without scaling, scene reparenting or remounting.
93
118
  The native host and two slots remain mounted when the drawer is disabled or its
@@ -96,12 +121,19 @@ an event, and passes foreground input through. Web omits the drawer host/menu
96
121
  and passes the existing tab content through; it implements no drawer gestures.
97
122
  The existing tab view's other Web support is unchanged.
98
123
 
99
- For normalized progress `p` in [0, 1], foreground translation is `.78 * width * p`,
100
- its left circular corner radius is `64 * p` points/dp and its neutral gray
101
- dim surface (RGB 28/28/28) has opacity `.7 * p`.
102
- The menu translates from `-.12 * drawerWidth` to zero; a black menu shade fades
103
- from .12 to zero. These are initial reference-video tuning values, not a claim
104
- of pixel-perfect parity. Closed menus are hidden from touch/accessibility;
124
+ For normalized progress `p` in [0, 1], foreground translation is `.8 * width * p`
125
+ and its left circular corner radius is `62 * min(1, p / .1)` points/dp, so
126
+ screens with other display corners never show a radius jump. The dim surface
127
+ washes the page linearly: white at `.5 * p` in the light palette, RGB 36/36/36
128
+ at `.58 * p` in the dark palette. In the light palette the page also casts a
129
+ black shadow under its left edge and corners, opacity .16, Gaussian sigma 18
130
+ points/dp, no offset, following the current corner radius; in the dark palette it instead draws a one-physical-pixel
131
+ white edge at 17 percent opacity. The menu scales from .97 to 1 about its
132
+ left-center edge (1 throughout when motion is reduced, see below) and its
133
+ opacity is `min(1, p / .6)`. The host itself is transparent, so whatever lies
134
+ behind it shows through the fading menu and its scaled-down margins.
135
+ These values were measured frame by frame from the reference recording.
136
+ Closed menus are hidden from touch/accessibility;
105
137
  while visible, the foreground is blocked by a native dim surface. Tapping that
106
138
  surface closes the drawer. iOS accessibility escape and Android Back close an
107
139
  open drawer; the dim surface exposes an accessible close action.
@@ -153,27 +185,57 @@ Vertical gestures fail before taking ownership. Active touches interrupted by
153
185
  a second finger, system cancellation, disabling, detach or a newer prop update
154
186
  cannot later emit an event. Cancellation returns to the previous stable state,
155
187
  or resumes an external target whose programmatic animation the gesture interrupted.
156
- No gesture progress crosses the JS bridge.
157
-
158
- Both platforms settle on their UI thread with the same critically damped curve:
159
- `p(t) = target + (a + b*t) * exp(-22*t)`, where `a = p0-target`,
160
- `b = v0 + 22*a`, and normalized velocity `v0` is clamped to [-8, 8] per second.
161
- Presentation is clamped to [0, 1], and the transition ends at or before 500 ms.
162
- Release targets open when `p + v0*.12 >= .5`. A newer animation or touch starts
163
- from the current displayed progress and cancels the previous completion.
188
+ Gesture progress crosses the JS bridge only through the opt-in `onDrawerProgress`.
189
+
190
+ Both platforms settle on their UI thread with the same curves. A tap, dim
191
+ close, Back/escape or prop change starting from rest eases with
192
+ cubic-bezier(.55, .6, .2, 1) over `max(.12, D * |target - p0|)` seconds, where D
193
+ is .36 to open and .29 to close. A released drag settles on a spring with
194
+ natural frequency 25.5 rad/s and damping ratio .84, starting from its normalized
195
+ finger velocity `v0` clamped to [-12, 12] per second; release targets open when
196
+ `p + v0*.12 >= .5`. Only this spring may carry the page past open, by at most
197
+ 3 percent of the drawer width; reported progress and touch/accessibility state
198
+ stay clamped to [0, 1]. The spring ends once within .0005 of its target and
199
+ slower than .02 per second, or at 600 ms. A request for a different target
200
+ while animating continues from the displayed progress with its current
201
+ velocity on the spring; a request for the same target keeps the running
202
+ animation and only replaces whether its completion is a user transition. A
203
+ touch starts from the current displayed progress and cancels the previous
204
+ completion. When the system asks for less motion (iOS Reduce Motion; Android
205
+ with animator duration scale 0), the menu does not scale. On iOS a tap,
206
+ close or prop change from rest then cross-fades from a snapshot to the final
207
+ state over 200 ms instead of moving, and a released drag settles critically
208
+ damped (damping ratio 1) without travelling past its target. A cross-fade is
209
+ an in-flight transition like an animation: its final state shows at once under
210
+ the snapshot, but the stable state, `onDrawerOpenChange` and the haptic follow
211
+ only when the fade ends. A newer cross-fade replaces the previous snapshot
212
+ (capturing it as currently shown). A request for the target already being
213
+ faded to leaves the fade running and only replaces whether its completion is a
214
+ user transition. A touch, an animated settle, a newer cross-fade, disabling or
215
+ detach removes the snapshot without completing it, as a touch does a running
216
+ animation, so a drag that begins during a faded close never receives that
217
+ close's prop echo; a resize completes it at once. While the snapshot shows, the
218
+ host takes every touch itself, so none reaches a page, menu or dim control that
219
+ is already in the final state under it; the drawer pan still receives them.
220
+ Android has no separate reduced-motion setting and lands such transitions
221
+ immediately.
164
222
  Resize snaps a pending settlement to its target, emitting its user event once
165
223
  if appropriate; an active drag follows the same cancellation rule. Detach cancels
166
224
  animations and callbacks; reattachment reapplies the latest external target.
167
225
  The host retains at most one display-link/animator, one touch
168
- sequence, two React child slots, and native dim surfaces. It owns no snapshots,
169
- workers, persistence, JS animation objects, RNGH or Reanimated dependency.
226
+ sequence, two React child slots, and native dim surfaces; on iOS one transient
227
+ snapshot during a reduced-motion cross-fade, removed when it ends; on Android
228
+ one hardware layer on the menu while its opacity is strictly between 0 and 1,
229
+ and three gradient shaders for the page shadow, rebuilt only when the corner
230
+ radius, height or palette changes. It owns no workers, persistence, JS
231
+ animation objects, RNGH or Reanimated dependency.
170
232
 
171
233
  Implementation boundaries: `src/BottomTabs.tsx` owns slots and settled callbacks;
172
234
  `src/BottomTabsDrawerNativeComponent.ts` defines the Fabric boundary;
173
235
  `ios/RCTBottomTabsDrawerContainerView.swift` and
174
236
  `android/src/main/java/com/onekey/bottomtabs/BottomTabsDrawerView.kt` own native
175
237
  input, layout, animation and cleanup. The iOS Fabric component and Android manager only forward children,
176
- props and the settled event. Required acceptance includes both bar styles,
238
+ props, the settled event and the opt-in progress event. Required acceptance includes both bar styles,
177
239
  custom bars, content/vertical gestures, dim close, rapid reversal, cancellation,
178
240
  disable/remove-content, resize, detach, accessibility, RTL and bottom-bar
179
241
  gesture ownership, including a real pager, nested horizontal list and vertical
@@ -181,6 +243,31 @@ scrolling in the complete Fabric example. Source checks and emulator checks do n
181
243
  device smoothness or exact reference-video fidelity.
182
244
  The Android native suite also exercises generated drawer prop forwarding in RTL,
183
245
  physical-left placement, and closing pans while opening swipes are disabled.
246
+ For the reference-recording revision it asserts the 80 percent travel, the
247
+ light and dark wash, the menu's final scale/opacity/layer, and that progress
248
+ events are opt-in, start in sync and end on the stable state; the wrapper tests
249
+ assert that progress stays off without a handler and during the mount commit,
250
+ that the handler, a replacement host and the color scheme reach native
251
+ unchanged, and that the menu slot is 80 percent wide. The iOS suite
252
+ `ios/tests/BottomTabsDrawerReduceMotionTests.swift` runs without an app host,
253
+ forcing Reduce Motion and supplying the fade snapshot through internal test
254
+ hooks. It asserts that a user close reports once, after the snapshot is gone;
255
+ that a drag taking over the fade drops the faded close and reports only its own
256
+ release; that a resize lands the fade at once; that same-target and newer
257
+ requests, disabling and detach take over or drop the pending report; and that
258
+ touches during an opening or closing fade land on the host, not on the menu,
259
+ page or dim under the snapshot.
260
+ Recorded evidence so far: on the iPhone 17 simulator (iOS 26) in the consumer
261
+ app, tap open/close timing, fling overshoot (about 2 points), smooth reversal,
262
+ the corner ramp, the reduced-motion cross-fade, the light/dark palettes and a
263
+ UI-thread Reanimated progress handler were compared frame by frame with the
264
+ reference recording. After the review fixes, the same setup showed menu content
265
+ reaching 20 points from the 80 percent edge, the header avatar hidden at full
266
+ open through the deferred progress event, no travel past open on a
267
+ reduced-motion fling, and three toggles within 120 ms under Reduce Motion
268
+ cross-fading to the final state with no leftover image (snapshot replacement
269
+ itself is source-verified). The Android suite has not yet been run for this revision;
270
+ physical-device smoothness on either platform remains unverified.
184
271
 
185
272
  The standalone `example/react-native/pages/BottomTabsHomeDrawerExample.tsx`
186
273
  reproduces Home’s wallet toolbar, balance/actions/banner shared header and
@@ -13,9 +13,13 @@
13
13
  @property(nonatomic) BOOL swipeEnabled;
14
14
  @property(nonatomic) BOOL hapticFeedbackEnabled;
15
15
  @property(nonatomic) double bottomBarHeight;
16
+ @property(nonatomic, copy) NSString *colorScheme;
17
+ @property(nonatomic) BOOL progressEventsEnabled;
16
18
  @property(nonatomic, copy) void (^onDrawerOpenChange)(BOOL open);
19
+ @property(nonatomic, copy) void (^onDrawerProgress)(double progress);
17
20
  - (void)insertChild:(UIView *)child atIndex:(NSInteger)index;
18
21
  - (void)removeChildAtIndex:(NSInteger)index;
22
+ - (void)resendProgress;
19
23
  @end
20
24
 
21
25
  using namespace facebook::react;
@@ -45,6 +49,12 @@ using namespace facebook::react;
45
49
  auto emitter = std::static_pointer_cast<const RNBottomTabsDrawerEventEmitter>(strongSelf->_eventEmitter);
46
50
  if (emitter) emitter->onDrawerOpenChange({.open = (bool)open});
47
51
  };
52
+ _drawer.onDrawerProgress = ^(double progress) {
53
+ auto strongSelf = weakSelf;
54
+ if (!strongSelf) return;
55
+ auto emitter = std::static_pointer_cast<const RNBottomTabsDrawerEventEmitter>(strongSelf->_eventEmitter);
56
+ if (emitter) emitter->onDrawerProgress({.progress = progress});
57
+ };
48
58
  }
49
59
  return self;
50
60
  }
@@ -59,6 +69,14 @@ using namespace facebook::react;
59
69
  [_drawer removeChildAtIndex:index];
60
70
  }
61
71
 
72
+ - (void)updateEventEmitter:(EventEmitter::Shared const &)eventEmitter
73
+ {
74
+ [super updateEventEmitter:eventEmitter];
75
+ // Fabric applies a mount's props before its emitter, so a position reported
76
+ // then never left native; send the current one now.
77
+ [_drawer resendProgress];
78
+ }
79
+
62
80
  - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
63
81
  {
64
82
  const auto &next = *std::static_pointer_cast<const RNBottomTabsDrawerProps>(props);
@@ -69,6 +87,12 @@ using namespace facebook::react;
69
87
  if (next.hapticFeedbackEnabled != previous.hapticFeedbackEnabled)
70
88
  _drawer.hapticFeedbackEnabled = next.hapticFeedbackEnabled;
71
89
  if (next.bottomBarHeight != previous.bottomBarHeight) _drawer.bottomBarHeight = next.bottomBarHeight;
90
+ if (next.colorScheme != previous.colorScheme) {
91
+ _drawer.colorScheme = next.colorScheme == RNBottomTabsDrawerColorScheme::Light ? @"light"
92
+ : next.colorScheme == RNBottomTabsDrawerColorScheme::Dark ? @"dark" : @"system";
93
+ }
94
+ if (next.progressEventsEnabled != previous.progressEventsEnabled)
95
+ _drawer.progressEventsEnabled = next.progressEventsEnabled;
72
96
  [super updateProps:props oldProps:oldProps];
73
97
  }
74
98
  @end