@nativescript-community/ui-image 4.3.27 → 4.3.28
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 +6 -0
- package/index.android.js +1 -1
- package/index.ios.js +6 -2
- package/package.json +2 -2
- package/platforms/android/java/com/nativescript/image/DraweeView.java +46 -24
- package/platforms/android/ui_image.aar +0 -0
- package/platforms/ios/src/Info.plist +0 -0
- package/platforms/ios/src/NImage.h +0 -7
- package/platforms/ios/src/NSImageDecodeSizeTransformer.h +0 -11
- package/platforms/ios/src/NSImageDecodeSizeTransformer.m +0 -44
- package/platforms/ios/src/NSImageRoundAsCircleTransformer.h +0 -8
- package/platforms/ios/src/NSImageRoundAsCircleTransformer.m +0 -40
- package/platforms/ios/src/NSImageRoundCornerTransformer.h +0 -13
- package/platforms/ios/src/NSImageRoundCornerTransformer.m +0 -59
- package/platforms/ios/src/module.modulemap +0 -5
- package/vue/index.mjs +0 -8
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
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.28](https://github.com/nativescript-community/ui-image/compare/v4.3.27...v4.3.28) (2024-01-23)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* **android:** improvement for future N ([f8e10f5](https://github.com/nativescript-community/ui-image/commit/f8e10f56945dbb76800d9fd90f2c6bd40966423f))
|
11
|
+
|
6
12
|
## [4.3.27](https://github.com/nativescript-community/ui-image/compare/v4.3.26...v4.3.27) (2023-11-24)
|
7
13
|
|
8
14
|
**Note:** Version bump only for package @nativescript-community/ui-image
|
package/index.android.js
CHANGED
@@ -682,7 +682,7 @@ export class Img extends ImageBase {
|
|
682
682
|
const bottomRightRadius = this.roundBottomRightRadius || 0;
|
683
683
|
const bottomLeftRadius = this.roundBottomLeftRadius || 0;
|
684
684
|
if (topLeftRadius || topRightRadius || bottomRightRadius || bottomLeftRadius) {
|
685
|
-
builder.setCornersRadii(topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius);
|
685
|
+
builder.setCornersRadii(Utils.layout.toDevicePixels(topLeftRadius), Utils.layout.toDevicePixels(topRightRadius), Utils.layout.toDevicePixels(bottomRightRadius), Utils.layout.toDevicePixels(bottomLeftRadius));
|
686
686
|
}
|
687
687
|
this.nativeImageViewProtected.setHierarchy(builder.build());
|
688
688
|
if (!this.mNeedRequestImage) {
|
package/index.ios.js
CHANGED
@@ -379,6 +379,10 @@ export class Img extends ImageBase {
|
|
379
379
|
const uri = getUri(src);
|
380
380
|
this.isLoading = true;
|
381
381
|
let options = 2048 /* SDWebImageOptions.ScaleDownLargeImages */ | 1024 /* SDWebImageOptions.AvoidAutoSetImage */;
|
382
|
+
if (this.placeholderImageUri) {
|
383
|
+
this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
384
|
+
this._setNativeImage(this.placeholderImage, animate);
|
385
|
+
}
|
382
386
|
if (this.noCache) {
|
383
387
|
// const key = uri.absoluteString;
|
384
388
|
// const imagePipeLine = getImagePipeline();
|
@@ -446,8 +450,8 @@ export class Img extends ImageBase {
|
|
446
450
|
this.initImage();
|
447
451
|
}
|
448
452
|
[_c = placeholderImageUriProperty.setNative]() {
|
449
|
-
this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
450
|
-
this.initImage();
|
453
|
+
// this.placeholderImage = this.getUIImage(this.placeholderImageUri);
|
454
|
+
// this.initImage();
|
451
455
|
}
|
452
456
|
[failureImageUriProperty.setNative]() {
|
453
457
|
// this.updateHierarchy();
|
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.28",
|
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": "482d5862d487c81f0ae413887f9ae3070c549772"
|
48
48
|
}
|
@@ -123,34 +123,40 @@ public class DraweeView extends SimpleDraweeView {
|
|
123
123
|
mLegacyVisibilityHandlingEnabled = legacyVisibilityHandlingEnabled;
|
124
124
|
}
|
125
125
|
|
126
|
-
|
127
|
-
public void updateOutlineProvider() {
|
126
|
+
public void updateOutlineProvider() {
|
128
127
|
Drawable drawable = getBackground();
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
128
|
+
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
129
|
+
// we try to support N setting outline provider now
|
130
|
+
if (!isUsingOutlineProvider && getOutlineProvider() != null) {
|
131
|
+
// already handled somewhere else
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
if (drawable instanceof BorderDrawable && (android.os.Build.VERSION.SDK_INT >= 33 || ((BorderDrawable)drawable).hasUniformBorderRadius())) {
|
135
|
+
setOutlineProvider(new ViewOutlineProvider() {
|
136
|
+
@Override
|
137
|
+
public void getOutline(View view, Outline outline) {
|
138
|
+
Drawable drawable = getBackground();
|
139
|
+
if (drawable instanceof BorderDrawable) {
|
140
|
+
BorderDrawable borderDrawable = (BorderDrawable) drawable;
|
141
|
+
// that if test is only needed until N BorderDrawable is updated to do it
|
142
|
+
if (borderDrawable.hasUniformBorderRadius()) {
|
143
|
+
// outlineRect.set(borderDrawable.getBounds());
|
144
|
+
outline.setRoundRect(borderDrawable.getBounds(), borderDrawable.getBorderBottomLeftRadius());
|
145
|
+
} else {
|
146
|
+
drawable.getOutline(outline);
|
147
|
+
}
|
141
148
|
} else {
|
142
|
-
|
149
|
+
outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
|
143
150
|
}
|
144
|
-
} else {
|
145
|
-
outline.setRect(100, 100, view.getWidth() - 200, view.getHeight() - 200);
|
146
151
|
}
|
147
|
-
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
setOutlineProvider(null);
|
153
|
-
setClipToOutline(false);
|
152
|
+
});
|
153
|
+
setClipToOutline(true);
|
154
|
+
isUsingOutlineProvider = true;
|
155
|
+
// } else if (android.os.Build.VERSION.SDK_INT >= 21) {
|
156
|
+
// isUsingOutlineProvider = false;
|
157
|
+
// setOutlineProvider(null);
|
158
|
+
// setClipToOutline(false);
|
159
|
+
}
|
154
160
|
}
|
155
161
|
}
|
156
162
|
|
@@ -293,6 +299,22 @@ public class DraweeView extends SimpleDraweeView {
|
|
293
299
|
}
|
294
300
|
|
295
301
|
ImageRequest request = requestBuilder.build();
|
302
|
+
|
303
|
+
// if (object != null && object.optBoolean("async") == false) {
|
304
|
+
// DataSource<CloseableReference<CloseableImage>> dataSource =
|
305
|
+
// imagePipeline.fetchImageFromBitmapCache(imageRequest, uri.toString());
|
306
|
+
// try {
|
307
|
+
// CloseableReference<CloseableImage> result = DataSources.waitForFinalResult(dataSource);
|
308
|
+
// if (result != null) {
|
309
|
+
// // Do something with the image, but do not keep the reference to it!
|
310
|
+
// // The image may get recycled as soon as the reference gets closed below.
|
311
|
+
// // If you need to keep a reference to the image, read the following sections.
|
312
|
+
// }
|
313
|
+
// } finally {
|
314
|
+
// dataSource.close();
|
315
|
+
// }
|
316
|
+
// }
|
317
|
+
|
296
318
|
PipelineDraweeControllerBuilder builder = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder();
|
297
319
|
builder.setImageRequest(request);
|
298
320
|
builder.setCallerContext(uri.toString());
|
Binary file
|
Binary file
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#import <SDWebImage/SDImageTransformer.h>
|
2
|
-
|
3
|
-
@interface NSImageDecodeSizeTransformer: NSObject <SDImageTransformer>
|
4
|
-
|
5
|
-
@property (nonatomic, assign, readonly) CGFloat decodeWidth;
|
6
|
-
@property (nonatomic, assign, readonly) CGFloat decodeHeight;
|
7
|
-
|
8
|
-
- (nonnull instancetype)init NS_UNAVAILABLE;
|
9
|
-
+ (nonnull instancetype)transformerWithDecodeWidth:(CGFloat)decodeWidth decodeHeight:(CGFloat)decodeHeight;
|
10
|
-
|
11
|
-
@end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
#import "NSImageDecodeSizeTransformer.h"
|
2
|
-
#import <SDWebImage/SDGraphicsImageRenderer.h>
|
3
|
-
|
4
|
-
@interface NSImageDecodeSizeTransformer ()
|
5
|
-
|
6
|
-
@property (nonatomic, assign) CGFloat decodeWidth;
|
7
|
-
@property (nonatomic, assign) CGFloat decodeHeight;
|
8
|
-
|
9
|
-
@end
|
10
|
-
|
11
|
-
@implementation NSImageDecodeSizeTransformer
|
12
|
-
+ (nonnull instancetype)transformerWithDecodeWidth:(CGFloat)decodeWidth decodeHeight:(CGFloat)decodeHeight {
|
13
|
-
NSImageDecodeSizeTransformer *transformer = [NSImageDecodeSizeTransformer new];
|
14
|
-
transformer.decodeWidth = decodeWidth;
|
15
|
-
transformer.decodeHeight = decodeHeight;
|
16
|
-
|
17
|
-
return transformer;
|
18
|
-
}
|
19
|
-
|
20
|
-
- (NSString *)transformerKey {
|
21
|
-
return [NSString stringWithFormat:@"NSImageDecodeSizeTransformer(%f,%f)", self.decodeWidth, self.decodeHeight];
|
22
|
-
}
|
23
|
-
|
24
|
-
- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
|
25
|
-
if (!image) {
|
26
|
-
return nil;
|
27
|
-
}
|
28
|
-
CGFloat widthRatio = 1.0f;
|
29
|
-
CGFloat heightRatio = 1.0f;
|
30
|
-
|
31
|
-
CGFloat width = (CGFloat)image.size.width;
|
32
|
-
CGFloat height = (CGFloat)image.size.height;
|
33
|
-
if (self.decodeWidth && self.decodeHeight) {
|
34
|
-
widthRatio = self.decodeWidth / width;
|
35
|
-
heightRatio = self.decodeHeight / height;
|
36
|
-
} else if (self.decodeWidth > 0) {
|
37
|
-
widthRatio = self.decodeWidth / width;
|
38
|
-
} else {
|
39
|
-
heightRatio = self.decodeHeight / height;
|
40
|
-
}
|
41
|
-
return [image sd_resizedImageWithSize:CGSizeMake(width * widthRatio, height * heightRatio) scaleMode:2];
|
42
|
-
}
|
43
|
-
|
44
|
-
@end
|
@@ -1,40 +0,0 @@
|
|
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
|
@@ -1,13 +0,0 @@
|
|
1
|
-
#import <SDWebImage/SDImageTransformer.h>
|
2
|
-
|
3
|
-
@interface NSImageRoundCornerTransformer: NSObject <SDImageTransformer>
|
4
|
-
|
5
|
-
@property (nonatomic, assign, readonly) CGFloat topLeftRadius;
|
6
|
-
@property (nonatomic, assign, readonly) CGFloat topRightRadius;
|
7
|
-
@property (nonatomic, assign, readonly) CGFloat bottomRightRadius;
|
8
|
-
@property (nonatomic, assign, readonly) CGFloat bottomLeftRadius;
|
9
|
-
|
10
|
-
- (nonnull instancetype)init NS_UNAVAILABLE;
|
11
|
-
+ (nonnull instancetype)transformerWithTopLefRadius:(CGFloat)topLeftRadius topRightRadius:(CGFloat)topRightRadius bottomRightRadius:(CGFloat)bottomRightRadius bottomLeftRadius:(CGFloat)bottomLeftRadius;
|
12
|
-
|
13
|
-
@end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
#import "NSImageRoundCornerTransformer.h"
|
2
|
-
#import <SDWebImage/SDGraphicsImageRenderer.h>
|
3
|
-
|
4
|
-
@interface NSImageRoundCornerTransformer ()
|
5
|
-
|
6
|
-
@property (nonatomic, assign) CGFloat topLeftRadius;
|
7
|
-
@property (nonatomic, assign) CGFloat topRightRadius;
|
8
|
-
@property (nonatomic, assign) CGFloat bottomRightRadius;
|
9
|
-
@property (nonatomic, assign) CGFloat bottomLeftRadius;
|
10
|
-
|
11
|
-
@end
|
12
|
-
|
13
|
-
@implementation NSImageRoundCornerTransformer
|
14
|
-
+ (instancetype)transformerWithTopLefRadius:(CGFloat)topLeftRadius topRightRadius:(CGFloat)topRightRadius bottomRightRadius:(CGFloat)bottomRightRadius bottomLeftRadius:(CGFloat)bottomLeftRadius {
|
15
|
-
|
16
|
-
NSImageRoundCornerTransformer *transformer = [NSImageRoundCornerTransformer new];
|
17
|
-
transformer.topLeftRadius = topLeftRadius;
|
18
|
-
transformer.topRightRadius = topRightRadius;
|
19
|
-
transformer.bottomRightRadius = bottomRightRadius;
|
20
|
-
transformer.bottomLeftRadius = bottomLeftRadius;
|
21
|
-
|
22
|
-
return transformer;
|
23
|
-
}
|
24
|
-
|
25
|
-
- (NSString *)transformerKey {
|
26
|
-
return [NSString stringWithFormat:@"NSImageRoundCornerTransformer(%f,%f,%f,%f)", self.topLeftRadius,self.topRightRadius,self.bottomRightRadius,self.bottomLeftRadius];
|
27
|
-
}
|
28
|
-
|
29
|
-
- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key {
|
30
|
-
if (!image) {
|
31
|
-
return nil;
|
32
|
-
}
|
33
|
-
|
34
|
-
SDGraphicsImageRendererFormat *format = [[SDGraphicsImageRendererFormat alloc] init];
|
35
|
-
format.scale = image.scale;
|
36
|
-
SDGraphicsImageRenderer *renderer = [[SDGraphicsImageRenderer alloc] initWithSize:image.size format:format];
|
37
|
-
UIImage *resultImage = [renderer imageWithActions:^(CGContextRef _Nonnull context) {
|
38
|
-
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
|
39
|
-
|
40
|
-
UIBezierPath *newPath = [UIBezierPath bezierPath];
|
41
|
-
|
42
|
-
CGFloat left = M_PI;
|
43
|
-
CGFloat up = 1.5*M_PI;
|
44
|
-
CGFloat down = M_PI_2;
|
45
|
-
CGFloat right = 0.0;
|
46
|
-
[newPath addArcWithCenter:CGPointMake( CGRectGetMinX(rect) + self.topLeftRadius, CGRectGetMinY( rect) + self.topLeftRadius) radius: self.topLeftRadius startAngle: left endAngle: up clockwise: true];
|
47
|
-
[newPath addArcWithCenter:CGPointMake( CGRectGetMaxX(rect) - self.topRightRadius, CGRectGetMinY( rect) + self.topRightRadius) radius: self.topRightRadius startAngle: up endAngle: right clockwise: true];
|
48
|
-
[newPath addArcWithCenter:CGPointMake( CGRectGetMaxX(rect) - self.bottomRightRadius, CGRectGetMaxY( rect) - self.bottomRightRadius) radius: self.bottomRightRadius startAngle: right endAngle: down clockwise: true];
|
49
|
-
[newPath addArcWithCenter:CGPointMake(CGRectGetMinX(rect) + self.bottomLeftRadius, CGRectGetMaxY( rect) - self.bottomLeftRadius) radius: self.bottomLeftRadius startAngle: down endAngle: left clockwise: true];
|
50
|
-
[newPath closePath];
|
51
|
-
CGContextSaveGState(context);
|
52
|
-
[newPath addClip];
|
53
|
-
[image drawInRect:rect];
|
54
|
-
CGContextRestoreGState(context);
|
55
|
-
}];
|
56
|
-
return resultImage;
|
57
|
-
}
|
58
|
-
|
59
|
-
@end
|