@onekeyfe/react-native-bottom-tabs 6.7.0-20 → 6.7.0-22
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/android/build.gradle +1 -1
- package/android/src/main/java/com/onekey/bottomtabs/BottomBarBlurRenderer.kt +50 -30
- package/android/src/main/java/com/onekey/bottomtabs/BottomTabsView.kt +82 -11
- package/android/src/main/java/com/onekey/bottomtabs/SharedSvgDecoder.kt +51 -0
- package/docs/SPEC.md +69 -18
- package/ios/RCTBottomAccessoryContainerView.swift +2 -0
- package/ios/RCTBottomTabsContainerView.swift +216 -12
- package/ios/SVG/SvgDecoder.mm +7 -3
- package/ios/TabBarFontSize.swift +2 -0
- package/lib/module/BottomAccessoryViewNativeComponent.ts +10 -10
- package/lib/module/BottomTabs.js +77 -53
- package/lib/module/BottomTabsDrawerNativeComponent.ts +12 -12
- package/lib/module/BottomTabsNativeComponent.ts +22 -23
- package/lib/typescript/src/BottomAccessoryView.d.ts +1 -1
- package/lib/typescript/src/BottomAccessoryViewNativeComponent.d.ts +6 -7
- package/lib/typescript/src/BottomTabs.d.ts +12 -6
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.d.ts +8 -9
- package/lib/typescript/src/BottomTabsDrawerNativeComponent.web.d.ts +1 -1
- package/lib/typescript/src/BottomTabsNativeComponent.d.ts +15 -16
- package/lib/typescript/src/DelayedFreeze.d.ts +1 -1
- package/lib/typescript/src/SceneMap.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +6 -2
- package/package.json +5 -4
- package/react-native-bottom-tabs.podspec +2 -0
- package/src/BottomAccessoryViewNativeComponent.ts +10 -10
- package/src/BottomTabs.tsx +111 -54
- package/src/BottomTabsDrawerNativeComponent.ts +12 -12
- package/src/BottomTabsNativeComponent.ts +22 -23
- package/src/index.tsx +7 -1
- package/src/types.ts +10 -2
- package/ios/SVG/CoreSVG.h +0 -13
- package/ios/SVG/CoreSVG.mm +0 -177
package/android/build.gradle
CHANGED
|
@@ -107,7 +107,7 @@ dependencies {
|
|
|
107
107
|
|
|
108
108
|
implementation("io.coil-kt.coil3:coil:${COIL_VERSION}")
|
|
109
109
|
implementation("io.coil-kt.coil3:coil-network-okhttp:${COIL_VERSION}")
|
|
110
|
-
implementation("
|
|
110
|
+
implementation project(":onekeyfe_react-native-image")
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
if (isNewArchitectureEnabled()) {
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
package com.onekey.bottomtabs
|
|
2
2
|
|
|
3
|
-
import android.graphics.BlendMode
|
|
4
3
|
import android.graphics.Canvas
|
|
5
4
|
import android.graphics.Color
|
|
6
|
-
import android.graphics.LinearGradient
|
|
7
5
|
import android.graphics.Paint
|
|
6
|
+
import android.graphics.Path
|
|
8
7
|
import android.graphics.RenderEffect
|
|
9
8
|
import android.graphics.RenderNode
|
|
10
9
|
import android.graphics.Shader
|
|
11
10
|
import androidx.annotation.RequiresApi
|
|
12
11
|
import kotlin.math.ceil
|
|
13
|
-
import kotlin.math.max
|
|
14
12
|
|
|
15
|
-
/** A GPU-only backdrop. The source callback must draw scenes, never this overlay. */
|
|
13
|
+
/** A GPU-only backdrop confined to the tab bar bounds. The source callback must draw scenes, never this overlay. */
|
|
16
14
|
@RequiresApi(31)
|
|
17
15
|
internal class BottomBarBlurRenderer(private val density: Float) {
|
|
18
16
|
private val node = RenderNode("TabBarBackdrop")
|
|
19
17
|
private val tintPaint = Paint()
|
|
20
|
-
private val
|
|
21
|
-
private var
|
|
22
|
-
private var
|
|
18
|
+
private val clipPath = Path()
|
|
19
|
+
private var lastLeft = 0
|
|
20
|
+
private var lastTop = -1
|
|
21
|
+
private var lastRight = 0
|
|
23
22
|
private var lastBottom = 0
|
|
23
|
+
private var lastCornerRadius = -1f
|
|
24
24
|
private var lastTint = Color.TRANSPARENT
|
|
25
|
-
private var fadeTop = 0f
|
|
26
|
-
private var sampleTop = 0f
|
|
27
25
|
|
|
28
26
|
init {
|
|
29
27
|
node.setRenderEffect(RenderEffect.createBlurEffect(
|
|
@@ -35,51 +33,73 @@ internal class BottomBarBlurRenderer(private val density: Float) {
|
|
|
35
33
|
|
|
36
34
|
fun draw(
|
|
37
35
|
canvas: Canvas,
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
left: Int,
|
|
37
|
+
top: Int,
|
|
38
|
+
right: Int,
|
|
40
39
|
bottom: Int,
|
|
40
|
+
cornerRadius: Float,
|
|
41
41
|
tint: Int,
|
|
42
42
|
drawScenes: (Canvas) -> Unit,
|
|
43
43
|
) {
|
|
44
|
-
|
|
44
|
+
val width = right - left
|
|
45
|
+
val height = bottom - top
|
|
46
|
+
if (!canvas.isHardwareAccelerated || width <= 0 || height <= 0) return
|
|
45
47
|
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
if (
|
|
49
|
+
left != lastLeft ||
|
|
50
|
+
top != lastTop ||
|
|
51
|
+
right != lastRight ||
|
|
52
|
+
bottom != lastBottom ||
|
|
53
|
+
cornerRadius != lastCornerRadius ||
|
|
54
|
+
tint != lastTint
|
|
55
|
+
) {
|
|
56
|
+
node.setPosition(0, 0, ceil(width / SCALE).toInt(), ceil(height / SCALE).toInt())
|
|
57
|
+
clipPath.reset()
|
|
58
|
+
if (cornerRadius > 0f) {
|
|
59
|
+
clipPath.addRoundRect(
|
|
60
|
+
left.toFloat(),
|
|
61
|
+
top.toFloat(),
|
|
62
|
+
right.toFloat(),
|
|
63
|
+
bottom.toFloat(),
|
|
64
|
+
cornerRadius,
|
|
65
|
+
cornerRadius,
|
|
66
|
+
Path.Direction.CW,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
54
69
|
val surface = (tint and 0x00ffffff) or (minOf(Color.alpha(tint), 199) shl 24)
|
|
55
70
|
tintPaint.color = surface
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
lastLeft = left
|
|
72
|
+
lastTop = top
|
|
73
|
+
lastRight = right
|
|
58
74
|
lastBottom = bottom
|
|
75
|
+
lastCornerRadius = cornerRadius
|
|
59
76
|
lastTint = tint
|
|
60
77
|
}
|
|
61
78
|
|
|
62
79
|
val recording = node.beginRecording()
|
|
63
80
|
try {
|
|
64
|
-
// Reuse child View display lists.
|
|
81
|
+
// Reuse child View display lists. Only sample the scene region directly behind the bar.
|
|
65
82
|
recording.scale(1f / SCALE, 1f / SCALE)
|
|
66
|
-
recording.translate(
|
|
83
|
+
recording.translate(-left.toFloat(), -top.toFloat())
|
|
67
84
|
recording.drawColor(tint or (0xff shl 24))
|
|
68
85
|
drawScenes(recording)
|
|
69
86
|
} finally {
|
|
70
87
|
node.endRecording()
|
|
71
88
|
}
|
|
72
89
|
|
|
73
|
-
val
|
|
90
|
+
val saveCount = canvas.save()
|
|
91
|
+
if (cornerRadius > 0f) {
|
|
92
|
+
canvas.clipPath(clipPath)
|
|
93
|
+
} else {
|
|
94
|
+
canvas.clipRect(left, top, right, bottom)
|
|
95
|
+
}
|
|
74
96
|
val transform = canvas.save()
|
|
75
|
-
canvas.translate(
|
|
97
|
+
canvas.translate(left.toFloat(), top.toFloat())
|
|
76
98
|
canvas.scale(SCALE, SCALE)
|
|
77
99
|
canvas.drawRenderNode(node)
|
|
78
100
|
canvas.restoreToCount(transform)
|
|
79
|
-
canvas.drawRect(
|
|
80
|
-
|
|
81
|
-
canvas.drawRect(0f, fadeTop, width.toFloat(), bottom.toFloat(), maskPaint)
|
|
82
|
-
canvas.restoreToCount(layer)
|
|
101
|
+
canvas.drawRect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat(), tintPaint)
|
|
102
|
+
canvas.restoreToCount(saveCount)
|
|
83
103
|
}
|
|
84
104
|
|
|
85
105
|
fun release() {
|
|
@@ -9,6 +9,7 @@ import androidx.appcompat.view.ContextThemeWrapper
|
|
|
9
9
|
import android.graphics.Color
|
|
10
10
|
import android.graphics.Canvas
|
|
11
11
|
import android.graphics.Outline
|
|
12
|
+
import android.graphics.drawable.BitmapDrawable
|
|
12
13
|
import android.graphics.drawable.ColorDrawable
|
|
13
14
|
import android.graphics.drawable.Drawable
|
|
14
15
|
import android.graphics.drawable.GradientDrawable
|
|
@@ -39,7 +40,6 @@ import androidx.core.view.forEachIndexed
|
|
|
39
40
|
import coil3.ImageLoader
|
|
40
41
|
import coil3.asDrawable
|
|
41
42
|
import coil3.request.ImageRequest
|
|
42
|
-
import coil3.svg.SvgDecoder
|
|
43
43
|
import coil3.size.Precision
|
|
44
44
|
import coil3.size.Size as CoilSize
|
|
45
45
|
import coil3.size.Scale
|
|
@@ -55,9 +55,12 @@ import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY
|
|
|
55
55
|
import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_LABELED
|
|
56
56
|
import com.google.android.material.navigation.NavigationBarView.LABEL_VISIBILITY_UNLABELED
|
|
57
57
|
import com.google.android.material.transition.platform.MaterialFadeThrough
|
|
58
|
+
import com.margelo.nitro.onekeyimage.OneKeyNamedSVG
|
|
58
59
|
import kotlin.math.abs
|
|
59
60
|
import kotlin.math.roundToInt
|
|
60
61
|
|
|
62
|
+
private const val ONEKEY_ICON_URI_PREFIX = "onekey-icon://"
|
|
63
|
+
|
|
61
64
|
private fun getMaterialContext(context: Context): Context {
|
|
62
65
|
return ContextThemeWrapper(context, com.google.android.material.R.style.Theme_MaterialComponents_DayNight)
|
|
63
66
|
}
|
|
@@ -154,7 +157,14 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
154
157
|
private val floatingRoot = object : FrameLayout(context) {
|
|
155
158
|
override fun drawChild(canvas: Canvas, child: View, drawingTime: Long): Boolean {
|
|
156
159
|
if (child === floatingBar && usesBottomBlur) {
|
|
157
|
-
drawBlurBackdrop(
|
|
160
|
+
drawBlurBackdrop(
|
|
161
|
+
canvas,
|
|
162
|
+
floatingBar.left,
|
|
163
|
+
floatingBar.top,
|
|
164
|
+
floatingBar.right,
|
|
165
|
+
floatingBar.bottom,
|
|
166
|
+
floatingBar.height / 2f,
|
|
167
|
+
) { recording ->
|
|
158
168
|
super.drawChild(recording, layoutHolder, drawingTime)
|
|
159
169
|
}
|
|
160
170
|
}
|
|
@@ -186,6 +196,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
186
196
|
var items: MutableList<TabInfo> = mutableListOf()
|
|
187
197
|
private val iconSources: MutableMap<Int, ImageSource> = mutableMapOf()
|
|
188
198
|
private val drawableCache: MutableMap<ImageSource, Drawable> = mutableMapOf()
|
|
199
|
+
private val iconRequestTokens: MutableMap<Int, Any> = mutableMapOf()
|
|
189
200
|
|
|
190
201
|
private var isLayoutEnqueued = false
|
|
191
202
|
private var selectedItem: String? = null
|
|
@@ -253,7 +264,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
253
264
|
|
|
254
265
|
private val imageLoader = ImageLoader.Builder(context)
|
|
255
266
|
.components {
|
|
256
|
-
add(
|
|
267
|
+
add(SharedSvgDecoder.Factory())
|
|
257
268
|
}
|
|
258
269
|
.build()
|
|
259
270
|
|
|
@@ -459,7 +470,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
459
470
|
drawableCache.clear()
|
|
460
471
|
iconSources.forEach { (index, source) ->
|
|
461
472
|
bottomNavigation.menu.findItem(index)?.let { menuItem ->
|
|
462
|
-
getDrawable(source) { menuItem.icon = it }
|
|
473
|
+
getDrawable(index, source) { menuItem.icon = it }
|
|
463
474
|
}
|
|
464
475
|
}
|
|
465
476
|
}
|
|
@@ -994,18 +1005,31 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
994
1005
|
}
|
|
995
1006
|
|
|
996
1007
|
private fun drawBlurBackdrop(
|
|
997
|
-
canvas: Canvas,
|
|
1008
|
+
canvas: Canvas,
|
|
1009
|
+
left: Int,
|
|
1010
|
+
top: Int,
|
|
1011
|
+
right: Int,
|
|
1012
|
+
bottom: Int,
|
|
1013
|
+
cornerRadius: Float,
|
|
1014
|
+
drawScenes: (Canvas) -> Unit,
|
|
998
1015
|
) {
|
|
999
1016
|
if (!usesBottomBlur || !canvas.isHardwareAccelerated || Build.VERSION.SDK_INT < 31) return
|
|
1000
1017
|
val blur = bottomBarBlur ?: BottomBarBlurRenderer(resources.displayMetrics.density).also {
|
|
1001
1018
|
bottomBarBlur = it
|
|
1002
1019
|
}
|
|
1003
|
-
blur.draw(canvas,
|
|
1020
|
+
blur.draw(canvas, left, top, right, bottom, cornerRadius, blurSurfaceColor, drawScenes)
|
|
1004
1021
|
}
|
|
1005
1022
|
|
|
1006
1023
|
override fun drawChild(canvas: Canvas, child: View, drawingTime: Long): Boolean {
|
|
1007
1024
|
if (child === bottomNavigation && androidTabBarStyle == AndroidTabBarStyle.DEFAULT) {
|
|
1008
|
-
drawBlurBackdrop(
|
|
1025
|
+
drawBlurBackdrop(
|
|
1026
|
+
canvas,
|
|
1027
|
+
bottomNavigation.left,
|
|
1028
|
+
bottomNavigation.top,
|
|
1029
|
+
bottomNavigation.right,
|
|
1030
|
+
bottomNavigation.bottom,
|
|
1031
|
+
0f,
|
|
1032
|
+
) { recording ->
|
|
1009
1033
|
super.drawChild(recording, layoutHolder, drawingTime)
|
|
1010
1034
|
}
|
|
1011
1035
|
}
|
|
@@ -1233,7 +1257,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1233
1257
|
|
|
1234
1258
|
menuItem.isVisible = !item.hidden
|
|
1235
1259
|
if (iconSources.containsKey(index)) {
|
|
1236
|
-
getDrawable(iconSources[index]!!) {
|
|
1260
|
+
getDrawable(index, iconSources[index]!!) {
|
|
1237
1261
|
menuItem.icon = it
|
|
1238
1262
|
}
|
|
1239
1263
|
}
|
|
@@ -1303,7 +1327,7 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1303
1327
|
|
|
1304
1328
|
// Update existing item if exists.
|
|
1305
1329
|
bottomNavigation.menu.findItem(idx)?.let { menuItem ->
|
|
1306
|
-
getDrawable(imageSource) {
|
|
1330
|
+
getDrawable(idx, imageSource) {
|
|
1307
1331
|
menuItem.icon = it
|
|
1308
1332
|
}
|
|
1309
1333
|
}
|
|
@@ -1335,11 +1359,50 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1335
1359
|
}
|
|
1336
1360
|
|
|
1337
1361
|
@SuppressLint("CheckResult")
|
|
1338
|
-
private fun getDrawable(imageSource: ImageSource, onDrawableReady: (Drawable?) -> Unit) {
|
|
1362
|
+
private fun getDrawable(index: Int, imageSource: ImageSource, onDrawableReady: (Drawable?) -> Unit) {
|
|
1363
|
+
iconRequestTokens.remove(index)?.let { OneKeyNamedSVG.cancel(it) }
|
|
1339
1364
|
drawableCache[imageSource]?.let {
|
|
1340
1365
|
onDrawableReady(it)
|
|
1341
1366
|
return
|
|
1342
1367
|
}
|
|
1368
|
+
val rawSource = imageSource.uri.orEmpty()
|
|
1369
|
+
if (rawSource.startsWith(ONEKEY_ICON_URI_PREFIX)) {
|
|
1370
|
+
val iconName = rawSource.removePrefix(ONEKEY_ICON_URI_PREFIX).trim()
|
|
1371
|
+
if (iconName.isEmpty()) {
|
|
1372
|
+
onDrawableReady(null)
|
|
1373
|
+
return
|
|
1374
|
+
}
|
|
1375
|
+
val token = Any()
|
|
1376
|
+
iconRequestTokens[index] = token
|
|
1377
|
+
val iconSizePx = bottomNavigation.itemIconSize.coerceAtLeast(1)
|
|
1378
|
+
val density = resources.displayMetrics.density
|
|
1379
|
+
OneKeyNamedSVG.request(
|
|
1380
|
+
owner = token,
|
|
1381
|
+
assets = context.applicationContext.assets,
|
|
1382
|
+
name = iconName,
|
|
1383
|
+
color = "rgba(0,0,0,1)",
|
|
1384
|
+
width = iconSizePx,
|
|
1385
|
+
height = iconSizePx,
|
|
1386
|
+
scale = density,
|
|
1387
|
+
) { bitmap ->
|
|
1388
|
+
if (iconRequestTokens[index] !== token) {
|
|
1389
|
+
return@request
|
|
1390
|
+
}
|
|
1391
|
+
iconRequestTokens.remove(index)
|
|
1392
|
+
if (bitmap == null) {
|
|
1393
|
+
onDrawableReady(null)
|
|
1394
|
+
return@request
|
|
1395
|
+
}
|
|
1396
|
+
val stateDrawable = BitmapDrawable(context.resources, bitmap)
|
|
1397
|
+
drawableCache[imageSource] = stateDrawable
|
|
1398
|
+
if (iconSources[index] == imageSource) {
|
|
1399
|
+
onDrawableReady(stateDrawable)
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return
|
|
1403
|
+
}
|
|
1404
|
+
val token = Any()
|
|
1405
|
+
iconRequestTokens[index] = token
|
|
1343
1406
|
val iconSizePx = bottomNavigation.itemIconSize
|
|
1344
1407
|
val request = ImageRequest.Builder(context)
|
|
1345
1408
|
.data(imageSource.getUri(context))
|
|
@@ -1348,9 +1411,15 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1348
1411
|
.precision(Precision.EXACT)
|
|
1349
1412
|
.target { drawable ->
|
|
1350
1413
|
post {
|
|
1414
|
+
if (iconRequestTokens[index] !== token) {
|
|
1415
|
+
return@post
|
|
1416
|
+
}
|
|
1417
|
+
iconRequestTokens.remove(index)
|
|
1351
1418
|
val stateDrawable = drawable.asDrawable(context.resources)
|
|
1352
1419
|
drawableCache[imageSource] = stateDrawable
|
|
1353
|
-
|
|
1420
|
+
if (iconSources[index] == imageSource) {
|
|
1421
|
+
onDrawableReady(stateDrawable)
|
|
1422
|
+
}
|
|
1354
1423
|
}
|
|
1355
1424
|
}
|
|
1356
1425
|
.listener(
|
|
@@ -1420,6 +1489,8 @@ class BottomTabsView(context: Context) : LinearLayout(context) {
|
|
|
1420
1489
|
}
|
|
1421
1490
|
|
|
1422
1491
|
fun onDropViewInstance() {
|
|
1492
|
+
iconRequestTokens.values.forEach { OneKeyNamedSVG.cancel(it) }
|
|
1493
|
+
iconRequestTokens.clear()
|
|
1423
1494
|
androidBottomBlurEnabled = false
|
|
1424
1495
|
updateBlurAppearance()
|
|
1425
1496
|
releaseBottomBlur()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.onekey.bottomtabs
|
|
2
|
+
|
|
3
|
+
import coil3.ImageLoader
|
|
4
|
+
import coil3.asImage
|
|
5
|
+
import coil3.decode.DecodeResult
|
|
6
|
+
import coil3.decode.DecodeUtils
|
|
7
|
+
import coil3.decode.Decoder
|
|
8
|
+
import coil3.fetch.SourceFetchResult
|
|
9
|
+
import coil3.request.Options
|
|
10
|
+
import coil3.request.maxBitmapSize
|
|
11
|
+
import com.margelo.nitro.onekeyimage.OneKeySVG
|
|
12
|
+
import kotlinx.coroutines.runInterruptible
|
|
13
|
+
import okio.ByteString.Companion.encodeUtf8
|
|
14
|
+
import kotlin.math.roundToInt
|
|
15
|
+
|
|
16
|
+
/** Coil retains fetching, cancellation and sizing; image owns SVG parsing/rendering. */
|
|
17
|
+
internal class SharedSvgDecoder(private val result: SourceFetchResult, private val options: Options) : Decoder {
|
|
18
|
+
override suspend fun decode(): DecodeResult = runInterruptible {
|
|
19
|
+
val document = result.source.source().inputStream().use { OneKeySVG.decode(it) }
|
|
20
|
+
val width = document.viewBoxWidth ?: document.intrinsicWidth
|
|
21
|
+
val height = document.viewBoxHeight ?: document.intrinsicHeight
|
|
22
|
+
val destination = DecodeUtils.computeDstSize(
|
|
23
|
+
if (width > 0) width.roundToInt() else 512,
|
|
24
|
+
if (height > 0) height.roundToInt() else 512,
|
|
25
|
+
options.size, options.scale, options.maxBitmapSize)
|
|
26
|
+
val dstWidth = destination.first
|
|
27
|
+
val dstHeight = destination.second
|
|
28
|
+
val (outputWidth, outputHeight) = if (width > 0 && height > 0) {
|
|
29
|
+
val multiplier = DecodeUtils.computeSizeMultiplier(width, height, dstWidth.toFloat(), dstHeight.toFloat(), options.scale)
|
|
30
|
+
(width * multiplier).toInt() to (height * multiplier).toInt()
|
|
31
|
+
} else dstWidth to dstHeight
|
|
32
|
+
DecodeResult(document.render(outputWidth, outputHeight).asImage(), isSampled = true)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class Factory : Decoder.Factory {
|
|
36
|
+
override fun create(result: SourceFetchResult, options: Options, imageLoader: ImageLoader): Decoder? {
|
|
37
|
+
if (result.mimeType != "image/svg+xml") {
|
|
38
|
+
val source = result.source.source()
|
|
39
|
+
if (!source.rangeEquals(0, "<".encodeUtf8())) return null
|
|
40
|
+
val tag = "<svg".encodeUtf8()
|
|
41
|
+
var found = false
|
|
42
|
+
for (index in 0L until (1024L - tag.size)) {
|
|
43
|
+
if (!source.request(index + tag.size)) break
|
|
44
|
+
if (source.rangeEquals(index, tag)) { found = true; break }
|
|
45
|
+
}
|
|
46
|
+
if (!found) return null
|
|
47
|
+
}
|
|
48
|
+
return SharedSvgDecoder(result, options)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
package/docs/SPEC.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Native Tab View behavioral contract
|
|
2
2
|
|
|
3
|
+
## Shared image SVG decoder — Implemented
|
|
4
|
+
|
|
5
|
+
BottomTabs depends on the matching image SDK peer/native module and delegates
|
|
6
|
+
SVG byte decoding to its native facade. No new third-party dependency or SVG
|
|
7
|
+
renderer is introduced. JavaScript props, source resolution and existing tab
|
|
8
|
+
behavior remain unchanged. There is no independent Web SVG reader to migrate.
|
|
9
|
+
|
|
10
|
+
iOS keeps the existing SvgDecoder RCTImageDataDecoder registration (which is
|
|
11
|
+
available to the React image loader beyond tabs), source detection, failure
|
|
12
|
+
delivery and its no-op cancellation block; only data-to-image implementation
|
|
13
|
+
moves out of the local CoreSVG fork. Existing URI loaders, selected/unselected
|
|
14
|
+
and side-accessory paths, SF Symbols, resize/tint and source ordering remain.
|
|
15
|
+
Raw decoding may retain intrinsic/vector dimensions where the old decoder
|
|
16
|
+
ignored target dimensions; it does not use named-icon workers or wait for a
|
|
17
|
+
main-thread callback.
|
|
18
|
+
|
|
19
|
+
Android retains Coil fetching, cache and ordinary image decoders. Its SVG factory
|
|
20
|
+
uses image's parse/render facility with the existing requested dimensions,
|
|
21
|
+
Scale.FILL and Precision.EXACT semantics. The independent coil-svg dependency is
|
|
22
|
+
removed once that route is replaced; no URI loading is moved to Glide. Decoder
|
|
23
|
+
execution remains in Coil's existing worker/cancellation/error lifecycle, with
|
|
24
|
+
no additional pool, cache or main-queue hop. Mutable drawable bounds are owned
|
|
25
|
+
per request, while shared raster data remains immutable.
|
|
26
|
+
|
|
27
|
+
Focused SDK fixtures cover raw SVG and ordinary images through actual RCTImageLoader
|
|
28
|
+
and Coil/BottomTabs consumers, source sizing/non-square art and iOS SF Symbols.
|
|
29
|
+
The current iOS 18.6 fixture does not accept iOS 27.1 side placement; complete
|
|
30
|
+
App styling, platform navigation and signed release acceptance remain separate. Existing source callback races are
|
|
31
|
+
not silently repaired as part of decoding unification. Builds and runtime
|
|
32
|
+
evidence are reported separately. This implementation does not change global image
|
|
33
|
+
loader registration or default-device configuration.
|
|
34
|
+
|
|
35
|
+
## Tab icon source resolution
|
|
36
|
+
|
|
37
|
+
String names matching `[A-Z][A-Za-z0-9]*` and explicit `{ iconName }` sources
|
|
38
|
+
resolve to `onekey-icon://` resources. An already prefixed string keeps that
|
|
39
|
+
scheme. Ordinary URI strings (including HTTP(S), file, data and other schemes,
|
|
40
|
+
absolute/relative paths and protocol-relative URLs) use the existing React Native
|
|
41
|
+
image-source path with `{ uri }`; they MUST NOT receive the named-icon prefix.
|
|
42
|
+
Whitespace-only strings resolve to an empty source. Numeric assets, URI objects
|
|
43
|
+
and SF Symbols retain their existing resolution. The shared resolver is used for
|
|
44
|
+
focused/unfocused icons and the iOS side-accessory icon.
|
|
45
|
+
|
|
46
|
+
The default `getIcon` resolver has a stable identity. With the same routes array
|
|
47
|
+
and resolver, iOS retains both normal and selected icon-source arrays across tab
|
|
48
|
+
selection and unrelated renders. Replacing the routes array or supplying a new
|
|
49
|
+
resolver recomputes both arrays. Android keeps its focus-dependent icon choice.
|
|
50
|
+
|
|
3
51
|
## Native left drawer
|
|
4
52
|
|
|
5
53
|
Status: implemented in module source. Package TypeScript, iOS/Android Fabric
|
|
@@ -172,10 +220,10 @@ bottom gap, or 0 while hidden.
|
|
|
172
220
|
|
|
173
221
|
Floating appearance with background blur disabled: the bar surface is `barTintColor` (or the theme background)
|
|
174
222
|
at 95% opacity (lightened slightly for dark colors), with
|
|
175
|
-
a hairline rim and an outline shadow. When background blur is enabled (see below), the
|
|
176
|
-
|
|
177
|
-
the capsule. The existing capsule keeps its rim/shadow and uses a 12 percent
|
|
178
|
-
surface fill over the blurred
|
|
223
|
+
a hairline rim and an outline shadow. When background blur is enabled (see below), the live blur and translucent
|
|
224
|
+
surface tint are confined and clipped to the capsule bounds; the region above,
|
|
225
|
+
beside, and beneath the capsule remains unblurred. The existing capsule keeps its rim/shadow and uses a 12 percent
|
|
226
|
+
surface fill over the blurred capsule backdrop; its lens and navigation controls remain
|
|
179
227
|
sharp. The selected tab sits on a capsule pill inset 4 dp
|
|
180
228
|
(`activeIndicatorColor` when provided). The Material ripple is disabled; the
|
|
181
229
|
lens provides press feedback.
|
|
@@ -211,7 +259,7 @@ coverage. Complete consumer-app and physical-device acceptance remain pending;
|
|
|
211
259
|
API 31-35 and visual dark-mode acceptance have not been reverified for this port.
|
|
212
260
|
|
|
213
261
|
`androidBottomBlurEnabled?: boolean` controls the native Android tab bar's live
|
|
214
|
-
background blur
|
|
262
|
+
background blur and translucent surface tint behind the bar.
|
|
215
263
|
Omitting it (including `undefined`) MUST enable the effect only on Android 16
|
|
216
264
|
(API 36) and newer. `false` MUST restore the existing appearance and layout for the current
|
|
217
265
|
`androidTabBarStyle`: docked scenes reserve bar height; floating scenes retain
|
|
@@ -229,19 +277,22 @@ report zero bar height. Toggling, resizing, theme changes, and system/keyboard
|
|
|
229
277
|
insets MUST refresh geometry and appearance without remounting scenes.
|
|
230
278
|
|
|
231
279
|
The module owns the GPU resources on the UI thread. It MUST sample only the
|
|
232
|
-
scene layer
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
280
|
+
scene layer directly behind the active tab bar bounds (the docked bar rectangle
|
|
281
|
+
in `default` style or the capsule bounds in `floating` style), excluding the
|
|
282
|
+
tab bar and its own output, and clip the blurred backdrop and tint to those
|
|
283
|
+
bounds (including the capsule corner radius in `floating` style) with no blur
|
|
284
|
+
or fade bleeding above or outside the bar. It MUST use hardware
|
|
285
|
+
RenderNode/RenderEffect rendering of the bar bounds at one-quarter resolution
|
|
286
|
+
in each dimension, with a 20 dp blur radius. It MUST NOT capture bitmaps, read
|
|
287
|
+
pixels back to the CPU, emit scroll events to JS, or run a recurring frame
|
|
288
|
+
callback for this effect. Rendering MUST follow the normal view invalidation
|
|
289
|
+
cycle, using the scene's existing display lists. The translucent tint MUST
|
|
290
|
+
follow `tabBarStyle.backgroundColor` when set, otherwise the docked Material
|
|
291
|
+
surface color or floating theme background, with opacity capped at 78 percent.
|
|
292
|
+
|
|
293
|
+
Only one blur RenderNode and cached paints/paths MAY be retained per mounted
|
|
294
|
+
tab view. Its offscreen dimensions MUST be bounded by one-quarter of the bar
|
|
295
|
+
width and one-quarter of the bar height (rounded up).
|
|
245
296
|
Disabling, hiding, detaching, and dropping the native view MUST discard the
|
|
246
297
|
display list; no scene snapshots, disk cache, timers, or background workers are
|
|
247
298
|
owned. SurfaceView content is outside the normal View display list and is not
|