@nativescript-community/ui-image 4.1.2 → 4.1.6

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,50 @@
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.1.6](https://github.com/nativescript-community/ui-image/compare/v4.1.5...v4.1.6) (2022-02-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **android:** build fix ([d985433](https://github.com/nativescript-community/ui-image/commit/d9854332a780393c1677d045c3efdadc936a2d03))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.1.5](https://github.com/nativescript-community/ui-image/compare/v4.1.4...v4.1.5) (2022-02-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **android:** build fix with N forks ([dfb24ef](https://github.com/nativescript-community/ui-image/commit/dfb24efb98bc0a2b777b2261db71513b8ea215e8))
23
+
24
+
25
+
26
+
27
+
28
+ ## [4.1.4](https://github.com/nativescript-community/ui-image/compare/v4.1.3...v4.1.4) (2022-01-14)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **android:** missing native-api-usage ([0019db6](https://github.com/nativescript-community/ui-image/commit/0019db697a94bad4208aa1803f8baa8b96fb0554))
34
+
35
+
36
+
37
+
38
+
39
+ ## [4.1.3](https://github.com/nativescript-community/ui-image/compare/v4.1.2...v4.1.3) (2022-01-14)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * **ios:** fixed transforms not being applied. New `animatedImageView` property to be set when using animated images ([5fb20f1](https://github.com/nativescript-community/ui-image/commit/5fb20f1d13cc48fe57000dc2fa6bb15c8b568ff0))
45
+
46
+
47
+
48
+
49
+
6
50
  ## [4.1.2](https://github.com/nativescript-community/ui-image/compare/v4.1.1...v4.1.2) (2021-12-29)
7
51
 
8
52
  **Note:** Version bump only for package @nativescript-community/ui-image
package/image-common.d.ts CHANGED
@@ -82,6 +82,7 @@ export declare class ImageBase extends View {
82
82
  aspectRatio: number;
83
83
  decodeWidth: number;
84
84
  decodeHeight: number;
85
+ animatedImageView: boolean;
85
86
  alwaysFade: boolean;
86
87
  noCache: boolean;
87
88
  tintColor: Color;
@@ -113,6 +114,7 @@ export declare class ImageBase extends View {
113
114
  static roundBottomLeftRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
114
115
  static roundBottomRightRadiusProperty: Property<ImageBase, CoreTypes.LengthType>;
115
116
  static clipToBoundsProperty: Property<ImageBase, boolean>;
117
+ static animatedImageViewProperty: Property<ImageBase, boolean>;
116
118
  protected handleImageProgress(value: number, totalSize?: number): void;
117
119
  private static needsSizeAdjustment;
118
120
  computeScaleFactor(measureWidth: number, measureHeight: number, widthIsFinite: boolean, heightIsFinite: boolean, nativeWidth: number, nativeHeight: number, aspectRatio: number): {
package/image-common.js CHANGED
@@ -147,6 +147,7 @@ ImageBase.roundTopRightRadiusProperty = new Property({ name: 'roundTopRightRadiu
147
147
  ImageBase.roundBottomLeftRadiusProperty = new Property({ name: 'roundBottomLeftRadius', defaultValue: 0, valueConverter: (v) => Length.toDevicePixels(Length.parse(v)) });
148
148
  ImageBase.roundBottomRightRadiusProperty = new Property({ name: 'roundBottomRightRadius', defaultValue: 0, valueConverter: (v) => Length.toDevicePixels(Length.parse(v)) });
149
149
  ImageBase.clipToBoundsProperty = new Property({ name: 'clipToBounds', defaultValue: true, valueConverter: booleanConverter });
150
+ ImageBase.animatedImageViewProperty = new Property({ name: 'animatedImageView', defaultValue: false, valueConverter: booleanConverter });
150
151
  ImageBase.srcProperty.register(ImageBase);
151
152
  ImageBase.lowerResSrcProperty.register(ImageBase);
152
153
  ImageBase.placeholderImageUriProperty.register(ImageBase);
@@ -173,4 +174,5 @@ ImageBase.decodeHeightProperty.register(ImageBase);
173
174
  ImageBase.alwaysFadeProperty.register(ImageBase);
174
175
  ImageBase.noCacheProperty.register(ImageBase);
175
176
  ImageBase.clipToBoundsProperty.register(ImageBase);
177
+ ImageBase.animatedImageViewProperty.register(ImageBase);
176
178
  //# sourceMappingURL=image-common.js.map
package/image.d.ts CHANGED
@@ -194,6 +194,11 @@ export class Img extends View {
194
194
  * Number value used as the resized image height
195
195
  */
196
196
  decodeHeight: number;
197
+
198
+ /**
199
+ * IOS: if you want to show animated images you need to set this to true
200
+ */
201
+ animatedImageView: boolean;
197
202
  }
198
203
 
199
204
  /**
package/image.ios.d.ts CHANGED
@@ -31,10 +31,10 @@ export declare class ImagePipeline {
31
31
  }
32
32
  export declare function getImagePipeline(): ImagePipeline;
33
33
  export declare class Img extends ImageBase {
34
- nativeViewProtected: SDAnimatedImageView;
34
+ nativeViewProtected: SDAnimatedImageView | UIImageView;
35
35
  isLoading: boolean;
36
36
  private _imageSourceAffectsLayout;
37
- createNativeView(): SDAnimatedImageView;
37
+ createNativeView(): UIImageView;
38
38
  _setNativeClipToBounds(): void;
39
39
  onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
40
40
  updateImageUri(): void;
package/image.ios.js CHANGED
@@ -3,39 +3,6 @@ import { ImageAsset, ImageSource, Screen, Trace, knownFolders, path } from '@nat
3
3
  import { isString } from '@nativescript/core/utils/types';
4
4
  import { RESOURCE_PREFIX, isFileOrResourcePath, isFontIconURI, layout } from '@nativescript/core/utils/utils';
5
5
  import { CLog, CLogTypes, ImageBase, ScaleType } from './image-common';
6
- var SDImageRoundAsCircleTransformer = /** @class */ (function (_super) {
7
- __extends(SDImageRoundAsCircleTransformer, _super);
8
- function SDImageRoundAsCircleTransformer() {
9
- return _super !== null && _super.apply(this, arguments) || this;
10
- }
11
- SDImageRoundAsCircleTransformer.transformer = function () {
12
- var transformer = SDImageRoundAsCircleTransformer.alloc().init();
13
- return transformer;
14
- };
15
- Object.defineProperty(SDImageRoundAsCircleTransformer.prototype, "transformerKey", {
16
- get: function () {
17
- return 'SDImageRoundAsCircleTransformer';
18
- },
19
- enumerable: true,
20
- configurable: true
21
- });
22
- SDImageRoundAsCircleTransformer.prototype.transformedImageWithImageForKey = function (image, key) {
23
- if (!image) {
24
- return null;
25
- }
26
- var width = image.size.width;
27
- var height = image.size.height;
28
- var minwidth = Math.min(width, height);
29
- var cornerRadius = minwidth / 2;
30
- var result = image
31
- .sd_resizedImageWithSizeScaleMode(CGSizeMake(minwidth, minwidth), SDImageScaleMode.AspectFill)
32
- .sd_roundedCornerImageWithRadiusCornersBorderWidthBorderColor(cornerRadius, UIRectCorner.BottomLeft | UIRectCorner.BottomRight | UIRectCorner.TopLeft | UIRectCorner.TopRight, 0, null)
33
- .sd_resizedImageWithSizeScaleMode(CGSizeMake(width, height), SDImageScaleMode.AspectFit);
34
- return result;
35
- };
36
- SDImageRoundAsCircleTransformer.ObjCProtocols = [SDImageTransformer];
37
- return SDImageRoundAsCircleTransformer;
38
- }(NSObject));
39
6
  export class ImageInfo {
40
7
  constructor(width, height) {
41
8
  this.width = width;
@@ -236,7 +203,7 @@ export class Img extends ImageBase {
236
203
  };
237
204
  }
238
205
  createNativeView() {
239
- const result = SDAnimatedImageView.new();
206
+ const result = this.animatedImageView ? SDAnimatedImageView.new() : UIImageView.new();
240
207
  result.contentMode = 1;
241
208
  result.clipsToBounds = true;
242
209
  result.userInteractionEnabled = true;
@@ -379,12 +346,15 @@ export class Img extends ImageBase {
379
346
  transformers.push(SDImageBlurTransformer.transformerWithRadius(this.blurRadius));
380
347
  }
381
348
  if (this.roundAsCircle === true) {
382
- transformers.push(SDImageRoundAsCircleTransformer.new());
349
+ transformers.push(NSImageRoundAsCircleTransformer.transformer());
383
350
  }
384
351
  if (this.roundBottomLeftRadius || this.roundBottomRightRadius || this.roundTopLeftRadius || this.roundTopRightRadius) {
385
352
  transformers.push(NSImageRoundCornerTransformer.transformerWithTopLefRadiusTopRightRadiusBottomRightRadiusBottomLeftRadius(layout.toDeviceIndependentPixels(this.roundTopLeftRadius), layout.toDeviceIndependentPixels(this.roundTopRightRadius), layout.toDeviceIndependentPixels(this.roundBottomRightRadius), layout.toDeviceIndependentPixels(this.roundBottomLeftRadius)));
386
353
  }
387
354
  if (transformers.length > 0) {
355
+ if (this.animatedImageView) {
356
+ options |= 512;
357
+ }
388
358
  context.setValueForKey(SDImagePipelineTransformer.transformerWithTransformers(transformers), SDWebImageContextImageTransformer);
389
359
  }
390
360
  this.nativeViewProtected.sd_setImageWithURLPlaceholderImageOptionsContextProgressCompleted(uri, this.placeholderImage, options, context, this.onLoadProgress, this.handleImageLoaded);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-image",
3
- "version": "4.1.2",
3
+ "version": "4.1.6",
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": "./image",
6
6
  "sideEffects": false,
@@ -36,5 +36,5 @@
36
36
  },
37
37
  "license": "Apache-2.0",
38
38
  "readmeFilename": "README.md",
39
- "gitHead": "a12811812f0f220d2ba522b76242182950bbf7bb"
39
+ "gitHead": "dda64bd9f419fe9df0d3ca7d25a23939ad71b764"
40
40
  }
@@ -1,9 +1,4 @@
1
-
2
- repositories {
3
- flatDir {
4
- dirs '../../../node_modules/@nativescript/core/platforms/android'
5
- }
6
- }
1
+ import groovy.json.JsonSlurper
7
2
  dependencies {
8
3
  def frescoVersion = project.hasProperty("frescoVersion") ? project.frescoVersion : "2.3.0"
9
4
 
@@ -19,3 +14,19 @@ dependencies {
19
14
  // }
20
15
  implementation(name:'widgets-release', ext:'aar')
21
16
  }
17
+
18
+ repositories {
19
+ mavenCentral()
20
+ def appDir = "$rootDir/../../.."
21
+ def widgetsDir = "$appDir/node_modules/@nativescript/core/platforms/android"
22
+ def appPackageJsonFile = file("$appDir/package.json")
23
+ if (appPackageJsonFile.exists()) {
24
+ def appPackageJson = new JsonSlurper().parseText(appPackageJsonFile.text)
25
+ if (appPackageJson.dependencies["@akylas/nativescript"] != null) {
26
+ widgetsDir = "$appDir/node_modules/@akylas/nativescript/platforms/android"
27
+ }
28
+ }
29
+ flatDir {
30
+ dirs "$widgetsDir"
31
+ }
32
+ }
@@ -27,6 +27,9 @@
27
27
  "com.nativescript.image:DraweeView*",
28
28
  "com.nativescript.image:ScalingBlurPostprocessor*",
29
29
  "android.graphics.drawable:Animatable",
30
- "com.facebook.imagepipeline.image:ImageInfo*"
30
+ "com.facebook.imagepipeline.image:ImageInfo*",
31
+ "com.facebook.common.util:UriUtil*",
32
+ "android.net:Uri*",
33
+ "android.net.Uri:Builder*"
31
34
  ]
32
35
  }
Binary file
@@ -4,3 +4,4 @@
4
4
 
5
5
  #import "NSImageRoundCornerTransformer.h"
6
6
  #import "NSImageDecodeSizeTransformer.h"
7
+ #import "NSImageRoundAsCircleTransformer.h"
@@ -0,0 +1,8 @@
1
+ #import <SDWebImage/SDImageTransformer.h>
2
+
3
+ @interface NSImageRoundAsCircleTransformer: NSObject <SDImageTransformer>
4
+
5
+ - (nonnull instancetype)init NS_UNAVAILABLE;
6
+ + (nonnull instancetype)transformer;
7
+
8
+ @end
@@ -0,0 +1,40 @@
1
+ #import "NSImageRoundAsCircleTransformer.h"
2
+ #import <SDWebImage/SDGraphicsImageRenderer.h>
3
+
4
+ @interface NSImageRoundAsCircleTransformer ()
5
+
6
+ @end
7
+
8
+ @implementation NSImageRoundAsCircleTransformer
9
+ + (instancetype)transformer {
10
+
11
+ NSImageRoundAsCircleTransformer *transformer = [NSImageRoundAsCircleTransformer new];
12
+ return transformer;
13
+ }
14
+
15
+ - (NSString *)transformerKey {
16
+ return [NSString stringWithFormat:@"NSImageRoundAsCircleTransformer"];
17
+ }
18
+
19
+ - (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
20
+ if (!image) {
21
+ return nil;
22
+ }
23
+
24
+ CGFloat width = (CGFloat)image.size.width;
25
+ CGFloat height = (CGFloat)image.size.height;
26
+ CGFloat minwidth = MIN(width, height);
27
+ CGFloat cornerRadius = minwidth / 2;
28
+
29
+ UIImage * resultImage = [image sd_resizedImageWithSize:CGSizeMake(minwidth, minwidth) scaleMode:SDImageScaleModeAspectFill];
30
+ resultImage = [resultImage sd_roundedCornerImageWithRadius:cornerRadius corners:UIRectCornerAllCorners borderWidth:0 borderColor:nil];
31
+ return resultImage;
32
+ // const result = (image as any)
33
+ // .sd_resizedImageWithSizeScaleMode(CGSizeMake(minwidth, minwidth), SDImageScaleMode.AspectFill)
34
+ // .sd_roundedCornerImageWithRadiusCornersBorderWidthBorderColor(cornerRadius, UIRectCorner.BottomLeft | UIRectCorner.BottomRight | UIRectCorner.TopLeft | UIRectCorner.TopRight, 0, null)
35
+ // .sd_resizedImageWithSizeScaleMode(CGSizeMake(width, height), SDImageScaleMode.AspectFit);
36
+ // return result;
37
+ // return resultImage;
38
+ }
39
+
40
+ @end