@onekeyfe/react-native-bottom-tabs 0.0.0-stage → 6.7.0-alpha.339
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/LICENSE +46 -0
- package/README.md +86 -2
- package/android/build.gradle +119 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsPackage.kt +16 -0
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +1419 -0
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsViewManager.kt +216 -0
- package/android/src/main/java/com/onekey/bottomtabs/FloatingTabBarStyle.kt +50 -0
- package/android/src/main/java/com/onekey/bottomtabs/ImageSource.kt +86 -0
- package/android/src/main/java/com/onekey/bottomtabs/TabInfo.kt +13 -0
- package/android/src/main/java/com/onekey/bottomtabs/Utils.kt +31 -0
- package/android/src/main/java/com/onekey/bottomtabs/events/OnNativeLayoutEvent.kt +20 -0
- package/android/src/main/java/com/onekey/bottomtabs/events/OnTabBarMeasuredEvent.kt +19 -0
- package/android/src/main/java/com/onekey/bottomtabs/events/PageSelectedEvent.kt +21 -0
- package/android/src/main/java/com/onekey/bottomtabs/events/TabDoublePressEvent.kt +19 -0
- package/common/cpp/react/renderer/components/RNBottomTabs/RNBottomTabsViewComponentDescriptor.h +32 -0
- package/common/cpp/react/renderer/components/RNBottomTabs/RNBottomTabsViewShadowNode.cpp +18 -0
- package/common/cpp/react/renderer/components/RNBottomTabs/RNBottomTabsViewShadowNode.h +35 -0
- package/common/cpp/react/renderer/components/RNBottomTabs/RNBottomTabsViewState.cpp +15 -0
- package/common/cpp/react/renderer/components/RNBottomTabs/RNBottomTabsViewState.h +25 -0
- package/docs/SPEC.md +101 -0
- package/ios/Extensions.swift +46 -0
- package/ios/RCTBottomAccessoryComponentView.h +12 -0
- package/ios/RCTBottomAccessoryComponentView.mm +67 -0
- package/ios/RCTBottomAccessoryContainerView.swift +51 -0
- package/ios/RCTBottomTabsComponentView.h +12 -0
- package/ios/RCTBottomTabsComponentView.mm +338 -0
- package/ios/RCTBottomTabsContainerView.swift +777 -0
- package/ios/RCTBottomTabsLog.h +7 -0
- package/ios/RCTBottomTabsLog.m +32 -0
- package/ios/SVG/CoreSVG.h +13 -0
- package/ios/SVG/CoreSVG.mm +177 -0
- package/ios/SVG/SvgDecoder.h +10 -0
- package/ios/SVG/SvgDecoder.mm +32 -0
- package/ios/TabBarFontSize.swift +55 -0
- package/lib/module/BottomAccessoryView.js +45 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +27 -0
- package/lib/module/BottomTabs.js +323 -0
- package/lib/module/BottomTabsNativeComponent.ts +69 -0
- package/lib/module/DelayedFreeze.js +31 -0
- package/lib/module/NativeSVGDecoder.js +5 -0
- package/lib/module/SceneMap.js +28 -0
- package/lib/module/codegen-types.d.js +2 -0
- package/lib/module/index.js +20 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/utils/BottomTabBarHeightContext.js +5 -0
- package/lib/module/utils/useBottomTabBarHeight.js +12 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/BottomAccessoryView.d.ts +8 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +16 -0
- package/lib/typescript/src/BottomTabs.d.ts +202 -0
- package/lib/typescript/src/BottomTabsNativeComponent.d.ts +58 -0
- package/lib/typescript/src/DelayedFreeze.d.ts +9 -0
- package/lib/typescript/src/NativeSVGDecoder.d.ts +6 -0
- package/lib/typescript/src/SceneMap.d.ts +10 -0
- package/lib/typescript/src/index.d.ts +16 -0
- package/lib/typescript/src/types.d.ts +29 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts +3 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts +2 -0
- package/package.json +117 -4
- package/react-native-bottom-tabs.podspec +36 -0
- package/react-native.config.js +13 -0
- package/src/BottomAccessoryView.tsx +58 -0
- package/src/BottomAccessoryViewNativeComponent.ts +27 -0
- package/src/BottomTabs.tsx +545 -0
- package/src/BottomTabsNativeComponent.ts +69 -0
- package/src/DelayedFreeze.tsx +33 -0
- package/src/NativeSVGDecoder.ts +5 -0
- package/src/SceneMap.tsx +34 -0
- package/src/codegen-types.d.ts +28 -0
- package/src/index.tsx +18 -0
- package/src/types.ts +31 -0
- package/src/utils/BottomTabBarHeightContext.ts +5 -0
- package/src/utils/useBottomTabBarHeight.ts +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Callstack
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
The Expo-derived ResourceIdHelper code in android/src/main/java/com/onekey/bottomtabs/ImageSource.kt retains:
|
|
25
|
+
|
|
26
|
+
The MIT License (MIT)
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
|
29
|
+
|
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
31
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
32
|
+
in the Software without restriction, including without limitation the rights
|
|
33
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
34
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
35
|
+
furnished to do so, subject to the following conditions:
|
|
36
|
+
|
|
37
|
+
The above copyright notice and this permission notice shall be included in all
|
|
38
|
+
copies or substantial portions of the Software.
|
|
39
|
+
|
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
42
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
43
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
44
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
45
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
46
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @onekeyfe/react-native-bottom-tabs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native bottom-tab navigation for OneKey React Native applications on iOS and
|
|
4
|
+
Android. The controlled React component receives route state from the caller
|
|
5
|
+
and renders scenes through the application's supplied renderer.
|
|
6
|
+
|
|
7
|
+
## Installation and usage
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @onekeyfe/react-native-bottom-tabs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install the application's iOS pods and rebuild the native application to register
|
|
14
|
+
the bottom tabs. The application owns route definitions and selection state.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import { Text } from 'react-native';
|
|
19
|
+
import BottomTabs from '@onekeyfe/react-native-bottom-tabs';
|
|
20
|
+
|
|
21
|
+
const routes = [{ key: 'home', title: 'Home' }, { key: 'settings', title: 'Settings' }];
|
|
22
|
+
|
|
23
|
+
function Tabs() {
|
|
24
|
+
const [index, setIndex] = useState(0);
|
|
25
|
+
return (
|
|
26
|
+
<BottomTabs
|
|
27
|
+
navigationState={{ index, routes }}
|
|
28
|
+
onIndexChange={setIndex}
|
|
29
|
+
renderScene={({ route }) => <Text>{route.title}</Text>}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Earlier releases were published as `@onekeyfe/react-native-tab-view`, where
|
|
36
|
+
the default export was `TabView` and `onTabLongPress` existed.
|
|
37
|
+
|
|
38
|
+
## State, scenes and platform options
|
|
39
|
+
|
|
40
|
+
`navigationState` contains the selected index and keyed routes. `onIndexChange`
|
|
41
|
+
reports requested tab changes; update state in the caller. Route metadata can
|
|
42
|
+
supply labels, badges and icons. `SceneMap` builds a renderer from stable scene
|
|
43
|
+
components; `useBottomTabBarHeight` and `BottomTabBarHeightContext` expose tab-bar
|
|
44
|
+
height to content under the provider.
|
|
45
|
+
|
|
46
|
+
The default export is `BottomTabs`; `AppleIcon` and `TabRole` are exported types.
|
|
47
|
+
Some appearance and interaction options are platform-specific, including Apple
|
|
48
|
+
symbols and newer iOS tab-bar presentation. Check those options against the
|
|
49
|
+
consumer's supported OS versions rather than assuming identical native layouts.
|
|
50
|
+
|
|
51
|
+
See [src/BottomTabs.tsx](src/BottomTabs.tsx) for component props and
|
|
52
|
+
[src/types.ts](src/types.ts) for route definitions.
|
|
53
|
+
|
|
54
|
+
See [docs/SPEC.md](docs/SPEC.md) for native touch-selection contracts and
|
|
55
|
+
acceptance boundaries.
|
|
56
|
+
|
|
57
|
+
## Upstream attribution
|
|
58
|
+
|
|
59
|
+
First, a sincere thank-you to Oskar Kwaśniewski and the
|
|
60
|
+
`react-native-bottom-tabs` maintainers for their excellent work 🙏
|
|
61
|
+
|
|
62
|
+
This package is built on, and inspired by,
|
|
63
|
+
[okwasniewski/react-native-bottom-tabs](https://github.com/okwasniewski/react-native-bottom-tabs).
|
|
64
|
+
|
|
65
|
+
Our original plan was to keep our customizations as patches on top of upstream
|
|
66
|
+
`react-native-bottom-tabs`.
|
|
67
|
+
|
|
68
|
+
As our product requirements evolved, the scope of those changes outgrew what we
|
|
69
|
+
could reasonably maintain as an upstream patch set. We regret that we were
|
|
70
|
+
unable to keep this work in patch form.
|
|
71
|
+
|
|
72
|
+
As the gap grew, we ultimately forked `react-native-bottom-tabs` to keep
|
|
73
|
+
development and delivery stable.
|
|
74
|
+
|
|
75
|
+
## Upstream Project
|
|
76
|
+
|
|
77
|
+
- Repository: [okwasniewski/react-native-bottom-tabs](https://github.com/okwasniewski/react-native-bottom-tabs)
|
|
78
|
+
- License: MIT
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
- This fork includes OneKey-specific adaptations for our product requirements.
|
|
83
|
+
- If you are looking for original behavior and full documentation, please refer
|
|
84
|
+
to the upstream repository.
|
|
85
|
+
|
|
86
|
+
Thank you again to Oskar Kwaśniewski and everyone who contributes to
|
|
87
|
+
`react-native-bottom-tabs` 💙
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['BottomTabs_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["BottomTabs_kotlinVersion"]
|
|
7
|
+
|
|
8
|
+
repositories {
|
|
9
|
+
google()
|
|
10
|
+
mavenCentral()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def isNewArchitectureEnabled() {
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def reactNativeArchitectures() {
|
|
24
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
25
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
apply plugin: "com.android.library"
|
|
29
|
+
apply plugin: "kotlin-android"
|
|
30
|
+
|
|
31
|
+
if (isNewArchitectureEnabled()) {
|
|
32
|
+
apply plugin: "com.facebook.react"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def getExtOrIntegerDefault(name) {
|
|
36
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["BottomTabs_" + name]).toInteger()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def supportsNamespace() {
|
|
40
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
41
|
+
def major = parsed[0].toInteger()
|
|
42
|
+
def minor = parsed[1].toInteger()
|
|
43
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
android {
|
|
47
|
+
if (supportsNamespace()) {
|
|
48
|
+
namespace "com.onekey.bottomtabs"
|
|
49
|
+
|
|
50
|
+
sourceSets {
|
|
51
|
+
main {
|
|
52
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
58
|
+
|
|
59
|
+
defaultConfig {
|
|
60
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
61
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
62
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
buildFeatures {
|
|
66
|
+
buildConfig true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
buildTypes {
|
|
70
|
+
release {
|
|
71
|
+
minifyEnabled false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
lintOptions {
|
|
76
|
+
disable "GradleCompatible"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
compileOptions {
|
|
80
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
81
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
sourceSets {
|
|
85
|
+
main {
|
|
86
|
+
java.srcDirs += [
|
|
87
|
+
// Codegen specs
|
|
88
|
+
"generated/java",
|
|
89
|
+
"generated/jni"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
repositories {
|
|
96
|
+
mavenCentral()
|
|
97
|
+
google()
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
101
|
+
def COIL_VERSION = "3.0.2"
|
|
102
|
+
|
|
103
|
+
dependencies {
|
|
104
|
+
implementation "com.facebook.react:react-android"
|
|
105
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
106
|
+
implementation 'com.google.android.material:material:1.14.0-alpha05'
|
|
107
|
+
|
|
108
|
+
implementation("io.coil-kt.coil3:coil:${COIL_VERSION}")
|
|
109
|
+
implementation("io.coil-kt.coil3:coil-network-okhttp:${COIL_VERSION}")
|
|
110
|
+
implementation("io.coil-kt.coil3:coil-svg:${COIL_VERSION}")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (isNewArchitectureEnabled()) {
|
|
114
|
+
react {
|
|
115
|
+
jsRootDir = file("../src/")
|
|
116
|
+
libraryName = "RNBottomTabs"
|
|
117
|
+
codegenJavaPackageName = "com.onekey.bottomtabs"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.onekey.bottomtabs
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class BottomTabsPackage : ReactPackage {
|
|
9
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
10
|
+
return listOf(BottomTabsViewManager(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|