@onekeyfe/react-native-image 3.0.156 → 3.0.157-alpha.249
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 +3 -0
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImage.kt +293 -20
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImageCache.kt +34 -4
- package/android/src/main/java/com/margelo/nitro/onekeyimage/OneKeyImageMemoryVariants.kt +119 -0
- package/android/src/test/java/com/margelo/nitro/onekeyimage/OneKeyImageMemoryVariantsTest.kt +149 -0
- package/ios/OneKeyImage.swift +268 -38
- package/ios/OneKeyImageCache.swift +40 -3
- package/ios/OneKeyImageMemoryVariants.swift +137 -0
- package/ios/OneKeyImageRequestContext.swift +55 -0
- package/ios/tests/OneKeyImageInfrastructureTests.swift +218 -0
- package/lib/module/index.js +24 -3
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.cpp +9 -0
- package/lib/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.hpp +2 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridOneKeyImageStateUpdater.cpp +5 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt +6 -0
- package/lib/nitrogen/generated/ios/c++/HybridOneKeyImageSpecSwift.hpp +7 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridOneKeyImageComponent.mm +6 -0
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyImageSpec.swift +1 -0
- package/lib/nitrogen/generated/ios/swift/HybridOneKeyImageSpec_cxx.swift +24 -0
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.hpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.cpp +2 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.hpp +3 -0
- package/lib/nitrogen/generated/shared/json/OneKeyImageConfig.json +1 -0
- package/lib/typescript/src/OneKeyImage.nitro.d.ts +6 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridOneKeyImageSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/views/JHybridOneKeyImageStateUpdater.cpp +5 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt +6 -0
- package/nitrogen/generated/ios/c++/HybridOneKeyImageSpecSwift.hpp +7 -0
- package/nitrogen/generated/ios/c++/views/HybridOneKeyImageComponent.mm +6 -0
- package/nitrogen/generated/ios/swift/HybridOneKeyImageSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridOneKeyImageSpec_cxx.swift +24 -0
- package/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOneKeyImageSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.cpp +2 -0
- package/nitrogen/generated/shared/c++/views/HybridOneKeyImageComponent.hpp +3 -0
- package/nitrogen/generated/shared/json/OneKeyImageConfig.json +1 -0
- package/package.json +2 -2
- package/src/OneKeyImage.nitro.ts +6 -0
- package/src/index.tsx +23 -1
|
@@ -58,6 +58,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
58
58
|
nitro::ReactProp<std::optional<bool>> optimizeTos;
|
|
59
59
|
nitro::ReactProp<std::optional<bool>> round;
|
|
60
60
|
nitro::ReactProp<std::optional<double>> resizeWidth;
|
|
61
|
+
nitro::ReactProp<std::optional<double>> resizeHeight;
|
|
61
62
|
nitro::ReactProp<std::optional<double>> overscan;
|
|
62
63
|
nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>> loadingStrategy;
|
|
63
64
|
nitro::ReactProp<std::optional<std::string>> placeholderColor;
|
|
@@ -80,6 +81,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
80
81
|
optimizeTos.hasSameValue(other.optimizeTos) &&
|
|
81
82
|
round.hasSameValue(other.round) &&
|
|
82
83
|
resizeWidth.hasSameValue(other.resizeWidth) &&
|
|
84
|
+
resizeHeight.hasSameValue(other.resizeHeight) &&
|
|
83
85
|
overscan.hasSameValue(other.overscan) &&
|
|
84
86
|
loadingStrategy.hasSameValue(other.loadingStrategy) &&
|
|
85
87
|
placeholderColor.hasSameValue(other.placeholderColor) &&
|
|
@@ -103,6 +105,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
103
105
|
optimizeTos.isProvided() ||
|
|
104
106
|
round.isProvided() ||
|
|
105
107
|
resizeWidth.isProvided() ||
|
|
108
|
+
resizeHeight.isProvided() ||
|
|
106
109
|
overscan.isProvided() ||
|
|
107
110
|
loadingStrategy.isProvided() ||
|
|
108
111
|
placeholderColor.isProvided() ||
|
|
@@ -36,6 +36,12 @@ export interface OneKeyImageNativeProps extends HybridViewProps {
|
|
|
36
36
|
round?: boolean;
|
|
37
37
|
/** Display width hint in layout units. Native applies the screen density. */
|
|
38
38
|
resizeWidth?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Display height hint in layout units. With `resizeWidth` it lets the
|
|
41
|
+
* pre-layout memory-cache probe derive the same decode thumbnail a preload
|
|
42
|
+
* with the same hints stored; omitted, the hint is a square of `resizeWidth`.
|
|
43
|
+
*/
|
|
44
|
+
resizeHeight?: number;
|
|
39
45
|
overscan?: number;
|
|
40
46
|
loadingStrategy?: OneKeyImageLoadingStrategy;
|
|
41
47
|
/** Theme-aware color used by static loading, error, and fallback states. */
|
|
@@ -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, round, resizeWidth, overscan, loadingStrategy, placeholderColor, hybridRef, onLoadStart, onLoad, onDisplay, onError, onLoadEnd, style, ...viewProps }: OneKeyImageProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare function OneKeyImage({ source, placeholder, fallback, variant, contentFit, cachePolicy, autoplay, recyclingKey, optimizeTos, round, resizeWidth, resizeHeight, 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>;
|
|
@@ -156,6 +156,15 @@ namespace margelo::nitro::onekeyimage {
|
|
|
156
156
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* resizeWidth */)>("setResizeWidth");
|
|
157
157
|
method(_javaPart, resizeWidth.has_value() ? jni::JDouble::valueOf(resizeWidth.value()) : nullptr);
|
|
158
158
|
}
|
|
159
|
+
std::optional<double> JHybridOneKeyImageSpec::getResizeHeight() {
|
|
160
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getResizeHeight");
|
|
161
|
+
auto __result = method(_javaPart);
|
|
162
|
+
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
|
|
163
|
+
}
|
|
164
|
+
void JHybridOneKeyImageSpec::setResizeHeight(std::optional<double> resizeHeight) {
|
|
165
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* resizeHeight */)>("setResizeHeight");
|
|
166
|
+
method(_javaPart, resizeHeight.has_value() ? jni::JDouble::valueOf(resizeHeight.value()) : nullptr);
|
|
167
|
+
}
|
|
159
168
|
std::optional<double> JHybridOneKeyImageSpec::getOverscan() {
|
|
160
169
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getOverscan");
|
|
161
170
|
auto __result = method(_javaPart);
|
|
@@ -70,6 +70,8 @@ namespace margelo::nitro::onekeyimage {
|
|
|
70
70
|
void setRound(std::optional<bool> round) override;
|
|
71
71
|
std::optional<double> getResizeWidth() override;
|
|
72
72
|
void setResizeWidth(std::optional<double> resizeWidth) override;
|
|
73
|
+
std::optional<double> getResizeHeight() override;
|
|
74
|
+
void setResizeHeight(std::optional<double> resizeHeight) override;
|
|
73
75
|
std::optional<double> getOverscan() override;
|
|
74
76
|
void setOverscan(std::optional<double> overscan) override;
|
|
75
77
|
std::optional<OneKeyImageLoadingStrategy> getLoadingStrategy() override;
|
|
@@ -103,6 +103,11 @@ void JHybridOneKeyImageStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
|
|
|
103
103
|
: !newProps->resizeWidth.hasSameValue(oldProps->resizeWidth)) {
|
|
104
104
|
hybridView->setResizeWidth(newProps->resizeWidth.get());
|
|
105
105
|
}
|
|
106
|
+
if (oldProps == nullptr
|
|
107
|
+
? newProps->resizeHeight.isProvided()
|
|
108
|
+
: !newProps->resizeHeight.hasSameValue(oldProps->resizeHeight)) {
|
|
109
|
+
hybridView->setResizeHeight(newProps->resizeHeight.get());
|
|
110
|
+
}
|
|
106
111
|
if (oldProps == nullptr
|
|
107
112
|
? newProps->overscan.isProvided()
|
|
108
113
|
: !newProps->overscan.hasSameValue(oldProps->overscan)) {
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/onekeyimage/HybridOneKeyImageSpec.kt
CHANGED
|
@@ -87,6 +87,12 @@ abstract class HybridOneKeyImageSpec: HybridView() {
|
|
|
87
87
|
@set:Keep
|
|
88
88
|
abstract var resizeWidth: Double?
|
|
89
89
|
|
|
90
|
+
@get:DoNotStrip
|
|
91
|
+
@get:Keep
|
|
92
|
+
@set:DoNotStrip
|
|
93
|
+
@set:Keep
|
|
94
|
+
abstract var resizeHeight: Double?
|
|
95
|
+
|
|
90
96
|
@get:DoNotStrip
|
|
91
97
|
@get:Keep
|
|
92
98
|
@set:DoNotStrip
|
|
@@ -148,6 +148,13 @@ namespace margelo::nitro::onekeyimage {
|
|
|
148
148
|
inline void setResizeWidth(std::optional<double> resizeWidth) noexcept override {
|
|
149
149
|
_swiftPart.setResizeWidth(resizeWidth);
|
|
150
150
|
}
|
|
151
|
+
inline std::optional<double> getResizeHeight() noexcept override {
|
|
152
|
+
auto __result = _swiftPart.getResizeHeight();
|
|
153
|
+
return __result;
|
|
154
|
+
}
|
|
155
|
+
inline void setResizeHeight(std::optional<double> resizeHeight) noexcept override {
|
|
156
|
+
_swiftPart.setResizeHeight(resizeHeight);
|
|
157
|
+
}
|
|
151
158
|
inline std::optional<double> getOverscan() noexcept override {
|
|
152
159
|
auto __result = _swiftPart.getOverscan();
|
|
153
160
|
return __result;
|
|
@@ -158,6 +158,12 @@ using namespace margelo::nitro::onekeyimage::views;
|
|
|
158
158
|
: !newViewProps.resizeWidth.hasSameValue(oldViewProps->resizeWidth)) {
|
|
159
159
|
swiftPart.setResizeWidth(newViewProps.resizeWidth.get());
|
|
160
160
|
}
|
|
161
|
+
// resizeHeight: optional
|
|
162
|
+
if (oldViewProps == nullptr
|
|
163
|
+
? newViewProps.resizeHeight.isProvided()
|
|
164
|
+
: !newViewProps.resizeHeight.hasSameValue(oldViewProps->resizeHeight)) {
|
|
165
|
+
swiftPart.setResizeHeight(newViewProps.resizeHeight.get());
|
|
166
|
+
}
|
|
161
167
|
// overscan: optional
|
|
162
168
|
if (oldViewProps == nullptr
|
|
163
169
|
? newViewProps.overscan.isProvided()
|
|
@@ -20,6 +20,7 @@ public protocol HybridOneKeyImageSpec_protocol: HybridObject, HybridView {
|
|
|
20
20
|
var optimizeTos: Bool? { get set }
|
|
21
21
|
var round: Bool? { get set }
|
|
22
22
|
var resizeWidth: Double? { get set }
|
|
23
|
+
var resizeHeight: Double? { get set }
|
|
23
24
|
var overscan: Double? { get set }
|
|
24
25
|
var loadingStrategy: OneKeyImageLoadingStrategy? { get set }
|
|
25
26
|
var placeholderColor: String? { get set }
|
|
@@ -340,6 +340,30 @@ open class HybridOneKeyImageSpec_cxx {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
public final var resizeHeight: bridge.std__optional_double_ {
|
|
344
|
+
@inline(__always)
|
|
345
|
+
get {
|
|
346
|
+
return { () -> bridge.std__optional_double_ in
|
|
347
|
+
if let __unwrappedValue = self.__implementation.resizeHeight {
|
|
348
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
349
|
+
} else {
|
|
350
|
+
return .init()
|
|
351
|
+
}
|
|
352
|
+
}()
|
|
353
|
+
}
|
|
354
|
+
@inline(__always)
|
|
355
|
+
set {
|
|
356
|
+
self.__implementation.resizeHeight = { () -> Double? in
|
|
357
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
358
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
359
|
+
return __unwrapped
|
|
360
|
+
} else {
|
|
361
|
+
return nil
|
|
362
|
+
}
|
|
363
|
+
}()
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
343
367
|
public final var overscan: bridge.std__optional_double_ {
|
|
344
368
|
@inline(__always)
|
|
345
369
|
get {
|
|
@@ -34,6 +34,8 @@ namespace margelo::nitro::onekeyimage {
|
|
|
34
34
|
prototype.registerHybridSetter("round", &HybridOneKeyImageSpec::setRound);
|
|
35
35
|
prototype.registerHybridGetter("resizeWidth", &HybridOneKeyImageSpec::getResizeWidth);
|
|
36
36
|
prototype.registerHybridSetter("resizeWidth", &HybridOneKeyImageSpec::setResizeWidth);
|
|
37
|
+
prototype.registerHybridGetter("resizeHeight", &HybridOneKeyImageSpec::getResizeHeight);
|
|
38
|
+
prototype.registerHybridSetter("resizeHeight", &HybridOneKeyImageSpec::setResizeHeight);
|
|
37
39
|
prototype.registerHybridGetter("overscan", &HybridOneKeyImageSpec::getOverscan);
|
|
38
40
|
prototype.registerHybridSetter("overscan", &HybridOneKeyImageSpec::setOverscan);
|
|
39
41
|
prototype.registerHybridGetter("loadingStrategy", &HybridOneKeyImageSpec::getLoadingStrategy);
|
|
@@ -80,6 +80,8 @@ namespace margelo::nitro::onekeyimage {
|
|
|
80
80
|
virtual void setRound(std::optional<bool> round) = 0;
|
|
81
81
|
virtual std::optional<double> getResizeWidth() = 0;
|
|
82
82
|
virtual void setResizeWidth(std::optional<double> resizeWidth) = 0;
|
|
83
|
+
virtual std::optional<double> getResizeHeight() = 0;
|
|
84
|
+
virtual void setResizeHeight(std::optional<double> resizeHeight) = 0;
|
|
83
85
|
virtual std::optional<double> getOverscan() = 0;
|
|
84
86
|
virtual void setOverscan(std::optional<double> overscan) = 0;
|
|
85
87
|
virtual std::optional<OneKeyImageLoadingStrategy> getLoadingStrategy() = 0;
|
|
@@ -30,6 +30,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
30
30
|
optimizeTos(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "optimizeTos", rawProps, sourceProps.optimizeTos)),
|
|
31
31
|
round(nitro::ReactProp<std::optional<bool>>::fromRawValue("OneKeyImage", "round", rawProps, sourceProps.round)),
|
|
32
32
|
resizeWidth(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "resizeWidth", rawProps, sourceProps.resizeWidth)),
|
|
33
|
+
resizeHeight(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "resizeHeight", rawProps, sourceProps.resizeHeight)),
|
|
33
34
|
overscan(nitro::ReactProp<std::optional<double>>::fromRawValue("OneKeyImage", "overscan", rawProps, sourceProps.overscan)),
|
|
34
35
|
loadingStrategy(nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>>::fromRawValue("OneKeyImage", "loadingStrategy", rawProps, sourceProps.loadingStrategy)),
|
|
35
36
|
placeholderColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("OneKeyImage", "placeholderColor", rawProps, sourceProps.placeholderColor)),
|
|
@@ -52,6 +53,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
52
53
|
case hashString("optimizeTos"): return true;
|
|
53
54
|
case hashString("round"): return true;
|
|
54
55
|
case hashString("resizeWidth"): return true;
|
|
56
|
+
case hashString("resizeHeight"): return true;
|
|
55
57
|
case hashString("overscan"): return true;
|
|
56
58
|
case hashString("loadingStrategy"): return true;
|
|
57
59
|
case hashString("placeholderColor"): return true;
|
|
@@ -58,6 +58,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
58
58
|
nitro::ReactProp<std::optional<bool>> optimizeTos;
|
|
59
59
|
nitro::ReactProp<std::optional<bool>> round;
|
|
60
60
|
nitro::ReactProp<std::optional<double>> resizeWidth;
|
|
61
|
+
nitro::ReactProp<std::optional<double>> resizeHeight;
|
|
61
62
|
nitro::ReactProp<std::optional<double>> overscan;
|
|
62
63
|
nitro::ReactProp<std::optional<OneKeyImageLoadingStrategy>> loadingStrategy;
|
|
63
64
|
nitro::ReactProp<std::optional<std::string>> placeholderColor;
|
|
@@ -80,6 +81,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
80
81
|
optimizeTos.hasSameValue(other.optimizeTos) &&
|
|
81
82
|
round.hasSameValue(other.round) &&
|
|
82
83
|
resizeWidth.hasSameValue(other.resizeWidth) &&
|
|
84
|
+
resizeHeight.hasSameValue(other.resizeHeight) &&
|
|
83
85
|
overscan.hasSameValue(other.overscan) &&
|
|
84
86
|
loadingStrategy.hasSameValue(other.loadingStrategy) &&
|
|
85
87
|
placeholderColor.hasSameValue(other.placeholderColor) &&
|
|
@@ -103,6 +105,7 @@ namespace margelo::nitro::onekeyimage::views {
|
|
|
103
105
|
optimizeTos.isProvided() ||
|
|
104
106
|
round.isProvided() ||
|
|
105
107
|
resizeWidth.isProvided() ||
|
|
108
|
+
resizeHeight.isProvided() ||
|
|
106
109
|
overscan.isProvided() ||
|
|
107
110
|
loadingStrategy.isProvided() ||
|
|
108
111
|
placeholderColor.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.157-alpha.249",
|
|
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.157-alpha.249",
|
|
85
85
|
"react": "*",
|
|
86
86
|
"react-native": "*",
|
|
87
87
|
"react-native-nitro-modules": "0.37.0"
|
package/src/OneKeyImage.nitro.ts
CHANGED
|
@@ -47,6 +47,12 @@ export interface OneKeyImageNativeProps extends HybridViewProps {
|
|
|
47
47
|
round?: boolean;
|
|
48
48
|
/** Display width hint in layout units. Native applies the screen density. */
|
|
49
49
|
resizeWidth?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Display height hint in layout units. With `resizeWidth` it lets the
|
|
52
|
+
* pre-layout memory-cache probe derive the same decode thumbnail a preload
|
|
53
|
+
* with the same hints stored; omitted, the hint is a square of `resizeWidth`.
|
|
54
|
+
*/
|
|
55
|
+
resizeHeight?: number;
|
|
50
56
|
overscan?: number;
|
|
51
57
|
loadingStrategy?: OneKeyImageLoadingStrategy;
|
|
52
58
|
/** Theme-aware color used by static loading, error, and fallback states. */
|
package/src/index.tsx
CHANGED
|
@@ -155,6 +155,7 @@ export function OneKeyImage({
|
|
|
155
155
|
optimizeTos = true,
|
|
156
156
|
round = false,
|
|
157
157
|
resizeWidth,
|
|
158
|
+
resizeHeight,
|
|
158
159
|
overscan = 1.1,
|
|
159
160
|
loadingStrategy = OneKeyImageLoadingStrategy.STATIC,
|
|
160
161
|
placeholderColor,
|
|
@@ -176,7 +177,7 @@ export function OneKeyImage({
|
|
|
176
177
|
normalized?.headers ?? {}
|
|
177
178
|
)}|${resolvedCachePolicy}|${recyclingKey ?? ''}|${contentFit}|${
|
|
178
179
|
optimizeTos ? '1' : '0'
|
|
179
|
-
}|${resizeWidth ?? ''}|${overscan}`;
|
|
180
|
+
}|${resizeWidth ?? ''}|${resizeHeight ?? ''}|${overscan}`;
|
|
180
181
|
const hasSource = normalized != null;
|
|
181
182
|
const hasOverlay = placeholder != null || fallback != null;
|
|
182
183
|
type LoadState = {
|
|
@@ -354,6 +355,7 @@ export function OneKeyImage({
|
|
|
354
355
|
borderEndStartRadius: flattenedStyle.borderEndStartRadius,
|
|
355
356
|
borderEndEndRadius: flattenedStyle.borderEndEndRadius,
|
|
356
357
|
zIndex: 1,
|
|
358
|
+
...(round ? ROUND_CLIP : null),
|
|
357
359
|
}
|
|
358
360
|
: undefined;
|
|
359
361
|
|
|
@@ -373,6 +375,7 @@ export function OneKeyImage({
|
|
|
373
375
|
optimizeTos,
|
|
374
376
|
round,
|
|
375
377
|
resizeWidth,
|
|
378
|
+
resizeHeight,
|
|
376
379
|
overscan,
|
|
377
380
|
loadingStrategy:
|
|
378
381
|
placeholder == null ? loadingStrategy : OneKeyImageLoadingStrategy.NONE,
|
|
@@ -387,6 +390,7 @@ export function OneKeyImage({
|
|
|
387
390
|
style,
|
|
388
391
|
styles.overlayContainer,
|
|
389
392
|
hasRoundedCorners ? styles.borderlessContainer : undefined,
|
|
393
|
+
round ? ROUND_CLIP : undefined,
|
|
390
394
|
]}
|
|
391
395
|
collapsable={false}
|
|
392
396
|
>
|
|
@@ -442,6 +446,24 @@ export const OneKeyImageCache = {
|
|
|
442
446
|
clearAll: () => nativeCache.clearAll(),
|
|
443
447
|
};
|
|
444
448
|
|
|
449
|
+
// `round` clips the native view to a circle: an oval path on Android
|
|
450
|
+
// (`OneKeyImage.kt` `addOval`), a `min(width, height) / 2` corner radius on iOS
|
|
451
|
+
// (`OneKeyImage.swift` `updateRoundMask`). The overlay container has to clip the
|
|
452
|
+
// same way, or a custom placeholder or fallback is painted square over a round
|
|
453
|
+
// image. A percentage radius says that without measuring the view, and covers
|
|
454
|
+
// every per-corner radius the caller's own style may have set.
|
|
455
|
+
const ROUND_CLIP = {
|
|
456
|
+
borderRadius: '50%',
|
|
457
|
+
borderTopLeftRadius: '50%',
|
|
458
|
+
borderTopRightRadius: '50%',
|
|
459
|
+
borderBottomLeftRadius: '50%',
|
|
460
|
+
borderBottomRightRadius: '50%',
|
|
461
|
+
borderStartStartRadius: '50%',
|
|
462
|
+
borderStartEndRadius: '50%',
|
|
463
|
+
borderEndStartRadius: '50%',
|
|
464
|
+
borderEndEndRadius: '50%',
|
|
465
|
+
} as const;
|
|
466
|
+
|
|
445
467
|
const styles = StyleSheet.create({
|
|
446
468
|
overlayContainer: {
|
|
447
469
|
overflow: 'hidden',
|