@soundtrackio/react-native-bottom-tabs 1.4.0
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 +32 -0
- package/android/build.gradle +132 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/rcttabview/ImageSource.kt +86 -0
- package/android/src/main/java/com/rcttabview/LatestRequestTracker.kt +19 -0
- package/android/src/main/java/com/rcttabview/RCTTabView.kt +689 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewManager.kt +222 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewPackage.kt +19 -0
- package/android/src/main/java/com/rcttabview/RCTTabViewPrewarm.kt +40 -0
- package/android/src/main/java/com/rcttabview/RebuildBatch.kt +31 -0
- package/android/src/main/java/com/rcttabview/TabBarVisibility.kt +14 -0
- package/android/src/main/java/com/rcttabview/Utils.kt +31 -0
- package/android/src/main/java/com/rcttabview/events/OnNativeLayoutEvent.kt +25 -0
- package/android/src/main/java/com/rcttabview/events/OnTabBarMeasuredEvent.kt +24 -0
- package/android/src/main/java/com/rcttabview/events/PageSelectedEvent.kt +32 -0
- package/android/src/main/java/com/rcttabview/events/TabLongPressedEvent.kt +24 -0
- package/android/src/test/java/com/rcttabview/LatestRequestTrackerTest.kt +37 -0
- package/android/src/test/java/com/rcttabview/RebuildBatchTest.kt +44 -0
- package/android/src/test/java/com/rcttabview/TabBarVisibilityTest.kt +58 -0
- package/app.plugin.js +1 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewComponentDescriptor.h +33 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.cpp +19 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewShadowNode.h +35 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.cpp +15 -0
- package/common/cpp/react/renderer/components/RNCTabView/RNCTabViewState.h +25 -0
- package/ios/BottomAccessoryProvider.swift +27 -0
- package/ios/Extensions.swift +101 -0
- package/ios/PlatformAliases.swift +43 -0
- package/ios/RCTBottomAccessoryComponentView.h +17 -0
- package/ios/RCTBottomAccessoryComponentView.mm +76 -0
- package/ios/RCTTabViewComponentView.h +16 -0
- package/ios/RCTTabViewComponentView.mm +285 -0
- package/ios/RepresentableView.swift +55 -0
- package/ios/SVG/CoreSVG.h +19 -0
- package/ios/SVG/CoreSVG.mm +177 -0
- package/ios/SVG/SvgDecoder.h +10 -0
- package/ios/SVG/SvgDecoder.mm +38 -0
- package/ios/TabAppearModifier.swift +38 -0
- package/ios/TabBarFontSize.swift +88 -0
- package/ios/TabItem.swift +35 -0
- package/ios/TabItemEventModifier.swift +163 -0
- package/ios/TabView/AnyTabView.swift +7 -0
- package/ios/TabView/LegacyTabView.swift +70 -0
- package/ios/TabView/NewTabView.swift +138 -0
- package/ios/TabViewImpl.swift +566 -0
- package/ios/TabViewProps.swift +109 -0
- package/ios/TabViewProvider.swift +368 -0
- package/ios/react-native-bottom-tabs-Bridging-Header.h +4 -0
- package/lib/module/BottomAccessoryView.js +47 -0
- package/lib/module/BottomAccessoryView.js.map +1 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +27 -0
- package/lib/module/DelayedFreeze.js +31 -0
- package/lib/module/DelayedFreeze.js.map +1 -0
- package/lib/module/NativeSVGDecoder.js +5 -0
- package/lib/module/NativeSVGDecoder.js.map +1 -0
- package/lib/module/SceneMap.js +28 -0
- package/lib/module/SceneMap.js.map +1 -0
- package/lib/module/TabView.js +294 -0
- package/lib/module/TabView.js.map +1 -0
- package/lib/module/TabViewNativeComponent.ts +73 -0
- package/lib/module/expo.js +35 -0
- package/lib/module/expo.js.map +1 -0
- package/lib/module/index.js +20 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/BottomTabBarHeightContext.js +5 -0
- package/lib/module/utils/BottomTabBarHeightContext.js.map +1 -0
- package/lib/module/utils/useBottomTabBarHeight.js +12 -0
- package/lib/module/utils/useBottomTabBarHeight.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/BottomAccessoryView.d.ts +7 -0
- package/lib/typescript/src/BottomAccessoryView.d.ts.map +1 -0
- package/lib/typescript/src/BottomAccessoryView.js +24 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +15 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.js +4 -0
- package/lib/typescript/src/DelayedFreeze.d.ts +7 -0
- package/lib/typescript/src/DelayedFreeze.d.ts.map +1 -0
- package/lib/typescript/src/DelayedFreeze.js +21 -0
- package/lib/typescript/src/NativeSVGDecoder.d.ts +5 -0
- package/lib/typescript/src/NativeSVGDecoder.d.ts.map +1 -0
- package/lib/typescript/src/NativeSVGDecoder.js +2 -0
- package/lib/typescript/src/SceneMap.d.ts +9 -0
- package/lib/typescript/src/SceneMap.d.ts.map +1 -0
- package/lib/typescript/src/SceneMap.js +15 -0
- package/lib/typescript/src/TabView.d.ts +219 -0
- package/lib/typescript/src/TabView.d.ts.map +1 -0
- package/lib/typescript/src/TabView.js +157 -0
- package/lib/typescript/src/TabViewNativeComponent.d.ts +59 -0
- package/lib/typescript/src/TabViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/TabViewNativeComponent.js +4 -0
- package/lib/typescript/src/expo.d.ts +6 -0
- package/lib/typescript/src/expo.d.ts.map +1 -0
- package/lib/typescript/src/expo.js +34 -0
- package/lib/typescript/src/index.d.ts +15 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.js +11 -0
- package/lib/typescript/src/types.d.ts +31 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/types.js +1 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts +2 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.d.ts.map +1 -0
- package/lib/typescript/src/utils/BottomTabBarHeightContext.js +2 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts +1 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.d.ts.map +1 -0
- package/lib/typescript/src/utils/useBottomTabBarHeight.js +9 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -0
- package/package.json +135 -0
- package/react-native-bottom-tabs.podspec +43 -0
- package/src/BottomAccessoryView.tsx +59 -0
- package/src/BottomAccessoryViewNativeComponent.ts +27 -0
- package/src/DelayedFreeze.tsx +31 -0
- package/src/NativeSVGDecoder.ts +5 -0
- package/src/SceneMap.tsx +34 -0
- package/src/TabView.tsx +558 -0
- package/src/TabViewNativeComponent.ts +73 -0
- package/src/expo.ts +58 -0
- package/src/index.tsx +23 -0
- package/src/types.ts +36 -0
- package/src/utils/BottomTabBarHeightContext.ts +5 -0
- package/src/utils/useBottomTabBarHeight.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
React Native Bottom Tabs
|
|
3
|
+
</h1>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<strong>Bottom Tabs that use native platform primitives.</strong><br>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
|
|
11
|
+
[](https://github.com/okwasniewski/react-native-bottom-tabs/blob/main/LICENSE)
|
|
12
|
+
[](https://www.npmjs.org/package/react-native-bottom-tabs)
|
|
13
|
+
[](https://www.npmjs.org/package/react-native-bottom-tabs)
|
|
14
|
+
[](https://www.npmjs.org/package/react-native-bottom-tabs)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
The full documentation can be found on our [website](https://callstackincubator.github.io/react-native-bottom-tabs/).
|
|
21
|
+
|
|
22
|
+
## Contributing
|
|
23
|
+
|
|
24
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
Made with ❤️ and [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RCTTabView_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
|
|
23
|
+
// itself. Applying the Kotlin plugin on top of it fails configuration with
|
|
24
|
+
// "Cannot add extension with name 'kotlin'". Only apply it when nothing has
|
|
25
|
+
// registered that extension yet.
|
|
26
|
+
if (project.extensions.findByName('kotlin') == null) {
|
|
27
|
+
apply plugin: "kotlin-android"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
apply plugin: "kotlin-kapt"
|
|
31
|
+
|
|
32
|
+
if (isNewArchitectureEnabled()) {
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def getExtOrDefault(name) {
|
|
37
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RCTTabView_" + name]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def getExtOrIntegerDefault(name) {
|
|
41
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RCTTabView_" + name]).toInteger()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
def supportsNamespace() {
|
|
45
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
46
|
+
def major = parsed[0].toInteger()
|
|
47
|
+
def minor = parsed[1].toInteger()
|
|
48
|
+
|
|
49
|
+
// Namespace support was added in 7.3.0
|
|
50
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
android {
|
|
54
|
+
if (supportsNamespace()) {
|
|
55
|
+
namespace "com.rcttabview"
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
65
|
+
|
|
66
|
+
defaultConfig {
|
|
67
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
68
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
69
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
buildFeatures {
|
|
74
|
+
buildConfig true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
buildTypes {
|
|
78
|
+
release {
|
|
79
|
+
minifyEnabled false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
lintOptions {
|
|
84
|
+
disable "GradleCompatible"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
compileOptions {
|
|
88
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
89
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
sourceSets {
|
|
93
|
+
main {
|
|
94
|
+
java.srcDirs += [
|
|
95
|
+
// Codegen specs
|
|
96
|
+
"generated/java",
|
|
97
|
+
"generated/jni"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
repositories {
|
|
104
|
+
mavenCentral()
|
|
105
|
+
google()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
109
|
+
|
|
110
|
+
dependencies {
|
|
111
|
+
def COIL_VERSION = "3.0.2"
|
|
112
|
+
// For < 0.71, this will be from the local maven repo
|
|
113
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
114
|
+
//noinspection GradleDynamicVersion
|
|
115
|
+
implementation "com.facebook.react:react-native:+"
|
|
116
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
117
|
+
implementation 'com.google.android.material:material:1.14.0-alpha05'
|
|
118
|
+
|
|
119
|
+
implementation("io.coil-kt.coil3:coil:${COIL_VERSION}")
|
|
120
|
+
implementation("io.coil-kt.coil3:coil-network-okhttp:${COIL_VERSION}")
|
|
121
|
+
implementation("io.coil-kt.coil3:coil-svg:${COIL_VERSION}")
|
|
122
|
+
|
|
123
|
+
testImplementation "junit:junit:4.13.2"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (isNewArchitectureEnabled()) {
|
|
127
|
+
react {
|
|
128
|
+
jsRootDir = file("../src/")
|
|
129
|
+
libraryName = "RNCTabView"
|
|
130
|
+
codegenJavaPackageName = "com.rcttabview"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.rcttabview
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.net.Uri
|
|
6
|
+
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper
|
|
7
|
+
import java.util.Locale
|
|
8
|
+
|
|
9
|
+
data class ImageSource(
|
|
10
|
+
val context: Context,
|
|
11
|
+
val uri: String? = null,
|
|
12
|
+
) {
|
|
13
|
+
private fun isLocalResourceUri(uri: Uri?) = uri?.scheme?.startsWith("res") ?: false
|
|
14
|
+
|
|
15
|
+
fun getUri(context: Context): Uri? {
|
|
16
|
+
val uri = computeUri(context)
|
|
17
|
+
|
|
18
|
+
if (isLocalResourceUri(uri)) {
|
|
19
|
+
return Uri.parse(
|
|
20
|
+
uri!!.toString().replace("res:/", "android.resource://" + context.packageName + "/")
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return uri
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private fun computeUri(context: Context): Uri? {
|
|
28
|
+
val stringUri = uri ?: return null
|
|
29
|
+
return try {
|
|
30
|
+
val uri: Uri = Uri.parse(stringUri)
|
|
31
|
+
// Verify scheme is set, so that relative uri (used by static resources) are not handled.
|
|
32
|
+
if (uri.scheme == null) {
|
|
33
|
+
computeLocalUri(stringUri, context)
|
|
34
|
+
} else {
|
|
35
|
+
uri
|
|
36
|
+
}
|
|
37
|
+
} catch (e: Exception) {
|
|
38
|
+
computeLocalUri(stringUri, context)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun computeLocalUri(stringUri: String, context: Context): Uri? {
|
|
43
|
+
return ResourceIdHelper.getResourceUri(context, stringUri)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Taken from https://github.com/expo/expo/blob/sdk-52/packages/expo-image/android/src/main/java/expo/modules/image/ResourceIdHelper.kt
|
|
48
|
+
object ResourceIdHelper {
|
|
49
|
+
private val idMap = mutableMapOf<String, Int>()
|
|
50
|
+
|
|
51
|
+
@SuppressLint("DiscouragedApi")
|
|
52
|
+
private fun getResourceRawId(context: Context, name: String): Int {
|
|
53
|
+
if (name.isEmpty()) {
|
|
54
|
+
return -1
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
val normalizedName = name.lowercase(Locale.ROOT).replace("-", "_")
|
|
58
|
+
synchronized(this) {
|
|
59
|
+
val id = idMap[normalizedName]
|
|
60
|
+
if (id != null) {
|
|
61
|
+
return id
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return context
|
|
65
|
+
.resources
|
|
66
|
+
.getIdentifier(normalizedName, "raw", context.packageName)
|
|
67
|
+
.also {
|
|
68
|
+
idMap[normalizedName] = it
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fun getResourceUri(context: Context, name: String): Uri? {
|
|
74
|
+
val drawableUri = ResourceDrawableIdHelper.getInstance().getResourceDrawableUri(context, name)
|
|
75
|
+
if (drawableUri != Uri.EMPTY) {
|
|
76
|
+
return drawableUri
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
val resId = getResourceRawId(context, name)
|
|
80
|
+
return if (resId > 0) {
|
|
81
|
+
Uri.Builder().scheme("res").path(resId.toString()).build()
|
|
82
|
+
} else {
|
|
83
|
+
null
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.rcttabview
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hands out increasing ids for requests made per key and tells whether an id is still the
|
|
5
|
+
* newest one issued for its key, so work that finishes asynchronously and out of order can
|
|
6
|
+
* apply only the result of the most recent request.
|
|
7
|
+
*/
|
|
8
|
+
class LatestRequestTracker<K> {
|
|
9
|
+
private val latestIds = mutableMapOf<K, Int>()
|
|
10
|
+
private var nextId = 0
|
|
11
|
+
|
|
12
|
+
fun begin(key: K): Int {
|
|
13
|
+
val id = ++nextId
|
|
14
|
+
latestIds[key] = id
|
|
15
|
+
return id
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun isLatest(key: K, id: Int): Boolean = latestIds[key] == id
|
|
19
|
+
}
|