@nativescript-community/ui-image 4.5.2 → 4.5.4
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.android.js +40 -10
- package/package.json +10 -2
- package/platforms/android/ui_image.aar +0 -0
- package/vue/index.mjs +0 -8
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.5.4](https://github.com/nativescript-community/ui-image/compare/v4.5.3...v4.5.4) (2024-11-12)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
9
|
+
|
10
|
+
## [4.5.3](https://github.com/nativescript-community/ui-image/compare/v4.5.2...v4.5.3) (2024-09-11)
|
11
|
+
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-image
|
13
|
+
|
6
14
|
## [4.5.2](https://github.com/nativescript-community/ui-image/compare/v4.5.1...v4.5.2) (2024-05-14)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @nativescript-community/ui-image
|
package/index.android.js
CHANGED
@@ -95,6 +95,27 @@ function getUri(src, asNative = true) {
|
|
95
95
|
}
|
96
96
|
return asNative ? android.net.Uri.parse(uri) : uri;
|
97
97
|
}
|
98
|
+
function isVectorDrawable(context, resId) {
|
99
|
+
const resources = context.getResources();
|
100
|
+
// VectorDrawable resources are usually stored as "drawable" in XML format
|
101
|
+
const value = new android.util.TypedValue();
|
102
|
+
resources.getValue(resId, value, true);
|
103
|
+
if (value.string.toString().endsWith('.xml')) {
|
104
|
+
// It's most likely a VectorDrawable
|
105
|
+
return true;
|
106
|
+
}
|
107
|
+
// If it's not a vector, it's probably a BitmapDrawable or another type
|
108
|
+
return false;
|
109
|
+
}
|
110
|
+
function getBitmapFromVectorDrawable(context, drawableId) {
|
111
|
+
const drawable = Utils.android.getApplicationContext().getDrawable(drawableId);
|
112
|
+
const bitmap = android.graphics.Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), android.graphics.Bitmap.Config.ARGB_8888);
|
113
|
+
const canvas = new android.graphics.Canvas(bitmap);
|
114
|
+
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
115
|
+
drawable.draw(canvas);
|
116
|
+
console.log('getBitmapFromVectorDrawable', bitmap, bitmap.getWidth(), bitmap.getHeight);
|
117
|
+
return new android.graphics.drawable.BitmapDrawable(context.getResources(), bitmap);
|
118
|
+
}
|
98
119
|
export class ImagePipeline {
|
99
120
|
toUri(value) {
|
100
121
|
if (value instanceof android.net.Uri) {
|
@@ -450,19 +471,28 @@ export class Img extends ImageBase {
|
|
450
471
|
}
|
451
472
|
if (src) {
|
452
473
|
let drawable;
|
453
|
-
if (src
|
474
|
+
if (typeof src === 'string') {
|
475
|
+
// disabled for now: loading vector drawables
|
476
|
+
// if (src.indexOf(Utils.RESOURCE_PREFIX) === 0) {
|
477
|
+
// const identifier = Utils.android.resources.getDrawableId(src.substring(Utils.RESOURCE_PREFIX.length));
|
478
|
+
// if (identifier >= 0 && isVectorDrawable(this._context, identifier)) {
|
479
|
+
// drawable = getBitmapFromVectorDrawable(this._context, identifier);
|
480
|
+
// }
|
481
|
+
// } else
|
482
|
+
if (Utils.isFontIconURI(src)) {
|
483
|
+
const fontIconCode = src.split('//')[1];
|
484
|
+
if (fontIconCode !== undefined) {
|
485
|
+
// support sync mode only
|
486
|
+
const font = this.style.fontInternal;
|
487
|
+
const color = this.style.color;
|
488
|
+
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
|
489
|
+
}
|
490
|
+
}
|
491
|
+
}
|
492
|
+
else if (src instanceof ImageSource) {
|
454
493
|
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), src.android);
|
455
494
|
this.updateViewSize(src.android);
|
456
495
|
}
|
457
|
-
else if (Utils.isFontIconURI(src)) {
|
458
|
-
const fontIconCode = src.split('//')[1];
|
459
|
-
if (fontIconCode !== undefined) {
|
460
|
-
// support sync mode only
|
461
|
-
const font = this.style.fontInternal;
|
462
|
-
const color = this.style.color;
|
463
|
-
drawable = new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
|
464
|
-
}
|
465
|
-
}
|
466
496
|
if (drawable) {
|
467
497
|
const hierarchy = this.nativeImageViewProtected.getHierarchy();
|
468
498
|
hierarchy.setImage(drawable, 1, hierarchy.getFadeDuration() === 0);
|
package/package.json
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-image",
|
3
|
-
"version": "4.5.
|
3
|
+
"version": "4.5.4",
|
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,
|
7
7
|
"typings": "./index.d.ts",
|
8
|
+
"scripts": {
|
9
|
+
"build": "npm run tsc && npm run readme",
|
10
|
+
"build.all": "npm run build && npm run build.angular",
|
11
|
+
"build.angular": "ng-packagr -p ../../src/image/angular/ng-package.json -c ../../src/image/angular/tsconfig.json && rm angular/.npmignore",
|
12
|
+
"readme": "readme generate -c ../../tools/readme/blueprint.json",
|
13
|
+
"tsc": "cpy '**/*.d.ts' '../../packages/image' --parents --cwd=../../src/image && tsc -skipLibCheck -d",
|
14
|
+
"clean": "rimraf ./*.d.ts ./*.js ./*.js.map"
|
15
|
+
},
|
8
16
|
"nativescript": {
|
9
17
|
"platforms": {
|
10
18
|
"android": "6.0.0",
|
@@ -36,5 +44,5 @@
|
|
36
44
|
},
|
37
45
|
"license": "Apache-2.0",
|
38
46
|
"readmeFilename": "README.md",
|
39
|
-
"gitHead": "
|
47
|
+
"gitHead": "1cbfe131d7851244fbcc4cb37981c2248d64c550"
|
40
48
|
}
|
Binary file
|