@onekeyfe/react-native-image 3.0.154 → 3.0.155
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/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImage.kt +3 -64
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImageReusableView.kt +0 -2
- package/android/src/test/java/com/margelo/nitro/onekeyimage/OneKeyImageRequestSignatureTest.kt +1 -14
- package/ios/OneKeyImage.swift +26 -26
- package/ios/OneKeyImageRequestContext.swift +13 -0
- package/ios/tests/OneKeyImageInfrastructureTests.swift +27 -46
- package/lib/module/index.js +0 -2
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.cpp +0 -9
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.hpp +0 -2
- package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyImageStateUpdater.cpp +0 -5
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt +0 -6
- package/lib/nitrogen/generated/ios/c++/HybridOneKeyImageSpecSwift.hpp +0 -7
- package/lib/nitrogen/generated/ios/c++/views/HybridOneKeyImageComponent.mm +0 -6
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyImageSpec.swift +0 -1
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyImageSpec_cxx.swift +0 -24
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.hpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.cpp +0 -2
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.hpp +0 -3
- package/lib/nitrogen/generated/shared/json/OneKeyImageConfig.json +0 -1
- package/lib/typescript/src/OneKeyImage.nitro.d.ts +0 -2
- package/lib/typescript/src/index.d.ts +1 -1
- package/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.cpp +0 -9
- package/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.hpp +0 -2
- package/nitrogen/generated/android/c++/views/JHybridOneKeyImageStateUpdater.cpp +0 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt +0 -6
- package/nitrogen/generated/ios/c++/HybridOneKeyImageSpecSwift.hpp +0 -7
- package/nitrogen/generated/ios/c++/views/HybridOneKeyImageComponent.mm +0 -6
- package/nitrogen/generated/ios/swift/HybridOneKeyImageSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridOneKeyImageSpec_cxx.swift +0 -24
- package/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.cpp +0 -2
- package/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.hpp +0 -3
- package/nitrogen/generated/shared/json/OneKeyImageConfig.json +0 -1
- package/package.json +2 -2
- package/src/OneKeyImage.nitro.ts +0 -2
- package/src/index.tsx +0 -2
|
@@ -7,9 +7,7 @@ import android.content.ContextWrapper
|
|
|
7
7
|
import android.content.res.Configuration
|
|
8
8
|
import android.graphics.Canvas
|
|
9
9
|
import android.graphics.Color
|
|
10
|
-
import android.graphics.Outline
|
|
11
10
|
import android.graphics.Paint
|
|
12
|
-
import android.graphics.Path
|
|
13
11
|
import android.graphics.drawable.Animatable
|
|
14
12
|
import android.graphics.drawable.Drawable
|
|
15
13
|
import android.os.Build
|
|
@@ -17,7 +15,6 @@ import android.os.Looper
|
|
|
17
15
|
import android.os.SystemClock
|
|
18
16
|
import android.provider.Settings
|
|
19
17
|
import android.view.View
|
|
20
|
-
import android.view.ViewOutlineProvider
|
|
21
18
|
import android.view.animation.DecelerateInterpolator
|
|
22
19
|
import android.widget.ImageView
|
|
23
20
|
import com.bumptech.glide.Glide
|
|
@@ -47,16 +44,6 @@ private fun Context.findActivity(): Activity? {
|
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
private class OneKeyImageHostView(context: ThemedReactContext) : ImageView(context) {
|
|
50
|
-
private val roundClipPath = Path()
|
|
51
|
-
private val roundOutlineProvider = object : ViewOutlineProvider() {
|
|
52
|
-
override fun getOutline(view: View, outline: Outline) {
|
|
53
|
-
if (view.width > 0 && view.height > 0) {
|
|
54
|
-
outline.setOval(0, 0, view.width, view.height)
|
|
55
|
-
} else {
|
|
56
|
-
outline.setEmpty()
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
47
|
private val fallbackPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
|
61
48
|
color = Color.rgb(110, 110, 120)
|
|
62
49
|
textAlign = Paint.Align.CENTER
|
|
@@ -65,16 +52,6 @@ private class OneKeyImageHostView(context: ThemedReactContext) : ImageView(conte
|
|
|
65
52
|
var drawStateSymbol = false
|
|
66
53
|
var stateSymbol = "◇"
|
|
67
54
|
var autoplayEnabled = false
|
|
68
|
-
var round = false
|
|
69
|
-
set(value) {
|
|
70
|
-
if (field == value) return
|
|
71
|
-
field = value
|
|
72
|
-
outlineProvider = if (value) roundOutlineProvider else ViewOutlineProvider.BACKGROUND
|
|
73
|
-
clipToOutline = value
|
|
74
|
-
updateRoundClipPath()
|
|
75
|
-
invalidateOutline()
|
|
76
|
-
invalidate()
|
|
77
|
-
}
|
|
78
55
|
private var aggregatedVisible = true
|
|
79
56
|
var skeletonRequested = false
|
|
80
57
|
set(value) {
|
|
@@ -88,24 +65,9 @@ private class OneKeyImageHostView(context: ThemedReactContext) : ImageView(conte
|
|
|
88
65
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
89
66
|
skeleton.updateBounds(w, h)
|
|
90
67
|
fallbackPaint.textSize = minOf(w, h) * 0.35f
|
|
91
|
-
if (round) {
|
|
92
|
-
updateRoundClipPath()
|
|
93
|
-
invalidateOutline()
|
|
94
|
-
}
|
|
95
68
|
if (w > 0 && h > 0) onReadyForRequest?.invoke()
|
|
96
69
|
}
|
|
97
70
|
|
|
98
|
-
override fun draw(canvas: Canvas) {
|
|
99
|
-
if (!round || roundClipPath.isEmpty) {
|
|
100
|
-
super.draw(canvas)
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
val saveCount = canvas.save()
|
|
104
|
-
canvas.clipPath(roundClipPath)
|
|
105
|
-
super.draw(canvas)
|
|
106
|
-
canvas.restoreToCount(saveCount)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
71
|
override fun onDraw(canvas: Canvas) {
|
|
110
72
|
super.onDraw(canvas)
|
|
111
73
|
if (drawStateSymbol) {
|
|
@@ -146,13 +108,6 @@ private class OneKeyImageHostView(context: ThemedReactContext) : ImageView(conte
|
|
|
146
108
|
skeleton.updateBounds(width, height)
|
|
147
109
|
}
|
|
148
110
|
|
|
149
|
-
private fun updateRoundClipPath() {
|
|
150
|
-
roundClipPath.reset()
|
|
151
|
-
if (round && width > 0 && height > 0) {
|
|
152
|
-
roundClipPath.addOval(0f, 0f, width.toFloat(), height.toFloat(), Path.Direction.CW)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
111
|
fun syncPlayback() {
|
|
157
112
|
val canRun = isAttachedToWindow && aggregatedVisible
|
|
158
113
|
if (skeletonRequested && canRun) skeleton.start() else skeleton.stop()
|
|
@@ -175,7 +130,6 @@ internal fun oneKeyImageRequestSignature(
|
|
|
175
130
|
contentFit: OneKeyImageContentFit?,
|
|
176
131
|
optimizeTos: Boolean?,
|
|
177
132
|
overscan: Double?,
|
|
178
|
-
round: Boolean,
|
|
179
133
|
width: Int,
|
|
180
134
|
height: Int,
|
|
181
135
|
density: Float,
|
|
@@ -188,7 +142,6 @@ internal fun oneKeyImageRequestSignature(
|
|
|
188
142
|
(contentFit ?: OneKeyImageContentFit.COVER).name,
|
|
189
143
|
optimizeTos.toString(),
|
|
190
144
|
overscan.toString(),
|
|
191
|
-
round.toString(),
|
|
192
145
|
resizeWidth.toString(),
|
|
193
146
|
width.toString(),
|
|
194
147
|
height.toString(),
|
|
@@ -288,10 +241,6 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
288
241
|
field = value
|
|
289
242
|
requestIdentityChanged()
|
|
290
243
|
}
|
|
291
|
-
override var round: Boolean? = false
|
|
292
|
-
set(value) {
|
|
293
|
-
field = value
|
|
294
|
-
}
|
|
295
244
|
override var overscan: Double? = 1.1
|
|
296
245
|
set(value) {
|
|
297
246
|
if (field == value) return
|
|
@@ -338,10 +287,6 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
338
287
|
|
|
339
288
|
override fun afterUpdate() {
|
|
340
289
|
super.afterUpdate()
|
|
341
|
-
// Fabric can reset `round` before clearing `sourceUri` while removing a view.
|
|
342
|
-
// Apply the shape once per committed prop batch so the outgoing frame keeps
|
|
343
|
-
// its clipping, while mounted and recycled views still receive the new value.
|
|
344
|
-
if (!sourceUri.isNullOrBlank()) hostView.round = round == true
|
|
345
290
|
loadForCurrentLayout()
|
|
346
291
|
}
|
|
347
292
|
|
|
@@ -401,7 +346,6 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
401
346
|
autoplay = false
|
|
402
347
|
recyclingKey = null
|
|
403
348
|
optimizeTos = true
|
|
404
|
-
round = false
|
|
405
349
|
resizeWidth = null
|
|
406
350
|
overscan = 1.1
|
|
407
351
|
loadingStrategy = OneKeyImageLoadingStrategy.STATIC
|
|
@@ -472,7 +416,6 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
472
416
|
contentFit = contentFit,
|
|
473
417
|
optimizeTos = optimizeTos,
|
|
474
418
|
overscan = overscan,
|
|
475
|
-
round = round == true,
|
|
476
419
|
width = hostView.width,
|
|
477
420
|
height = hostView.height,
|
|
478
421
|
density = hostView.resources.displayMetrics.density,
|
|
@@ -606,7 +549,7 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
606
549
|
requestManager()
|
|
607
550
|
.asDrawable()
|
|
608
551
|
.load(OneKeyImageModel.build(requestUrl, headersJson))
|
|
609
|
-
.apply(requestOptions(policy, requestUrl
|
|
552
|
+
.apply(requestOptions(policy, requestUrl))
|
|
610
553
|
.override(decodeDimensions.width, decodeDimensions.height)
|
|
611
554
|
.listener(object : RequestListener<Drawable> {
|
|
612
555
|
override fun onLoadFailed(
|
|
@@ -634,15 +577,11 @@ class HybridOneKeyImage(private val context: ThemedReactContext) :
|
|
|
634
577
|
.into(target)
|
|
635
578
|
}
|
|
636
579
|
|
|
637
|
-
private fun requestOptions(
|
|
638
|
-
policy: OneKeyImageCachePolicy,
|
|
639
|
-
uri: String,
|
|
640
|
-
round: Boolean,
|
|
641
|
-
): RequestOptions {
|
|
580
|
+
private fun requestOptions(policy: OneKeyImageCachePolicy, uri: String): RequestOptions {
|
|
642
581
|
val options = RequestOptions()
|
|
643
582
|
.withOneKeyAvatarCache(uri)
|
|
583
|
+
.dontTransform()
|
|
644
584
|
.downsample(OneKeyImageSafeDownsampleStrategy)
|
|
645
|
-
if (round) options.circleCrop() else options.dontTransform()
|
|
646
585
|
return when (policy) {
|
|
647
586
|
OneKeyImageCachePolicy.MEMORY_DISK -> options.diskCacheStrategy(oneKeyImageMemoryDiskStrategy(uri))
|
|
648
587
|
OneKeyImageCachePolicy.MEMORY -> options.diskCacheStrategy(DiskCacheStrategy.NONE)
|
|
@@ -29,7 +29,6 @@ class OneKeyImageReusableView(context: ThemedReactContext) : FrameLayout(context
|
|
|
29
29
|
overscan: Double,
|
|
30
30
|
loadingStrategy: String,
|
|
31
31
|
placeholderColor: String,
|
|
32
|
-
round: Boolean = false,
|
|
33
32
|
onLoad: (() -> Unit)? = null,
|
|
34
33
|
onError: (() -> Unit)? = null,
|
|
35
34
|
) {
|
|
@@ -58,7 +57,6 @@ class OneKeyImageReusableView(context: ThemedReactContext) : FrameLayout(context
|
|
|
58
57
|
image.autoplay = autoplay
|
|
59
58
|
image.recyclingKey = recyclingKey
|
|
60
59
|
image.optimizeTos = optimizeTos
|
|
61
|
-
image.round = round
|
|
62
60
|
image.overscan = overscan
|
|
63
61
|
image.loadingStrategy = when (loadingStrategy) {
|
|
64
62
|
"skeleton" -> OneKeyImageLoadingStrategy.SKELETON
|
package/android/src/test/java/com/margelo/nitro/onekeyimage/OneKeyImageRequestSignatureTest.kt
CHANGED
|
@@ -26,19 +26,7 @@ class OneKeyImageRequestSignatureTest {
|
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
fun roundParticipatesInRequestIdentity() {
|
|
31
|
-
assertNotEquals(
|
|
32
|
-
signature(OneKeyImageContentFit.COVER, round = false),
|
|
33
|
-
signature(OneKeyImageContentFit.COVER, round = true),
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private fun signature(
|
|
38
|
-
contentFit: OneKeyImageContentFit?,
|
|
39
|
-
resizeWidth: Double? = null,
|
|
40
|
-
round: Boolean = false,
|
|
41
|
-
): String = oneKeyImageRequestSignature(
|
|
29
|
+
private fun signature(contentFit: OneKeyImageContentFit?, resizeWidth: Double? = null): String = oneKeyImageRequestSignature(
|
|
42
30
|
rawUrl = "https://example.com/image.png",
|
|
43
31
|
sourceHeadersJson = null,
|
|
44
32
|
recyclingKey = null,
|
|
@@ -46,7 +34,6 @@ class OneKeyImageRequestSignatureTest {
|
|
|
46
34
|
contentFit = contentFit,
|
|
47
35
|
optimizeTos = true,
|
|
48
36
|
overscan = 1.1,
|
|
49
|
-
round = round,
|
|
50
37
|
width = 200,
|
|
51
38
|
height = 100,
|
|
52
39
|
density = 2f,
|
package/ios/OneKeyImage.swift
CHANGED
|
@@ -7,13 +7,9 @@ import UIKit
|
|
|
7
7
|
private final class OneKeyImageHostView: SDAnimatedImageView {
|
|
8
8
|
var onLayout: (() -> Void)?
|
|
9
9
|
var onWindowChanged: ((Bool) -> Void)?
|
|
10
|
-
var round = false {
|
|
11
|
-
didSet { updateRoundMask() }
|
|
12
|
-
}
|
|
13
10
|
|
|
14
11
|
override func layoutSubviews() {
|
|
15
12
|
super.layoutSubviews()
|
|
16
|
-
updateRoundMask()
|
|
17
13
|
onLayout?()
|
|
18
14
|
}
|
|
19
15
|
|
|
@@ -21,10 +17,6 @@ private final class OneKeyImageHostView: SDAnimatedImageView {
|
|
|
21
17
|
super.didMoveToWindow()
|
|
22
18
|
onWindowChanged?(window != nil)
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
private func updateRoundMask() {
|
|
26
|
-
layer.cornerRadius = round ? min(bounds.width, bounds.height) / 2 : 0
|
|
27
|
-
}
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
private final class OneKeyImageSkeletonView: UIView {
|
|
@@ -120,9 +112,7 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
120
112
|
var view: UIView { hostView }
|
|
121
113
|
|
|
122
114
|
var sourceUri: String? {
|
|
123
|
-
didSet {
|
|
124
|
-
if sourceUri != oldValue { identityDidChange() }
|
|
125
|
-
}
|
|
115
|
+
didSet { if sourceUri != oldValue { identityDidChange() } }
|
|
126
116
|
}
|
|
127
117
|
var sourceHeadersJson: String? {
|
|
128
118
|
didSet { if sourceHeadersJson != oldValue { identityDidChange() } }
|
|
@@ -144,7 +134,6 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
144
134
|
var optimizeTos: Bool? = true {
|
|
145
135
|
didSet { if optimizeTos != oldValue { identityDidChange() } }
|
|
146
136
|
}
|
|
147
|
-
var round: Bool? = false
|
|
148
137
|
var resizeWidth: Double? {
|
|
149
138
|
didSet {
|
|
150
139
|
if !Self.equalOptionalDouble(resizeWidth, oldValue) { identityDidChange() }
|
|
@@ -196,12 +185,6 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
196
185
|
}
|
|
197
186
|
|
|
198
187
|
func afterUpdate() {
|
|
199
|
-
// Fabric can reset `round` before clearing `sourceUri` while removing a view.
|
|
200
|
-
// Apply the shape once per committed prop batch so the outgoing frame keeps
|
|
201
|
-
// its clipping, while mounted and recycled views still receive the new value.
|
|
202
|
-
if let sourceUri, !sourceUri.isEmpty {
|
|
203
|
-
hostView.round = round == true
|
|
204
|
-
}
|
|
205
188
|
scheduleLoad()
|
|
206
189
|
}
|
|
207
190
|
|
|
@@ -260,7 +243,11 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
260
243
|
guard !hostView.bounds.isEmpty else {
|
|
261
244
|
cancelCurrentRequest(invalidateGeneration: true)
|
|
262
245
|
lastRequestSignature = nil
|
|
263
|
-
|
|
246
|
+
// A memory-cached image shown from `identityDidChange` before layout
|
|
247
|
+
// stays up; layout re-runs this load with real bounds and confirms it.
|
|
248
|
+
if displayState != .image {
|
|
249
|
+
showLoading(requestIsActive: false, letLibraryStartIndicator: false)
|
|
250
|
+
}
|
|
264
251
|
return
|
|
265
252
|
}
|
|
266
253
|
guard let rawString = sourceUri, !rawString.isEmpty else {
|
|
@@ -515,7 +502,6 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
515
502
|
autoplay = true
|
|
516
503
|
recyclingKey = nil
|
|
517
504
|
optimizeTos = true
|
|
518
|
-
round = false
|
|
519
505
|
resizeWidth = nil
|
|
520
506
|
overscan = 1.1
|
|
521
507
|
loadingStrategy = .static
|
|
@@ -563,7 +549,13 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
563
549
|
}
|
|
564
550
|
|
|
565
551
|
private func showMemoryCachedImageIfAvailable(requestIsActive: Bool) -> Bool {
|
|
566
|
-
|
|
552
|
+
// JS leaves `cachePolicy` unset for the common case and Fabric then hands
|
|
553
|
+
// Nitro a nil, which the request path already treats as memory-disk; the
|
|
554
|
+
// probe must agree, otherwise a nil policy skips the memory lookup entirely
|
|
555
|
+
// and every mount pays the async pipeline round trip (an icon skeleton
|
|
556
|
+
// frame) for an image that is already decoded in memory.
|
|
557
|
+
let effectivePolicy = cachePolicy ?? .memoryDisk
|
|
558
|
+
guard effectivePolicy == .memory || effectivePolicy == .memoryDisk,
|
|
567
559
|
let sourceUri,
|
|
568
560
|
let rawURL = URL(string: sourceUri) else {
|
|
569
561
|
return false
|
|
@@ -583,11 +575,19 @@ final class HybridOneKeyImage: HybridOneKeyImageSpec, RecyclableView {
|
|
|
583
575
|
hasCustomIdentity: hasCustomIdentity
|
|
584
576
|
)
|
|
585
577
|
: rawURL
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
578
|
+
// Before layout the bounds are empty; fall back to the `resizeWidth` hint so
|
|
579
|
+
// the probe key matches the prewarm / post-layout request instead of
|
|
580
|
+
// missing on every mount frame.
|
|
581
|
+
let thumbnailPixelSize = OneKeyImageDecodeSizing.probeViewSize(
|
|
582
|
+
bounds: hostView.bounds.size,
|
|
583
|
+
resizeWidth: resizeWidth
|
|
584
|
+
).flatMap {
|
|
585
|
+
OneKeyImageDecodeSizing.thumbnailPixelSize(
|
|
586
|
+
viewSize: $0,
|
|
587
|
+
scale: screenScale,
|
|
588
|
+
contentFit: contentFit ?? .cover
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
591
|
func memoryCachedImage(for url: URL) -> UIImage? {
|
|
592
592
|
let context = OneKeyImageRequestContext.make(
|
|
593
593
|
headersJson: sourceHeadersJson,
|
|
@@ -610,6 +610,19 @@ enum OneKeyImageDecodeSizing {
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
+
/// The logical size to probe the memory cache with. Before the first layout
|
|
614
|
+
/// the host view has no bounds, but the JS side already knows the display
|
|
615
|
+
/// size through `resizeWidth` (the same hint the prewarm used), so a square
|
|
616
|
+
/// from it yields the decode-thumbnail key the laid-out view will ask for.
|
|
617
|
+
/// A cached image can then show on the mount frame instead of a skeleton
|
|
618
|
+
/// until layout re-probes.
|
|
619
|
+
static func probeViewSize(bounds: CGSize, resizeWidth: Double?) -> CGSize? {
|
|
620
|
+
if bounds.width.isFinite, bounds.height.isFinite, bounds.width > 0, bounds.height > 0 {
|
|
621
|
+
return bounds
|
|
622
|
+
}
|
|
623
|
+
return logicalViewSize(width: resizeWidth, height: nil)
|
|
624
|
+
}
|
|
625
|
+
|
|
613
626
|
static func thumbnailPixelSize(
|
|
614
627
|
viewSize: CGSize,
|
|
615
628
|
scale: CGFloat,
|
|
@@ -310,6 +310,33 @@ final class OneKeyImageInfrastructureTests: XCTestCase {
|
|
|
310
310
|
)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
func testMemoryProbeFallsBackToResizeWidthBeforeLayout() throws {
|
|
314
|
+
// Laid out: the real bounds win, even with a hint.
|
|
315
|
+
XCTAssertEqual(
|
|
316
|
+
OneKeyImageDecodeSizing.probeViewSize(
|
|
317
|
+
bounds: CGSize(width: 40, height: 64),
|
|
318
|
+
resizeWidth: 32
|
|
319
|
+
),
|
|
320
|
+
CGSize(width: 40, height: 64)
|
|
321
|
+
)
|
|
322
|
+
// Not laid out yet: a square from the hint, matching the prewarm key.
|
|
323
|
+
let probe = try XCTUnwrap(
|
|
324
|
+
OneKeyImageDecodeSizing.probeViewSize(bounds: .zero, resizeWidth: 40)
|
|
325
|
+
)
|
|
326
|
+
XCTAssertEqual(probe, CGSize(width: 40, height: 40))
|
|
327
|
+
XCTAssertEqual(
|
|
328
|
+
OneKeyImageDecodeSizing.thumbnailPixelSize(viewSize: probe, scale: 3, contentFit: .cover),
|
|
329
|
+
OneKeyImageDecodeSizing.thumbnailPixelSize(
|
|
330
|
+
viewSize: try XCTUnwrap(OneKeyImageDecodeSizing.logicalViewSize(width: 40, height: nil)),
|
|
331
|
+
scale: 3,
|
|
332
|
+
contentFit: .cover
|
|
333
|
+
)
|
|
334
|
+
)
|
|
335
|
+
// No bounds and no usable hint: nothing to probe with.
|
|
336
|
+
XCTAssertNil(OneKeyImageDecodeSizing.probeViewSize(bounds: .zero, resizeWidth: nil))
|
|
337
|
+
XCTAssertNil(OneKeyImageDecodeSizing.probeViewSize(bounds: .zero, resizeWidth: 0))
|
|
338
|
+
}
|
|
339
|
+
|
|
313
340
|
func testNoSizePreloadUsesCappedDecodeTarget() {
|
|
314
341
|
XCTAssertEqual(HybridOneKeyImageCache.maximumConcurrentPreloads, 4)
|
|
315
342
|
XCTAssertEqual(
|
|
@@ -565,50 +592,4 @@ final class OneKeyImageInfrastructureTests: XCTestCase {
|
|
|
565
592
|
)
|
|
566
593
|
XCTAssertTrue(imageView.clearBufferWhenStopped)
|
|
567
594
|
}
|
|
568
|
-
|
|
569
|
-
func testRoundPropUpdatesNativeCornerRadius() throws {
|
|
570
|
-
let image = HybridOneKeyImage()
|
|
571
|
-
let imageView = try XCTUnwrap(image.view as? SDAnimatedImageView)
|
|
572
|
-
imageView.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
|
|
573
|
-
|
|
574
|
-
image.sourceUri = "https://example.com/round.png"
|
|
575
|
-
image.round = true
|
|
576
|
-
image.afterUpdate()
|
|
577
|
-
imageView.layoutIfNeeded()
|
|
578
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 20)
|
|
579
|
-
|
|
580
|
-
image.round = nil
|
|
581
|
-
image.afterUpdate()
|
|
582
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 20)
|
|
583
|
-
|
|
584
|
-
image.round = false
|
|
585
|
-
image.afterUpdate()
|
|
586
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 0)
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
func testRecycleKeepsRoundMaskUntilVisibleViewDetaches() throws {
|
|
590
|
-
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
591
|
-
let image = HybridOneKeyImage()
|
|
592
|
-
let imageView = try XCTUnwrap(image.view as? SDAnimatedImageView)
|
|
593
|
-
imageView.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
|
|
594
|
-
window.addSubview(imageView)
|
|
595
|
-
image.sourceUri = "https://example.com/round.png"
|
|
596
|
-
image.round = true
|
|
597
|
-
image.afterUpdate()
|
|
598
|
-
imageView.layoutIfNeeded()
|
|
599
|
-
|
|
600
|
-
// Fabric resets props in setter order before the view leaves the hierarchy.
|
|
601
|
-
image.round = false
|
|
602
|
-
image.sourceUri = nil
|
|
603
|
-
image.afterUpdate()
|
|
604
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 20)
|
|
605
|
-
|
|
606
|
-
image.prepareForRecycle()
|
|
607
|
-
|
|
608
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 20)
|
|
609
|
-
|
|
610
|
-
image.sourceUri = "https://example.com/reused.png"
|
|
611
|
-
image.afterUpdate()
|
|
612
|
-
XCTAssertEqual(imageView.layer.cornerRadius, 0)
|
|
613
|
-
}
|
|
614
595
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -44,7 +44,6 @@ export function OneKeyImage({
|
|
|
44
44
|
autoplay,
|
|
45
45
|
recyclingKey,
|
|
46
46
|
optimizeTos = true,
|
|
47
|
-
round = false,
|
|
48
47
|
resizeWidth,
|
|
49
48
|
overscan = 1.1,
|
|
50
49
|
loadingStrategy = OneKeyImageLoadingStrategy.STATIC,
|
|
@@ -213,7 +212,6 @@ export function OneKeyImage({
|
|
|
213
212
|
autoplay: autoplay ?? Platform.OS !== 'android',
|
|
214
213
|
recyclingKey,
|
|
215
214
|
optimizeTos,
|
|
216
|
-
round,
|
|
217
215
|
resizeWidth,
|
|
218
216
|
overscan,
|
|
219
217
|
loadingStrategy: placeholder == null ? loadingStrategy : OneKeyImageLoadingStrategy.NONE,
|
|
@@ -138,15 +138,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
138
138
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* optimizeTos */)>("setOptimizeTos");
|
|
139
139
|
method(_javaPart, optimizeTos.has_value() ? jni::JBoolean::valueOf(optimizeTos.value()) : nullptr);
|
|
140
140
|
}
|
|
141
|
-
std::optional<bool> JHybridOneKeyImageSpec::getRound() {
|
|
142
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getRound");
|
|
143
|
-
auto __result = method(_javaPart);
|
|
144
|
-
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
|
|
145
|
-
}
|
|
146
|
-
void JHybridOneKeyImageSpec::setRound(std::optional<bool> round) {
|
|
147
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* round */)>("setRound");
|
|
148
|
-
method(_javaPart, round.has_value() ? jni::JBoolean::valueOf(round.value()) : nullptr);
|
|
149
|
-
}
|
|
150
141
|
std::optional<double> JHybridOneKeyImageSpec::getResizeWidth() {
|
|
151
142
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getResizeWidth");
|
|
152
143
|
auto __result = method(_javaPart);
|
|
@@ -66,8 +66,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
66
66
|
void setRecyclingKey(const std::optional<std::string>& recyclingKey) override;
|
|
67
67
|
std::optional<bool> getOptimizeTos() override;
|
|
68
68
|
void setOptimizeTos(std::optional<bool> optimizeTos) override;
|
|
69
|
-
std::optional<bool> getRound() override;
|
|
70
|
-
void setRound(std::optional<bool> round) override;
|
|
71
69
|
std::optional<double> getResizeWidth() override;
|
|
72
70
|
void setResizeWidth(std::optional<double> resizeWidth) override;
|
|
73
71
|
std::optional<double> getOverscan() override;
|
|
@@ -93,11 +93,6 @@ void JHybridOneKeyImageStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
93
93
|
: !newProps->optimizeTos.hasSameValue(oldProps->optimizeTos)) {
|
|
94
94
|
hybridView->setOptimizeTos(newProps->optimizeTos.get());
|
|
95
95
|
}
|
|
96
|
-
if (oldProps == nullptr
|
|
97
|
-
? newProps->round.isProvided()
|
|
98
|
-
: !newProps->round.hasSameValue(oldProps->round)) {
|
|
99
|
-
hybridView->setRound(newProps->round.get());
|
|
100
|
-
}
|
|
101
96
|
if (oldProps == nullptr
|
|
102
97
|
? newProps->resizeWidth.isProvided()
|
|
103
98
|
: !newProps->resizeWidth.hasSameValue(oldProps->resizeWidth)) {
|
package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt
CHANGED
|
@@ -75,12 +75,6 @@ abstract class HybridOneKeyImageSpec: HybridView() {
|
|
|
75
75
|
@set:Keep
|
|
76
76
|
abstract var optimizeTos: Boolean?
|
|
77
77
|
|
|
78
|
-
@get:DoNotStrip
|
|
79
|
-
@get:Keep
|
|
80
|
-
@set:DoNotStrip
|
|
81
|
-
@set:Keep
|
|
82
|
-
abstract var round: Boolean?
|
|
83
|
-
|
|
84
78
|
@get:DoNotStrip
|
|
85
79
|
@get:Keep
|
|
86
80
|
@set:DoNotStrip
|
|
@@ -134,13 +134,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
134
134
|
inline void setOptimizeTos(std::optional<bool> optimizeTos) noexcept override {
|
|
135
135
|
_swiftPart.setOptimizeTos(optimizeTos);
|
|
136
136
|
}
|
|
137
|
-
inline std::optional<bool> getRound() noexcept override {
|
|
138
|
-
auto __result = _swiftPart.getRound();
|
|
139
|
-
return __result;
|
|
140
|
-
}
|
|
141
|
-
inline void setRound(std::optional<bool> round) noexcept override {
|
|
142
|
-
_swiftPart.setRound(round);
|
|
143
|
-
}
|
|
144
137
|
inline std::optional<double> getResizeWidth() noexcept override {
|
|
145
138
|
auto __result = _swiftPart.getResizeWidth();
|
|
146
139
|
return __result;
|
|
@@ -146,12 +146,6 @@ using namespace margelo::nitro::onekeyimage::views;
|
|
|
146
146
|
: !newViewProps.optimizeTos.hasSameValue(oldViewProps->optimizeTos)) {
|
|
147
147
|
swiftPart.setOptimizeTos(newViewProps.optimizeTos.get());
|
|
148
148
|
}
|
|
149
|
-
// round: optional
|
|
150
|
-
if (oldViewProps == nullptr
|
|
151
|
-
? newViewProps.round.isProvided()
|
|
152
|
-
: !newViewProps.round.hasSameValue(oldViewProps->round)) {
|
|
153
|
-
swiftPart.setRound(newViewProps.round.get());
|
|
154
|
-
}
|
|
155
149
|
// resizeWidth: optional
|
|
156
150
|
if (oldViewProps == nullptr
|
|
157
151
|
? newViewProps.resizeWidth.isProvided()
|
|
@@ -18,7 +18,6 @@ public protocol HybridOneKeyImageSpec_protocol: HybridObject, HybridView {
|
|
|
18
18
|
var autoplay: Bool? { get set }
|
|
19
19
|
var recyclingKey: String? { get set }
|
|
20
20
|
var optimizeTos: Bool? { get set }
|
|
21
|
-
var round: Bool? { get set }
|
|
22
21
|
var resizeWidth: Double? { get set }
|
|
23
22
|
var overscan: Double? { get set }
|
|
24
23
|
var loadingStrategy: OneKeyImageLoadingStrategy? { get set }
|
|
@@ -292,30 +292,6 @@ open class HybridOneKeyImageSpec_cxx {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
public final var round: bridge.std__optional_bool_ {
|
|
296
|
-
@inline(__always)
|
|
297
|
-
get {
|
|
298
|
-
return { () -> bridge.std__optional_bool_ in
|
|
299
|
-
if let __unwrappedValue = self.__implementation.round {
|
|
300
|
-
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
301
|
-
} else {
|
|
302
|
-
return .init()
|
|
303
|
-
}
|
|
304
|
-
}()
|
|
305
|
-
}
|
|
306
|
-
@inline(__always)
|
|
307
|
-
set {
|
|
308
|
-
self.__implementation.round = { () -> Bool? in
|
|
309
|
-
if bridge.has_value_std__optional_bool_(newValue) {
|
|
310
|
-
let __unwrapped = bridge.get_std__optional_bool_(newValue)
|
|
311
|
-
return __unwrapped
|
|
312
|
-
} else {
|
|
313
|
-
return nil
|
|
314
|
-
}
|
|
315
|
-
}()
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
295
|
public final var resizeWidth: bridge.std__optional_double_ {
|
|
320
296
|
@inline(__always)
|
|
321
297
|
get {
|
|
@@ -30,8 +30,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
30
30
|
prototype.registerHybridSetter("recyclingKey", &HybridOneKeyImageSpec::setRecyclingKey);
|
|
31
31
|
prototype.registerHybridGetter("optimizeTos", &HybridOneKeyImageSpec::getOptimizeTos);
|
|
32
32
|
prototype.registerHybridSetter("optimizeTos", &HybridOneKeyImageSpec::setOptimizeTos);
|
|
33
|
-
prototype.registerHybridGetter("round", &HybridOneKeyImageSpec::getRound);
|
|
34
|
-
prototype.registerHybridSetter("round", &HybridOneKeyImageSpec::setRound);
|
|
35
33
|
prototype.registerHybridGetter("resizeWidth", &HybridOneKeyImageSpec::getResizeWidth);
|
|
36
34
|
prototype.registerHybridSetter("resizeWidth", &HybridOneKeyImageSpec::setResizeWidth);
|
|
37
35
|
prototype.registerHybridGetter("overscan", &HybridOneKeyImageSpec::getOverscan);
|
|
@@ -76,8 +76,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
76
76
|
virtual void setRecyclingKey(const std::optional<std::string>& recyclingKey) = 0;
|
|
77
77
|
virtual std::optional<bool> getOptimizeTos() = 0;
|
|
78
78
|
virtual void setOptimizeTos(std::optional<bool> optimizeTos) = 0;
|
|
79
|
-
virtual std::optional<bool> getRound() = 0;
|
|
80
|
-
virtual void setRound(std::optional<bool> round) = 0;
|
|
81
79
|
virtual std::optional<double> getResizeWidth() = 0;
|
|
82
80
|
virtual void setResizeWidth(std::optional<double> resizeWidth) = 0;
|
|
83
81
|
virtual std::optional<double> getOverscan() = 0;
|
|
@@ -28,7 +28,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
28
28
|
autoplay(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "autoplay", rawProps, sourceProps.autoplay)),
|
|
29
29
|
recyclingKey(nitro::ReactProp<std::optional<std::string>>::fromRawValue("OneKeyImage", "recyclingKey", rawProps, sourceProps.recyclingKey)),
|
|
30
30
|
optimizeTos(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "optimizeTos", rawProps, sourceProps.optimizeTos)),
|
|
31
|
-
round(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "round", rawProps, sourceProps.round)),
|
|
32
31
|
resizeWidth(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "resizeWidth", rawProps, sourceProps.resizeWidth)),
|
|
33
32
|
overscan(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "overscan", rawProps, sourceProps.overscan)),
|
|
34
33
|
loadingStrategy(nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>>::fromRawValue("OneKeyImage", "loadingStrategy", rawProps, sourceProps.loadingStrategy)),
|
|
@@ -50,7 +49,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
50
49
|
case hashString("autoplay"): return true;
|
|
51
50
|
case hashString("recyclingKey"): return true;
|
|
52
51
|
case hashString("optimizeTos"): return true;
|
|
53
|
-
case hashString("round"): return true;
|
|
54
52
|
case hashString("resizeWidth"): return true;
|
|
55
53
|
case hashString("overscan"): return true;
|
|
56
54
|
case hashString("loadingStrategy"): return true;
|
|
@@ -56,7 +56,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
56
56
|
nitro::ReactProp<std::optional<bool>> autoplay;
|
|
57
57
|
nitro::ReactProp<std::optional<std::string>> recyclingKey;
|
|
58
58
|
nitro::ReactProp<std::optional<bool>> optimizeTos;
|
|
59
|
-
nitro::ReactProp<std::optional<bool>> round;
|
|
60
59
|
nitro::ReactProp<std::optional<double>> resizeWidth;
|
|
61
60
|
nitro::ReactProp<std::optional<double>> overscan;
|
|
62
61
|
nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>> loadingStrategy;
|
|
@@ -78,7 +77,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
78
77
|
autoplay.hasSameValue(other.autoplay) &&
|
|
79
78
|
recyclingKey.hasSameValue(other.recyclingKey) &&
|
|
80
79
|
optimizeTos.hasSameValue(other.optimizeTos) &&
|
|
81
|
-
round.hasSameValue(other.round) &&
|
|
82
80
|
resizeWidth.hasSameValue(other.resizeWidth) &&
|
|
83
81
|
overscan.hasSameValue(other.overscan) &&
|
|
84
82
|
loadingStrategy.hasSameValue(other.loadingStrategy) &&
|
|
@@ -101,7 +99,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
101
99
|
autoplay.isProvided() ||
|
|
102
100
|
recyclingKey.isProvided() ||
|
|
103
101
|
optimizeTos.isProvided() ||
|
|
104
|
-
round.isProvided() ||
|
|
105
102
|
resizeWidth.isProvided() ||
|
|
106
103
|
overscan.isProvided() ||
|
|
107
104
|
loadingStrategy.isProvided() ||
|
|
@@ -32,8 +32,6 @@ export interface OneKeyImageNativeProps extends HybridViewProps {
|
|
|
32
32
|
autoplay?: boolean;
|
|
33
33
|
recyclingKey?: string;
|
|
34
34
|
optimizeTos?: boolean;
|
|
35
|
-
/** Clips the native image to an oval using its current bounds. */
|
|
36
|
-
round?: boolean;
|
|
37
35
|
/** Display width hint in layout units. Native applies the screen density. */
|
|
38
36
|
resizeWidth?: number;
|
|
39
37
|
overscan?: number;
|
|
@@ -45,7 +45,7 @@ export interface OneKeyImageProps extends Omit<OneKeyImageNativeProps, 'sourceUr
|
|
|
45
45
|
onError?: MaybeWrappedCallback<(event: OneKeyImageErrorEvent) => void>;
|
|
46
46
|
onLoadEnd?: MaybeWrappedCallback<() => void>;
|
|
47
47
|
}
|
|
48
|
-
export declare function OneKeyImage({ source, placeholder, fallback, variant, contentFit, cachePolicy, autoplay, recyclingKey, optimizeTos,
|
|
48
|
+
export declare function OneKeyImage({ source, placeholder, fallback, variant, contentFit, cachePolicy, autoplay, recyclingKey, optimizeTos, resizeWidth, overscan, loadingStrategy, placeholderColor, hybridRef, onLoadStart, onLoad, onDisplay, onError, onLoadEnd, style, ...viewProps }: OneKeyImageProps): import("react/jsx-runtime").JSX.Element;
|
|
49
49
|
export declare const OneKeyImageCache: {
|
|
50
50
|
preload(sources: OneKeyImagePreloadInput[]): Promise<boolean>;
|
|
51
51
|
clearMemory: () => Promise<void>;
|
|
@@ -138,15 +138,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
138
138
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* optimizeTos */)>("setOptimizeTos");
|
|
139
139
|
method(_javaPart, optimizeTos.has_value() ? jni::JBoolean::valueOf(optimizeTos.value()) : nullptr);
|
|
140
140
|
}
|
|
141
|
-
std::optional<bool> JHybridOneKeyImageSpec::getRound() {
|
|
142
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getRound");
|
|
143
|
-
auto __result = method(_javaPart);
|
|
144
|
-
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
|
|
145
|
-
}
|
|
146
|
-
void JHybridOneKeyImageSpec::setRound(std::optional<bool> round) {
|
|
147
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* round */)>("setRound");
|
|
148
|
-
method(_javaPart, round.has_value() ? jni::JBoolean::valueOf(round.value()) : nullptr);
|
|
149
|
-
}
|
|
150
141
|
std::optional<double> JHybridOneKeyImageSpec::getResizeWidth() {
|
|
151
142
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getResizeWidth");
|
|
152
143
|
auto __result = method(_javaPart);
|
|
@@ -66,8 +66,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
66
66
|
void setRecyclingKey(const std::optional<std::string>& recyclingKey) override;
|
|
67
67
|
std::optional<bool> getOptimizeTos() override;
|
|
68
68
|
void setOptimizeTos(std::optional<bool> optimizeTos) override;
|
|
69
|
-
std::optional<bool> getRound() override;
|
|
70
|
-
void setRound(std::optional<bool> round) override;
|
|
71
69
|
std::optional<double> getResizeWidth() override;
|
|
72
70
|
void setResizeWidth(std::optional<double> resizeWidth) override;
|
|
73
71
|
std::optional<double> getOverscan() override;
|
|
@@ -93,11 +93,6 @@ void JHybridOneKeyImageStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
93
93
|
: !newProps->optimizeTos.hasSameValue(oldProps->optimizeTos)) {
|
|
94
94
|
hybridView->setOptimizeTos(newProps->optimizeTos.get());
|
|
95
95
|
}
|
|
96
|
-
if (oldProps == nullptr
|
|
97
|
-
? newProps->round.isProvided()
|
|
98
|
-
: !newProps->round.hasSameValue(oldProps->round)) {
|
|
99
|
-
hybridView->setRound(newProps->round.get());
|
|
100
|
-
}
|
|
101
96
|
if (oldProps == nullptr
|
|
102
97
|
? newProps->resizeWidth.isProvided()
|
|
103
98
|
: !newProps->resizeWidth.hasSameValue(oldProps->resizeWidth)) {
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt
CHANGED
|
@@ -75,12 +75,6 @@ abstract class HybridOneKeyImageSpec: HybridView() {
|
|
|
75
75
|
@set:Keep
|
|
76
76
|
abstract var optimizeTos: Boolean?
|
|
77
77
|
|
|
78
|
-
@get:DoNotStrip
|
|
79
|
-
@get:Keep
|
|
80
|
-
@set:DoNotStrip
|
|
81
|
-
@set:Keep
|
|
82
|
-
abstract var round: Boolean?
|
|
83
|
-
|
|
84
78
|
@get:DoNotStrip
|
|
85
79
|
@get:Keep
|
|
86
80
|
@set:DoNotStrip
|
|
@@ -134,13 +134,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
134
134
|
inline void setOptimizeTos(std::optional<bool> optimizeTos) noexcept override {
|
|
135
135
|
_swiftPart.setOptimizeTos(optimizeTos);
|
|
136
136
|
}
|
|
137
|
-
inline std::optional<bool> getRound() noexcept override {
|
|
138
|
-
auto __result = _swiftPart.getRound();
|
|
139
|
-
return __result;
|
|
140
|
-
}
|
|
141
|
-
inline void setRound(std::optional<bool> round) noexcept override {
|
|
142
|
-
_swiftPart.setRound(round);
|
|
143
|
-
}
|
|
144
137
|
inline std::optional<double> getResizeWidth() noexcept override {
|
|
145
138
|
auto __result = _swiftPart.getResizeWidth();
|
|
146
139
|
return __result;
|
|
@@ -146,12 +146,6 @@ using namespace margelo::nitro::onekeyimage::views;
|
|
|
146
146
|
: !newViewProps.optimizeTos.hasSameValue(oldViewProps->optimizeTos)) {
|
|
147
147
|
swiftPart.setOptimizeTos(newViewProps.optimizeTos.get());
|
|
148
148
|
}
|
|
149
|
-
// round: optional
|
|
150
|
-
if (oldViewProps == nullptr
|
|
151
|
-
? newViewProps.round.isProvided()
|
|
152
|
-
: !newViewProps.round.hasSameValue(oldViewProps->round)) {
|
|
153
|
-
swiftPart.setRound(newViewProps.round.get());
|
|
154
|
-
}
|
|
155
149
|
// resizeWidth: optional
|
|
156
150
|
if (oldViewProps == nullptr
|
|
157
151
|
? newViewProps.resizeWidth.isProvided()
|
|
@@ -18,7 +18,6 @@ public protocol HybridOneKeyImageSpec_protocol: HybridObject, HybridView {
|
|
|
18
18
|
var autoplay: Bool? { get set }
|
|
19
19
|
var recyclingKey: String? { get set }
|
|
20
20
|
var optimizeTos: Bool? { get set }
|
|
21
|
-
var round: Bool? { get set }
|
|
22
21
|
var resizeWidth: Double? { get set }
|
|
23
22
|
var overscan: Double? { get set }
|
|
24
23
|
var loadingStrategy: OneKeyImageLoadingStrategy? { get set }
|
|
@@ -292,30 +292,6 @@ open class HybridOneKeyImageSpec_cxx {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
public final var round: bridge.std__optional_bool_ {
|
|
296
|
-
@inline(__always)
|
|
297
|
-
get {
|
|
298
|
-
return { () -> bridge.std__optional_bool_ in
|
|
299
|
-
if let __unwrappedValue = self.__implementation.round {
|
|
300
|
-
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
301
|
-
} else {
|
|
302
|
-
return .init()
|
|
303
|
-
}
|
|
304
|
-
}()
|
|
305
|
-
}
|
|
306
|
-
@inline(__always)
|
|
307
|
-
set {
|
|
308
|
-
self.__implementation.round = { () -> Bool? in
|
|
309
|
-
if bridge.has_value_std__optional_bool_(newValue) {
|
|
310
|
-
let __unwrapped = bridge.get_std__optional_bool_(newValue)
|
|
311
|
-
return __unwrapped
|
|
312
|
-
} else {
|
|
313
|
-
return nil
|
|
314
|
-
}
|
|
315
|
-
}()
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
295
|
public final var resizeWidth: bridge.std__optional_double_ {
|
|
320
296
|
@inline(__always)
|
|
321
297
|
get {
|
|
@@ -30,8 +30,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
30
30
|
prototype.registerHybridSetter("recyclingKey", &HybridOneKeyImageSpec::setRecyclingKey);
|
|
31
31
|
prototype.registerHybridGetter("optimizeTos", &HybridOneKeyImageSpec::getOptimizeTos);
|
|
32
32
|
prototype.registerHybridSetter("optimizeTos", &HybridOneKeyImageSpec::setOptimizeTos);
|
|
33
|
-
prototype.registerHybridGetter("round", &HybridOneKeyImageSpec::getRound);
|
|
34
|
-
prototype.registerHybridSetter("round", &HybridOneKeyImageSpec::setRound);
|
|
35
33
|
prototype.registerHybridGetter("resizeWidth", &HybridOneKeyImageSpec::getResizeWidth);
|
|
36
34
|
prototype.registerHybridSetter("resizeWidth", &HybridOneKeyImageSpec::setResizeWidth);
|
|
37
35
|
prototype.registerHybridGetter("overscan", &HybridOneKeyImageSpec::getOverscan);
|
|
@@ -76,8 +76,6 @@ namespace margelo::nitro::onekeyimage {
|
|
|
76
76
|
virtual void setRecyclingKey(const std::optional<std::string>& recyclingKey) = 0;
|
|
77
77
|
virtual std::optional<bool> getOptimizeTos() = 0;
|
|
78
78
|
virtual void setOptimizeTos(std::optional<bool> optimizeTos) = 0;
|
|
79
|
-
virtual std::optional<bool> getRound() = 0;
|
|
80
|
-
virtual void setRound(std::optional<bool> round) = 0;
|
|
81
79
|
virtual std::optional<double> getResizeWidth() = 0;
|
|
82
80
|
virtual void setResizeWidth(std::optional<double> resizeWidth) = 0;
|
|
83
81
|
virtual std::optional<double> getOverscan() = 0;
|
|
@@ -28,7 +28,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
28
28
|
autoplay(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "autoplay", rawProps, sourceProps.autoplay)),
|
|
29
29
|
recyclingKey(nitro::ReactProp<std::optional<std::string>>::fromRawValue("OneKeyImage", "recyclingKey", rawProps, sourceProps.recyclingKey)),
|
|
30
30
|
optimizeTos(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "optimizeTos", rawProps, sourceProps.optimizeTos)),
|
|
31
|
-
round(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "round", rawProps, sourceProps.round)),
|
|
32
31
|
resizeWidth(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "resizeWidth", rawProps, sourceProps.resizeWidth)),
|
|
33
32
|
overscan(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "overscan", rawProps, sourceProps.overscan)),
|
|
34
33
|
loadingStrategy(nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>>::fromRawValue("OneKeyImage", "loadingStrategy", rawProps, sourceProps.loadingStrategy)),
|
|
@@ -50,7 +49,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
50
49
|
case hashString("autoplay"): return true;
|
|
51
50
|
case hashString("recyclingKey"): return true;
|
|
52
51
|
case hashString("optimizeTos"): return true;
|
|
53
|
-
case hashString("round"): return true;
|
|
54
52
|
case hashString("resizeWidth"): return true;
|
|
55
53
|
case hashString("overscan"): return true;
|
|
56
54
|
case hashString("loadingStrategy"): return true;
|
|
@@ -56,7 +56,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
56
56
|
nitro::ReactProp<std::optional<bool>> autoplay;
|
|
57
57
|
nitro::ReactProp<std::optional<std::string>> recyclingKey;
|
|
58
58
|
nitro::ReactProp<std::optional<bool>> optimizeTos;
|
|
59
|
-
nitro::ReactProp<std::optional<bool>> round;
|
|
60
59
|
nitro::ReactProp<std::optional<double>> resizeWidth;
|
|
61
60
|
nitro::ReactProp<std::optional<double>> overscan;
|
|
62
61
|
nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>> loadingStrategy;
|
|
@@ -78,7 +77,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
78
77
|
autoplay.hasSameValue(other.autoplay) &&
|
|
79
78
|
recyclingKey.hasSameValue(other.recyclingKey) &&
|
|
80
79
|
optimizeTos.hasSameValue(other.optimizeTos) &&
|
|
81
|
-
round.hasSameValue(other.round) &&
|
|
82
80
|
resizeWidth.hasSameValue(other.resizeWidth) &&
|
|
83
81
|
overscan.hasSameValue(other.overscan) &&
|
|
84
82
|
loadingStrategy.hasSameValue(other.loadingStrategy) &&
|
|
@@ -101,7 +99,6 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
101
99
|
autoplay.isProvided() ||
|
|
102
100
|
recyclingKey.isProvided() ||
|
|
103
101
|
optimizeTos.isProvided() ||
|
|
104
|
-
round.isProvided() ||
|
|
105
102
|
resizeWidth.isProvided() ||
|
|
106
103
|
overscan.isProvided() ||
|
|
107
104
|
loadingStrategy.isProvided() ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-image",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.155",
|
|
4
4
|
"description": "High-performance native image view for OneKey",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"typescript": "^5.9.2"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@onekeyfe/react-native-skeleton": "3.0.
|
|
84
|
+
"@onekeyfe/react-native-skeleton": "3.0.155",
|
|
85
85
|
"react": "*",
|
|
86
86
|
"react-native": "*",
|
|
87
87
|
"react-native-nitro-modules": "0.37.0"
|
package/src/OneKeyImage.nitro.ts
CHANGED
|
@@ -43,8 +43,6 @@ export interface OneKeyImageNativeProps extends HybridViewProps {
|
|
|
43
43
|
autoplay?: boolean;
|
|
44
44
|
recyclingKey?: string;
|
|
45
45
|
optimizeTos?: boolean;
|
|
46
|
-
/** Clips the native image to an oval using its current bounds. */
|
|
47
|
-
round?: boolean;
|
|
48
46
|
/** Display width hint in layout units. Native applies the screen density. */
|
|
49
47
|
resizeWidth?: number;
|
|
50
48
|
overscan?: number;
|
package/src/index.tsx
CHANGED
|
@@ -153,7 +153,6 @@ export function OneKeyImage({
|
|
|
153
153
|
autoplay,
|
|
154
154
|
recyclingKey,
|
|
155
155
|
optimizeTos = true,
|
|
156
|
-
round = false,
|
|
157
156
|
resizeWidth,
|
|
158
157
|
overscan = 1.1,
|
|
159
158
|
loadingStrategy = OneKeyImageLoadingStrategy.STATIC,
|
|
@@ -371,7 +370,6 @@ export function OneKeyImage({
|
|
|
371
370
|
autoplay: autoplay ?? Platform.OS !== 'android',
|
|
372
371
|
recyclingKey,
|
|
373
372
|
optimizeTos,
|
|
374
|
-
round,
|
|
375
373
|
resizeWidth,
|
|
376
374
|
overscan,
|
|
377
375
|
loadingStrategy:
|