@nativescript-community/ui-image 4.3.0 → 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 CHANGED
@@ -3,6 +3,36 @@
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
+
14
+ ## [4.3.2](https://github.com/nativescript-community/ui-image/compare/v4.3.1...v4.3.2) (2022-07-15)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **image:** imageRotation scaling fix ([2f12172](https://github.com/nativescript-community/ui-image/commit/2f12172c022c9e6122420763a43b68a2bc137503))
20
+
21
+
22
+
23
+
24
+
25
+ ## [4.3.1](https://github.com/nativescript-community/ui-image/compare/v4.3.0...v4.3.1) (2022-07-14)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **image:** make imageRotation work in ListView ([58913bd](https://github.com/nativescript-community/ui-image/commit/58913bde275284ed704fac07b4154c11090bc7b9))
31
+
32
+
33
+
34
+
35
+
6
36
  # [4.3.0](https://github.com/nativescript-community/ui-image/compare/v4.2.1...v4.3.0) (2022-07-13)
7
37
 
8
38
 
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
@@ -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.substr(RESOURCE_PREFIX.length);
63
- const identifier = res.getIdentifier(resName, 'drawable', ad.getApplication().getPackageName());
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 _e;
320
+ var _u;
315
321
  const scaleType = this.nativeImageViewProtected.getHierarchy().getActualImageScaleType();
316
- (_e = scaleType['setImageRotation']) === null || _e === void 0 ? void 0 : _e.call(scaleType, value);
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
- [_a = ImageBase.srcProperty.setNative]() {
340
+ [_q = ImageBase.srcProperty.setNative]() {
335
341
  this.initImage();
336
342
  }
337
- [_b = ImageBase.lowerResSrcProperty.setNative]() {
343
+ [_r = ImageBase.lowerResSrcProperty.setNative]() {
338
344
  this.initImage();
339
345
  }
340
- [_c = ImageBase.blurDownSamplingProperty.setNative]() {
346
+ [_s = ImageBase.blurDownSamplingProperty.setNative]() {
341
347
  this.initImage();
342
348
  }
343
- [_d = ImageBase.aspectRatioProperty.setNative]() {
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
- needRequestImage
670
+ needUpdateHierarchy
665
671
  ], Img.prototype, _a, null);
666
672
  __decorate([
667
- needRequestImage
673
+ needUpdateHierarchy
668
674
  ], Img.prototype, _b, null);
669
675
  __decorate([
670
- needRequestImage
676
+ needUpdateHierarchy
671
677
  ], Img.prototype, _c, null);
672
678
  __decorate([
673
- needRequestImage
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();
@@ -772,24 +820,24 @@ function getScaleType(scaleType) {
772
820
  if (isString(scaleType)) {
773
821
  switch (scaleType) {
774
822
  case ScaleType.Center:
775
- return com.nativescript.image.ScalingUtils.ScaleType.CENTER;
823
+ return new com.nativescript.image.ScalingUtils.ScaleTypeCenter();
776
824
  case ScaleType.AspectFill:
777
825
  case ScaleType.CenterCrop:
778
- return com.nativescript.image.ScalingUtils.ScaleType.CENTER_CROP;
826
+ return new com.nativescript.image.ScalingUtils.ScaleTypeCenterCrop();
779
827
  case ScaleType.CenterInside:
780
- return com.nativescript.image.ScalingUtils.ScaleType.CENTER_INSIDE;
828
+ return new com.nativescript.image.ScalingUtils.ScaleTypeCenterInside();
781
829
  case ScaleType.FitCenter:
782
830
  case ScaleType.AspectFit:
783
- return com.nativescript.image.ScalingUtils.ScaleType.FIT_CENTER;
831
+ return new com.nativescript.image.ScalingUtils.ScaleTypeFitCenter();
784
832
  case ScaleType.FitEnd:
785
- return com.nativescript.image.ScalingUtils.ScaleType.FIT_END;
833
+ return new com.nativescript.image.ScalingUtils.ScaleTypeFitEnd();
786
834
  case ScaleType.FitStart:
787
- return com.nativescript.image.ScalingUtils.ScaleType.FIT_START;
835
+ return new com.nativescript.image.ScalingUtils.ScaleTypeFitStart();
788
836
  case ScaleType.Fill:
789
837
  case ScaleType.FitXY:
790
- return com.nativescript.image.ScalingUtils.ScaleType.FIT_XY;
838
+ return new com.nativescript.image.ScalingUtils.ScaleTypeFitXY();
791
839
  case ScaleType.FocusCrop:
792
- return com.nativescript.image.ScalingUtils.ScaleType.FOCUS_CROP;
840
+ return new com.nativescript.image.ScalingUtils.ScaleTypeFocusCrop();
793
841
  default:
794
842
  break;
795
843
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.3.0",
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": "33aa9b9b923101c0c3f37f22a3ebaf245d6aa91e"
47
+ "gitHead": "a216a880fc8c0d1c166e0a52a1c97443913d583e"
48
48
  }
@@ -144,13 +144,18 @@ public class ScalingUtils {
144
144
  float focusY) {
145
145
  float sX = (float) parentRect.width() / (float) childWidth;
146
146
  float sY = (float) parentRect.height() / (float) childHeight;
147
- float rotationDelta = _imageRotation % 180;
148
- if (rotationDelta != 0) {
147
+ float rotationDelta = (90 - (_imageRotation % 180))/90.0f;
148
+ if (rotationDelta != 1) {
149
149
  float destSX = (float) parentRect.width() / (float) childHeight;
150
150
  float destSY = (float) parentRect.height() / (float) childWidth;
151
- final float pos = Math.abs(rotationDelta)/90.0f;
152
- sX = sX + pos * (destSX - sX);
153
- sY = sY + pos * (destSY - sY);
151
+ if (rotationDelta < 0) {
152
+ sX = destSX + rotationDelta * (destSX - sX);
153
+ sY = destSY + rotationDelta * (destSY - sY);
154
+ } else {
155
+ sX = sX + (1 - rotationDelta) * (destSX - sX);
156
+ sY = sY + (1 - rotationDelta) * (destSY - sY);
157
+ }
158
+
154
159
  }
155
160
  getTransformImpl(outTransform, parentRect, childWidth, childHeight, focusX, focusY, sX, sY);
156
161
  if (_imageMatrix != null) {
@@ -173,7 +178,7 @@ public class ScalingUtils {
173
178
  float scaleY);
174
179
  }
175
180
 
176
- private static class ScaleTypeFitXY extends AbstractScaleType {
181
+ public static class ScaleTypeFitXY extends AbstractScaleType {
177
182
 
178
183
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitXY();
179
184
 
@@ -199,7 +204,7 @@ public class ScalingUtils {
199
204
  }
200
205
  }
201
206
 
202
- private static class ScaleTypeFitStart extends AbstractScaleType {
207
+ public static class ScaleTypeFitStart extends AbstractScaleType {
203
208
 
204
209
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitStart();
205
210
 
@@ -226,7 +231,7 @@ public class ScalingUtils {
226
231
  }
227
232
  }
228
233
 
229
- private static class ScaleTypeFitBottomStart extends AbstractScaleType {
234
+ public static class ScaleTypeFitBottomStart extends AbstractScaleType {
230
235
 
231
236
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitBottomStart();
232
237
 
@@ -253,7 +258,7 @@ public class ScalingUtils {
253
258
  }
254
259
  }
255
260
 
256
- private static class ScaleTypeFitCenter extends AbstractScaleType {
261
+ public static class ScaleTypeFitCenter extends AbstractScaleType {
257
262
 
258
263
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitCenter();
259
264
 
@@ -280,7 +285,7 @@ public class ScalingUtils {
280
285
  }
281
286
  }
282
287
 
283
- private static class ScaleTypeFitEnd extends AbstractScaleType {
288
+ public static class ScaleTypeFitEnd extends AbstractScaleType {
284
289
 
285
290
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitEnd();
286
291
 
@@ -307,7 +312,7 @@ public class ScalingUtils {
307
312
  }
308
313
  }
309
314
 
310
- private static class ScaleTypeCenter extends AbstractScaleType {
315
+ public static class ScaleTypeCenter extends AbstractScaleType {
311
316
 
312
317
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeCenter();
313
318
 
@@ -332,7 +337,7 @@ public class ScalingUtils {
332
337
  }
333
338
  }
334
339
 
335
- private static class ScaleTypeCenterInside extends AbstractScaleType {
340
+ public static class ScaleTypeCenterInside extends AbstractScaleType {
336
341
 
337
342
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeCenterInside();
338
343
 
@@ -359,7 +364,7 @@ public class ScalingUtils {
359
364
  }
360
365
  }
361
366
 
362
- private static class ScaleTypeCenterCrop extends AbstractScaleType {
367
+ public static class ScaleTypeCenterCrop extends AbstractScaleType {
363
368
 
364
369
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeCenterCrop();
365
370
 
@@ -393,7 +398,7 @@ public class ScalingUtils {
393
398
  }
394
399
  }
395
400
 
396
- private static class ScaleTypeFocusCrop extends AbstractScaleType {
401
+ public static class ScaleTypeFocusCrop extends AbstractScaleType {
397
402
 
398
403
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFocusCrop();
399
404
 
@@ -429,7 +434,7 @@ public class ScalingUtils {
429
434
  }
430
435
  }
431
436
 
432
- private static class ScaleTypeFitX extends AbstractScaleType {
437
+ public static class ScaleTypeFitX extends AbstractScaleType {
433
438
 
434
439
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitX();
435
440
 
@@ -457,7 +462,7 @@ public class ScalingUtils {
457
462
  }
458
463
  }
459
464
 
460
- private static class ScaleTypeFitY extends AbstractScaleType {
465
+ public static class ScaleTypeFitY extends AbstractScaleType {
461
466
 
462
467
  public static final com.facebook.drawee.drawable.ScalingUtils.ScaleType INSTANCE = new ScaleTypeFitY();
463
468
 
Binary file