@nativescript-community/ui-image 4.3.2 → 4.3.3
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/CHANGELOG.md +8 -0
- package/index-common.d.ts +2 -0
- package/index-common.js +5 -0
- package/index.android.d.ts +1 -0
- package/index.android.js +86 -38
- package/package.json +2 -2
- package/platforms/android/ui_image.aar +0 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.3.3](https://github.com/nativescript-community/ui-image/compare/v4.3.2...v4.3.3) (2022-09-12)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
6
14
|
## [4.3.2](https://github.com/nativescript-community/ui-image/compare/v4.3.1...v4.3.2) (2022-07-15)
|
7
15
|
|
8
16
|
|
package/index-common.d.ts
CHANGED
@@ -84,6 +84,7 @@ export declare class ImageBase extends View {
|
|
84
84
|
decodeWidth: number;
|
85
85
|
decodeHeight: number;
|
86
86
|
animatedImageView: boolean;
|
87
|
+
loadMode: 'sync' | 'async';
|
87
88
|
alwaysFade: boolean;
|
88
89
|
noCache: boolean;
|
89
90
|
tintColor: Color;
|
@@ -115,6 +116,7 @@ export declare class ImageBase extends View {
|
|
115
116
|
static roundTopRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
116
117
|
static roundBottomLeftRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
117
118
|
static roundBottomRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
|
119
|
+
static loadModeProperty: Property<ImageBase, "sync" | "async">;
|
118
120
|
static clipToBoundsProperty: Property<ImageBase, boolean>;
|
119
121
|
static animatedImageViewProperty: Property<ImageBase, boolean>;
|
120
122
|
get nativeImageViewProtected(): any;
|
package/index-common.js
CHANGED
@@ -168,6 +168,10 @@ ImageBase.roundBottomRightRadiusProperty = new Property({
|
|
168
168
|
defaultValue: 0,
|
169
169
|
valueConverter: (v) => Length.toDevicePixels(Length.parse(v))
|
170
170
|
});
|
171
|
+
ImageBase.loadModeProperty = new Property({
|
172
|
+
name: 'loadMode',
|
173
|
+
defaultValue: 'sync'
|
174
|
+
});
|
171
175
|
ImageBase.clipToBoundsProperty = new Property({ name: 'clipToBounds', defaultValue: true, valueConverter: booleanConverter });
|
172
176
|
ImageBase.animatedImageViewProperty = new Property({ name: 'animatedImageView', defaultValue: false, valueConverter: booleanConverter });
|
173
177
|
ImageBase.srcProperty.register(ImageBase);
|
@@ -198,4 +202,5 @@ ImageBase.alwaysFadeProperty.register(ImageBase);
|
|
198
202
|
ImageBase.noCacheProperty.register(ImageBase);
|
199
203
|
ImageBase.clipToBoundsProperty.register(ImageBase);
|
200
204
|
ImageBase.animatedImageViewProperty.register(ImageBase);
|
205
|
+
ImageBase.loadModeProperty.register(ImageBase);
|
201
206
|
//# sourceMappingURL=index-common.js.map
|
package/index.android.d.ts
CHANGED
@@ -62,6 +62,7 @@ export declare class FailureEventData extends EventData {
|
|
62
62
|
set error(value: ImageError);
|
63
63
|
}
|
64
64
|
export declare const needRequestImage: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
65
|
+
export declare const needUpdateHierarchy: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
65
66
|
export declare class Img extends ImageBase {
|
66
67
|
nativeViewProtected: com.nativescript.image.DraweeView;
|
67
68
|
nativeImageViewProtected: com.nativescript.image.DraweeView;
|
package/index.android.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _a, _b, _c, _d;
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
2
2
|
export * from './index-common';
|
3
3
|
import { Color, Image, ImageAsset, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
|
4
4
|
import { android as androidApp } from '@nativescript/core/application';
|
@@ -54,13 +54,9 @@ function getUri(src) {
|
|
54
54
|
imagePath = src;
|
55
55
|
}
|
56
56
|
if (isFileOrResourcePath(imagePath)) {
|
57
|
-
const res = ad.getApplicationContext().getResources();
|
58
|
-
if (!res) {
|
59
|
-
return null;
|
60
|
-
}
|
61
57
|
if (imagePath.indexOf(RESOURCE_PREFIX) === 0) {
|
62
|
-
const resName = imagePath.
|
63
|
-
const identifier =
|
58
|
+
const resName = imagePath.substring(RESOURCE_PREFIX.length);
|
59
|
+
const identifier = Utils.ad.resources.getDrawableId(resName);
|
64
60
|
if (0 < identifier) {
|
65
61
|
uri = new android.net.Uri.Builder().scheme(com.facebook.common.util.UriUtil.LOCAL_RESOURCE_SCHEME).path(java.lang.String.valueOf(identifier)).build();
|
66
62
|
}
|
@@ -219,6 +215,16 @@ export const needRequestImage = function (target, propertyKey, descriptor) {
|
|
219
215
|
return originalMethod.apply(this, args);
|
220
216
|
};
|
221
217
|
};
|
218
|
+
export const needUpdateHierarchy = function (target, propertyKey, descriptor) {
|
219
|
+
const originalMethod = descriptor.value;
|
220
|
+
descriptor.value = function (...args) {
|
221
|
+
if (!this._canUpdateHierarchy) {
|
222
|
+
this._needUpdateHierarchy = true;
|
223
|
+
return;
|
224
|
+
}
|
225
|
+
return originalMethod.apply(this, args);
|
226
|
+
};
|
227
|
+
};
|
222
228
|
export class Img extends ImageBase {
|
223
229
|
constructor() {
|
224
230
|
super(...arguments);
|
@@ -283,64 +289,64 @@ export class Img extends ImageBase {
|
|
283
289
|
this.src = null;
|
284
290
|
this.src = src;
|
285
291
|
}
|
286
|
-
[ImageBase.placeholderImageUriProperty.setNative]() {
|
292
|
+
[_a = ImageBase.placeholderImageUriProperty.setNative]() {
|
287
293
|
this.updateHierarchy();
|
288
294
|
}
|
289
|
-
[ImageBase.failureImageUriProperty.setNative]() {
|
295
|
+
[_b = ImageBase.failureImageUriProperty.setNative]() {
|
290
296
|
this.updateHierarchy();
|
291
297
|
}
|
292
|
-
[ImageBase.stretchProperty.setNative]() {
|
298
|
+
[_c = ImageBase.stretchProperty.setNative]() {
|
293
299
|
this.updateHierarchy();
|
294
300
|
}
|
295
|
-
[ImageBase.fadeDurationProperty.setNative]() {
|
301
|
+
[_d = ImageBase.fadeDurationProperty.setNative]() {
|
296
302
|
this.updateHierarchy();
|
297
303
|
}
|
298
|
-
[ImageBase.backgroundUriProperty.setNative]() {
|
304
|
+
[_e = ImageBase.backgroundUriProperty.setNative]() {
|
299
305
|
this.updateHierarchy();
|
300
306
|
}
|
301
|
-
[ImageBase.showProgressBarProperty.setNative]() {
|
307
|
+
[_f = ImageBase.showProgressBarProperty.setNative]() {
|
302
308
|
this.updateHierarchy();
|
303
309
|
}
|
304
|
-
[ImageBase.progressBarColorProperty.setNative]() {
|
310
|
+
[_g = ImageBase.progressBarColorProperty.setNative]() {
|
305
311
|
this.updateHierarchy();
|
306
312
|
}
|
307
|
-
[ImageBase.roundAsCircleProperty.setNative]() {
|
313
|
+
[_h = ImageBase.roundAsCircleProperty.setNative]() {
|
308
314
|
this.updateHierarchy();
|
309
315
|
}
|
310
|
-
[ImageBase.roundTopLeftRadiusProperty.setNative]() {
|
316
|
+
[_j = ImageBase.roundTopLeftRadiusProperty.setNative]() {
|
311
317
|
this.updateHierarchy();
|
312
318
|
}
|
313
319
|
[ImageBase.imageRotationProperty.setNative](value) {
|
314
|
-
var
|
320
|
+
var _u;
|
315
321
|
const scaleType = this.nativeImageViewProtected.getHierarchy().getActualImageScaleType();
|
316
|
-
(
|
322
|
+
(_u = scaleType['setImageRotation']) === null || _u === void 0 ? void 0 : _u.call(scaleType, value);
|
317
323
|
this.nativeImageViewProtected.invalidate();
|
318
324
|
}
|
319
|
-
[ImageBase.roundTopRightRadiusProperty.setNative]() {
|
325
|
+
[_k = ImageBase.roundTopRightRadiusProperty.setNative]() {
|
320
326
|
this.updateHierarchy();
|
321
327
|
}
|
322
|
-
[ImageBase.roundBottomLeftRadiusProperty.setNative]() {
|
328
|
+
[_l = ImageBase.roundBottomLeftRadiusProperty.setNative]() {
|
323
329
|
this.updateHierarchy();
|
324
330
|
}
|
325
|
-
[ImageBase.roundBottomRightRadiusProperty.setNative]() {
|
331
|
+
[_m = ImageBase.roundBottomRightRadiusProperty.setNative]() {
|
326
332
|
this.updateHierarchy();
|
327
333
|
}
|
328
|
-
[ImageBase.tintColorProperty.setNative](value) {
|
334
|
+
[_o = ImageBase.tintColorProperty.setNative](value) {
|
329
335
|
this.updateHierarchy();
|
330
336
|
}
|
331
|
-
[ImageBase.blurRadiusProperty.setNative]() {
|
337
|
+
[_p = ImageBase.blurRadiusProperty.setNative]() {
|
332
338
|
this.initImage();
|
333
339
|
}
|
334
|
-
[
|
340
|
+
[_q = ImageBase.srcProperty.setNative]() {
|
335
341
|
this.initImage();
|
336
342
|
}
|
337
|
-
[
|
343
|
+
[_r = ImageBase.lowerResSrcProperty.setNative]() {
|
338
344
|
this.initImage();
|
339
345
|
}
|
340
|
-
[
|
346
|
+
[_s = ImageBase.blurDownSamplingProperty.setNative]() {
|
341
347
|
this.initImage();
|
342
348
|
}
|
343
|
-
[
|
349
|
+
[_t = ImageBase.aspectRatioProperty.setNative]() {
|
344
350
|
this.initImage();
|
345
351
|
}
|
346
352
|
async initImage() {
|
@@ -369,8 +375,12 @@ export class Img extends ImageBase {
|
|
369
375
|
hierarchy.setImage(drawable, 1, hierarchy.getFadeDuration() === 0);
|
370
376
|
return;
|
371
377
|
}
|
378
|
+
const uri = getUri(src);
|
379
|
+
if (!uri) {
|
380
|
+
console.log(`Error: 'src' not valid: ${src}`);
|
381
|
+
return;
|
382
|
+
}
|
372
383
|
if (this.noCache) {
|
373
|
-
const uri = getUri(src);
|
374
384
|
const imagePipeLine = getImagePipeline();
|
375
385
|
const isInCache = imagePipeLine.isInBitmapMemoryCache(uri);
|
376
386
|
if (isInCache) {
|
@@ -378,11 +388,6 @@ export class Img extends ImageBase {
|
|
378
388
|
}
|
379
389
|
}
|
380
390
|
this.isLoading = true;
|
381
|
-
const uri = getUri(src);
|
382
|
-
if (!uri) {
|
383
|
-
console.log(`Error: 'src' not valid: ${src}`);
|
384
|
-
return;
|
385
|
-
}
|
386
391
|
let requestBuilder = com.facebook.imagepipeline.request.ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions(com.facebook.imagepipeline.common.RotationOptions.autoRotate());
|
387
392
|
if (this.progressiveRenderingEnabled === true) {
|
388
393
|
requestBuilder = requestBuilder.setProgressiveRenderingEnabled(this.progressiveRenderingEnabled);
|
@@ -423,7 +428,7 @@ export class Img extends ImageBase {
|
|
423
428
|
},
|
424
429
|
onFailure(id, throwable) {
|
425
430
|
if (Trace.isEnabled()) {
|
426
|
-
CLog(CLogTypes.info, 'onFailure', id, throwable);
|
431
|
+
CLog(CLogTypes.info, 'onFailure', id, throwable.getLocalizedMessage());
|
427
432
|
}
|
428
433
|
const nativeView = that && that.get();
|
429
434
|
if (nativeView) {
|
@@ -536,6 +541,7 @@ export class Img extends ImageBase {
|
|
536
541
|
}
|
537
542
|
const controller = builder.build();
|
538
543
|
this.nativeImageViewProtected.setController(controller);
|
544
|
+
console.log('setController', this, src, uri);
|
539
545
|
}
|
540
546
|
else {
|
541
547
|
this.nativeImageViewProtected.setController(null);
|
@@ -661,17 +667,59 @@ export class Img extends ImageBase {
|
|
661
667
|
}
|
662
668
|
}
|
663
669
|
__decorate([
|
664
|
-
|
670
|
+
needUpdateHierarchy
|
665
671
|
], Img.prototype, _a, null);
|
666
672
|
__decorate([
|
667
|
-
|
673
|
+
needUpdateHierarchy
|
668
674
|
], Img.prototype, _b, null);
|
669
675
|
__decorate([
|
670
|
-
|
676
|
+
needUpdateHierarchy
|
671
677
|
], Img.prototype, _c, null);
|
672
678
|
__decorate([
|
673
|
-
|
679
|
+
needUpdateHierarchy
|
674
680
|
], Img.prototype, _d, null);
|
681
|
+
__decorate([
|
682
|
+
needUpdateHierarchy
|
683
|
+
], Img.prototype, _e, null);
|
684
|
+
__decorate([
|
685
|
+
needUpdateHierarchy
|
686
|
+
], Img.prototype, _f, null);
|
687
|
+
__decorate([
|
688
|
+
needUpdateHierarchy
|
689
|
+
], Img.prototype, _g, null);
|
690
|
+
__decorate([
|
691
|
+
needUpdateHierarchy
|
692
|
+
], Img.prototype, _h, null);
|
693
|
+
__decorate([
|
694
|
+
needUpdateHierarchy
|
695
|
+
], Img.prototype, _j, null);
|
696
|
+
__decorate([
|
697
|
+
needUpdateHierarchy
|
698
|
+
], Img.prototype, _k, null);
|
699
|
+
__decorate([
|
700
|
+
needUpdateHierarchy
|
701
|
+
], Img.prototype, _l, null);
|
702
|
+
__decorate([
|
703
|
+
needUpdateHierarchy
|
704
|
+
], Img.prototype, _m, null);
|
705
|
+
__decorate([
|
706
|
+
needUpdateHierarchy
|
707
|
+
], Img.prototype, _o, null);
|
708
|
+
__decorate([
|
709
|
+
needRequestImage
|
710
|
+
], Img.prototype, _p, null);
|
711
|
+
__decorate([
|
712
|
+
needRequestImage
|
713
|
+
], Img.prototype, _q, null);
|
714
|
+
__decorate([
|
715
|
+
needRequestImage
|
716
|
+
], Img.prototype, _r, null);
|
717
|
+
__decorate([
|
718
|
+
needRequestImage
|
719
|
+
], Img.prototype, _s, null);
|
720
|
+
__decorate([
|
721
|
+
needRequestImage
|
722
|
+
], Img.prototype, _t, null);
|
675
723
|
class GenericDraweeHierarchyBuilder {
|
676
724
|
constructor() {
|
677
725
|
const res = ad.getApplicationContext().getResources();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-image",
|
3
|
-
"version": "4.3.
|
3
|
+
"version": "4.3.3",
|
4
4
|
"description": "Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.",
|
5
5
|
"main": "./index",
|
6
6
|
"sideEffects": false,
|
@@ -44,5 +44,5 @@
|
|
44
44
|
},
|
45
45
|
"license": "Apache-2.0",
|
46
46
|
"readmeFilename": "README.md",
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "a216a880fc8c0d1c166e0a52a1c97443913d583e"
|
48
48
|
}
|
Binary file
|