Skip to content

Commit 22eb284

Browse files
committed
feat: fontIcon support for all images (placeholder, ….)
1 parent ea32331 commit 22eb284

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/image.android.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,15 @@ export class Img extends ImageBase {
778778
private getDrawable(path: string | ImageSource) {
779779
let drawable: android.graphics.drawable.BitmapDrawable;
780780
if (typeof path === 'string') {
781-
if (isFileOrResourcePath(path)) {
781+
if (isFontIconURI(path)) {
782+
const fontIconCode = (path).split('//')[1];
783+
if (fontIconCode !== undefined) {
784+
// support sync mode only
785+
const font = this.style.fontInternal;
786+
const color = this.style.color;
787+
drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
788+
}
789+
} else if (isFileOrResourcePath(path)) {
782790
if (path.indexOf(RESOURCE_PREFIX) === 0) {
783791
return this.getDrawableFromResource(path); // number!
784792
} else {

src/image.ios.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,16 @@ export class Img extends ImageBase {
403403
}
404404
let image;
405405
if (typeof imagePath === 'string') {
406-
if (isFileOrResourcePath(imagePath)) {
406+
if (isFontIconURI(imagePath)) {
407+
const fontIconCode = (imagePath).split('//')[1];
408+
if (fontIconCode !== undefined) {
409+
// support sync mode only
410+
const font = this.style.fontInternal;
411+
const color = this.style.color;
412+
image = (ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios);
413+
}
414+
}
415+
if (!image && isFileOrResourcePath(imagePath)) {
407416
image = ImageSource.fromFileOrResourceSync(imagePath);
408417
}
409418
} else {

0 commit comments

Comments
 (0)