@onekeyfe/react-native-bottom-tabs 6.7.0-alpha.475 → 6.8.0-11
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 +139 -48
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsDrawerManager.kt +15 -0
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsDrawerView.kt +315 -59
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +426 -53
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsViewManager.kt +6 -5
- package/android/src/main/java/com/onekey/bottomtabs/FloatingTabBarStyle.kt +22 -6
- package/android/src/main/java/com/onekey/bottomtabs/events/TabDoublePressEvent.kt +7 -1
- package/docs/SPEC.md +228 -30
- package/ios/RCTBottomTabsComponentView.mm +4 -1
- package/ios/RCTBottomTabsContainerView.swift +263 -15
- package/ios/RCTBottomTabsDrawerComponentView.mm +24 -0
- package/ios/RCTBottomTabsDrawerContainerView.swift +358 -51
- package/ios/tests/BottomTabsDrawerReduceMotionTests.swift +291 -0
- package/lib/module/BottomTabs.js +85 -58
- package/lib/module/BottomTabsDrawerNativeComponent.ts +3 -0
- package/lib/module/BottomTabsNativeComponent.ts +6 -1
- package/lib/module/index.js +1 -0
- package/lib/typescript/src/BottomTabs.d.ts +23 -2
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.d.ts +5 -0
- package/lib/typescript/src/BottomTabsNativeComponent.d.ts +5 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/package.json +1 -1
- package/react-native-bottom-tabs.podspec +6 -0
- package/src/BottomTabs.tsx +94 -44
- package/src/BottomTabsDrawerNativeComponent.ts +3 -0
- package/src/BottomTabsNativeComponent.ts +6 -1
- package/src/index.tsx +1 -0
package/README.md
CHANGED
|
@@ -1,66 +1,158 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# @onekeyfe/react-native-bottom-tabs
|
|
2
4
|
|
|
3
|
-
Native bottom-tab navigation for OneKey
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
**Native bottom-tab navigation for OneKey apps on iOS and Android — the platform owns the tab bar, the application owns routing.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@onekeyfe/react-native-bottom-tabs)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
A controlled tab container that renders the real `UITabBarController` on iOS and a
|
|
16
|
+
Material or floating native bar on Android, while the application supplies the
|
|
17
|
+
navigation state and scene components. Tab selection, badges, icons, lazy scene
|
|
18
|
+
mounting, double-press detection and the optional left drawer are handled by the
|
|
19
|
+
native view. The package targets iOS and Android only; it has no Web
|
|
20
|
+
implementation and no route definitions of its own.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Platform-native tab bars** — UIKit tab bar on iOS, Material
|
|
25
|
+
`BottomNavigationView` or a floating capsule bar on Android, with the system's
|
|
26
|
+
own gestures and insets.
|
|
27
|
+
- **Controlled navigation state** — pass `{ index, routes }`, render scenes from
|
|
28
|
+
stable route keys, and update your own state in `onIndexChange`.
|
|
29
|
+
- **Lazy and frozen scenes** — `lazy`/`getLazy` and `freezeOnBlur` control when a
|
|
30
|
+
scene mounts and whether it keeps rendering in the background.
|
|
31
|
+
- **Rich tab metadata** — labels, badges, tints, SF Symbols, named icons, image
|
|
32
|
+
sources, hidden tabs, test IDs and roles.
|
|
33
|
+
- **Native drawer and Android options** — an optional physical-left menu, a
|
|
34
|
+
floating bar with live blur on Android 16+, ripple and inset controls.
|
|
6
35
|
|
|
7
|
-
## Installation
|
|
36
|
+
## Installation
|
|
8
37
|
|
|
9
38
|
```sh
|
|
10
|
-
yarn add @onekeyfe/react-native-bottom-tabs
|
|
39
|
+
yarn add @onekeyfe/react-native-bottom-tabs @onekeyfe/react-native-image
|
|
11
40
|
```
|
|
12
41
|
|
|
13
|
-
|
|
14
|
-
|
|
42
|
+
Peer dependencies: `react`, `react-native` and `@onekeyfe/react-native-image`,
|
|
43
|
+
which provides the native SVG decoder for named and SVG tab icons. The package
|
|
44
|
+
registers native views, so install the app's iOS pods and rebuild the native
|
|
45
|
+
binary; a JavaScript-only install does not register the tab bar:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
cd ios && pod install
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Android links through autolinking; deployment floors are iOS 15.1 and Android
|
|
52
|
+
API 24.
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
15
55
|
|
|
16
56
|
```tsx
|
|
17
57
|
import { useState } from 'react';
|
|
18
58
|
import { Text } from 'react-native';
|
|
19
|
-
import BottomTabs from '@onekeyfe/react-native-bottom-tabs';
|
|
59
|
+
import BottomTabs, { SceneMap } from '@onekeyfe/react-native-bottom-tabs';
|
|
60
|
+
|
|
61
|
+
const HomeScene = () => <Text>Home</Text>;
|
|
62
|
+
const SettingsScene = () => <Text>Settings</Text>;
|
|
20
63
|
|
|
21
|
-
const
|
|
64
|
+
const renderScene = SceneMap({ home: HomeScene, settings: SettingsScene });
|
|
22
65
|
|
|
23
|
-
|
|
66
|
+
const routes = [
|
|
67
|
+
{ key: 'home', title: 'Home' },
|
|
68
|
+
{ key: 'settings', title: 'Settings', badge: '3' },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export function AppTabs() {
|
|
24
72
|
const [index, setIndex] = useState(0);
|
|
25
73
|
return (
|
|
26
74
|
<BottomTabs
|
|
27
75
|
navigationState={{ index, routes }}
|
|
28
76
|
onIndexChange={setIndex}
|
|
29
|
-
renderScene={
|
|
77
|
+
renderScene={renderScene}
|
|
30
78
|
/>
|
|
31
79
|
);
|
|
32
80
|
}
|
|
33
81
|
```
|
|
34
82
|
|
|
35
|
-
|
|
36
|
-
the
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
`
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
The application owns routes, selection state and scene content; the native view
|
|
84
|
+
owns the tab bar, gestures and scene freezing. Keep the `routes` array stable
|
|
85
|
+
unless the route definitions actually change.
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### Exports
|
|
90
|
+
|
|
91
|
+
| Export | Platforms | Description |
|
|
92
|
+
| --- | :-: | --- |
|
|
93
|
+
| `BottomTabs` (default) | iOS, Android | Controlled native tab container and scene host. |
|
|
94
|
+
| `SceneMap` | iOS, Android | Builds a `renderScene` function from a route-key → component map. |
|
|
95
|
+
| `useBottomTabBarHeight()` | iOS, Android | Native tab-bar height in logical units (`0` while hidden); must be inside the tab container. |
|
|
96
|
+
| `BottomTabBarHeightContext` | iOS, Android | Context that provides the same height to scene content. |
|
|
97
|
+
| `AppleIcon`, `NamedIcon`, `BottomTabIconSource`, `TabRole`, `TabBarPlacement` | iOS, Android | Icon and tab typing helpers, including `{ sfSymbol }` and `{ iconName }`. |
|
|
98
|
+
|
|
99
|
+
### `BottomTabs` props
|
|
100
|
+
|
|
101
|
+
| Prop | Type | Platforms | Description |
|
|
102
|
+
| --- | --- | :-: | --- |
|
|
103
|
+
| `navigationState`, `renderScene` | `{ index, routes }`, function | iOS, Android | Required selected index, keyed routes and scene renderer. |
|
|
104
|
+
| `onIndexChange`, `onTabDoublePress` | callbacks | iOS, Android | Tab change; second press on the selected tab within the platform double-tap timeout. |
|
|
105
|
+
| `renderLazyPlaceholder`, `getLazy`, `getFreezeOnBlur`, `getSceneStyle` | functions | iOS, Android | Lazy placeholder, per-route lazy/freeze and scene style. |
|
|
106
|
+
| `getLabelText`, `getBadge`, `getIcon`, `getHidden`, `getTestID`, `getActiveTintColor` | functions | iOS, Android | Per-route metadata and tint resolvers; each defaults to the matching route field. |
|
|
107
|
+
| `getRole` | function | iOS | System search-tab role. |
|
|
108
|
+
| `getBadgeBackgroundColor`, `getBadgeTextColor` | functions | Android | Badge background and text colors. |
|
|
109
|
+
| `tabBar`, `tabBarStyle`, `tabLabelStyle`, `tabBarActiveTintColor`, `tabBarInactiveTintColor` | component/props | iOS, Android | Custom JS bar replacing the native bar, plus bar background, label font and tints. |
|
|
110
|
+
| `tabBarHidden`, `labeled`, `hapticFeedbackEnabled`, `delayedFreeze` | `boolean` | iOS, Android | Visibility, labels, haptics and delayed freeze/unfreeze. |
|
|
111
|
+
| `translucent`, `disablePageAnimations`, `sidebarAdaptable`, `scrollEdgeAppearance` | platform options | iOS | Translucency, page animations, adaptable/sidebar style and scroll-edge appearance. |
|
|
112
|
+
| `minimizeBehavior`, `renderBottomAccessoryView` | options | iOS 26+ | Tab-bar minimizing behavior and an accessory view above the bar. |
|
|
113
|
+
| `onTabBarPlacementChange`, `sideAccessoryIcon`, `onSideAccessoryPress` | event/style props | iOS | Vertical placement (iPhone Duo) and its side accessory button. |
|
|
114
|
+
| `androidTabBarStyle`, `androidBottomBlurEnabled` | platform props | Android | Material docked or floating capsule bar; live blur defaults on for Android 16+. |
|
|
115
|
+
| `rippleColor`, `activeIndicatorColor`, `ignoreBottomInsets`, `ignoreKeyboardInsets` | platform props | Android | Ripple, indicator, navigation-bar and keyboard inset controls. |
|
|
116
|
+
| `renderDrawerContent`, `drawerOpen`, `drawerSwipeEnabled`, `onDrawerOpenChange` | drawer props | iOS, Android | Optional native left drawer and its controlled state. |
|
|
117
|
+
|
|
118
|
+
Route fields such as `title`, `badge`, `focusedIcon`, `unfocusedIcon`, `lazy`,
|
|
119
|
+
`hidden`, `role`, `preventsDefault` and `freezeOnBlur` mirror the resolvers above;
|
|
120
|
+
see [`src/types.ts`](src/types.ts) and [`src/BottomTabs.tsx`](src/BottomTabs.tsx).
|
|
121
|
+
|
|
122
|
+
## Platform support
|
|
123
|
+
|
|
124
|
+
| Capability | iOS | Android |
|
|
125
|
+
| --- | :-: | :-: |
|
|
126
|
+
| Native tab bar, selection and scenes | ✅ | ✅ |
|
|
127
|
+
| Lazy scenes and freeze-on-blur | ✅ | ✅ |
|
|
128
|
+
| Labels, badges and icon sources | ✅ | ✅ |
|
|
129
|
+
| Native left drawer | ✅ | ✅ |
|
|
130
|
+
| Double press with scroll-to-top | ✅ | ✅ |
|
|
131
|
+
| Floating capsule bar and live background blur | — | ✅ |
|
|
132
|
+
| Bottom accessory view, minimize behavior, vertical placement | ✅ iOS 26+ | — |
|
|
133
|
+
|
|
134
|
+
## Caveats
|
|
135
|
+
|
|
136
|
+
> [!WARNING]
|
|
137
|
+
> This package has no Web implementation. It targets the iOS and Android native
|
|
138
|
+
> tab bar only; do not mount it in a Web bundle.
|
|
139
|
+
|
|
140
|
+
> [!IMPORTANT]
|
|
141
|
+
> Android supports at most 100 tabs. Routes beyond the first 100 are dropped with
|
|
142
|
+
> a console warning, so keep the navigation state within that bound.
|
|
143
|
+
|
|
144
|
+
> [!NOTE]
|
|
145
|
+
> Tab long press is not supported: `onTabLongPress` and the native long-press
|
|
146
|
+
> recognizers were removed. Use `onTabDoublePress` for a second press on the
|
|
147
|
+
> already selected tab.
|
|
148
|
+
|
|
149
|
+
## References
|
|
150
|
+
|
|
151
|
+
- [Behavioral contract](docs/SPEC.md)
|
|
152
|
+
- Example pages: [test page](../../example/react-native/pages/BottomTabsTestPage.tsx)
|
|
153
|
+
and [drawer page](../../example/react-native/pages/BottomTabsHomeDrawerExample.tsx)
|
|
154
|
+
- [npm package](https://www.npmjs.com/package/@onekeyfe/react-native-bottom-tabs)
|
|
155
|
+
- [Changelog](../../CHANGELOG.md)
|
|
64
156
|
|
|
65
157
|
## Upstream attribution
|
|
66
158
|
|
|
@@ -80,16 +172,15 @@ unable to keep this work in patch form.
|
|
|
80
172
|
As the gap grew, we ultimately forked `react-native-bottom-tabs` to keep
|
|
81
173
|
development and delivery stable.
|
|
82
174
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- Repository: [okwasniewski/react-native-bottom-tabs](https://github.com/okwasniewski/react-native-bottom-tabs)
|
|
175
|
+
- Upstream repository:
|
|
176
|
+
[okwasniewski/react-native-bottom-tabs](https://github.com/okwasniewski/react-native-bottom-tabs)
|
|
86
177
|
- License: MIT
|
|
87
|
-
|
|
88
|
-
## Notes
|
|
89
|
-
|
|
90
178
|
- This fork includes OneKey-specific adaptations for our product requirements.
|
|
91
|
-
-
|
|
92
|
-
to the upstream repository.
|
|
179
|
+
- For original behavior and full documentation, refer to the upstream repository.
|
|
93
180
|
|
|
94
181
|
Thank you again to Oskar Kwaśniewski and everyone who contributes to
|
|
95
182
|
`react-native-bottom-tabs` 💙
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -23,6 +23,11 @@ class BottomTabsDrawerManager : ViewGroupManager<BottomTabsDrawerView>(),
|
|
|
23
23
|
DrawerOpenChangeEvent(UIManagerHelper.getSurfaceId(context), view.id, open),
|
|
24
24
|
)
|
|
25
25
|
}
|
|
26
|
+
view.onDrawerProgress = { progress ->
|
|
27
|
+
UIManagerHelper.getEventDispatcherForReactTag(context, view.id)?.dispatchEvent(
|
|
28
|
+
DrawerProgressEvent(UIManagerHelper.getSurfaceId(context), view.id, progress),
|
|
29
|
+
)
|
|
30
|
+
}
|
|
26
31
|
return view
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -36,6 +41,7 @@ class BottomTabsDrawerManager : ViewGroupManager<BottomTabsDrawerView>(),
|
|
|
36
41
|
override fun needsCustomLayoutForChildren() = true
|
|
37
42
|
override fun onDropViewInstance(view: BottomTabsDrawerView) {
|
|
38
43
|
view.onDrawerOpenChange = null
|
|
44
|
+
view.onDrawerProgress = null
|
|
39
45
|
view.dispose()
|
|
40
46
|
super.onDropViewInstance(view)
|
|
41
47
|
}
|
|
@@ -45,6 +51,8 @@ class BottomTabsDrawerManager : ViewGroupManager<BottomTabsDrawerView>(),
|
|
|
45
51
|
override fun setSwipeEnabled(view: BottomTabsDrawerView, value: Boolean) { view.swipeEnabled = value }
|
|
46
52
|
override fun setHapticFeedbackEnabled(view: BottomTabsDrawerView, value: Boolean) { view.drawerHapticFeedbackEnabled = value }
|
|
47
53
|
override fun setBottomBarHeight(view: BottomTabsDrawerView, value: Double) { view.bottomBarHeight = value.toFloat() }
|
|
54
|
+
override fun setColorScheme(view: BottomTabsDrawerView, value: String?) { view.colorScheme = value ?: "system" }
|
|
55
|
+
override fun setProgressEventsEnabled(view: BottomTabsDrawerView, value: Boolean) { view.progressEventsEnabled = value }
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
private class DrawerOpenChangeEvent(surfaceId: Int, tag: Int, private val open: Boolean) :
|
|
@@ -53,3 +61,10 @@ private class DrawerOpenChangeEvent(surfaceId: Int, tag: Int, private val open:
|
|
|
53
61
|
override fun canCoalesce() = false
|
|
54
62
|
override fun getEventData() = Arguments.createMap().apply { putBoolean("open", open) }
|
|
55
63
|
}
|
|
64
|
+
|
|
65
|
+
// Coalescable: a JS listener only needs the latest position per frame.
|
|
66
|
+
private class DrawerProgressEvent(surfaceId: Int, tag: Int, private val progress: Float) :
|
|
67
|
+
Event<DrawerProgressEvent>(surfaceId, tag) {
|
|
68
|
+
override fun getEventName() = "onDrawerProgress"
|
|
69
|
+
override fun getEventData() = Arguments.createMap().apply { putDouble("progress", progress.toDouble()) }
|
|
70
|
+
}
|