Skip to content

Commit

Permalink
feat: fontIcon support for all images (placeholder, ….)
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Oct 7, 2021
1 parent ea32331 commit 22eb284
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/image.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,15 @@ export class Img extends ImageBase {
private getDrawable(path: string | ImageSource) {
let drawable: android.graphics.drawable.BitmapDrawable;
if (typeof path === 'string') {
if (isFileOrResourcePath(path)) {
if (isFontIconURI(path)) {
const fontIconCode = (path).split('//')[1];
if (fontIconCode !== undefined) {
// support sync mode only
const font = this.style.fontInternal;
const color = this.style.color;
drawable = new android.graphics.drawable.BitmapDrawable(ad.getApplicationContext().getResources(), ImageSource.fromFontIconCodeSync(fontIconCode, font, color).android);
}
} else if (isFileOrResourcePath(path)) {
if (path.indexOf(RESOURCE_PREFIX) === 0) {
return this.getDrawableFromResource(path); // number!
} else {
Expand Down
11 changes: 10 additions & 1 deletion src/image.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,16 @@ export class Img extends ImageBase {
}
let image;
if (typeof imagePath === 'string') {
if (isFileOrResourcePath(imagePath)) {
if (isFontIconURI(imagePath)) {
const fontIconCode = (imagePath).split('//')[1];
if (fontIconCode !== undefined) {
// support sync mode only
const font = this.style.fontInternal;
const color = this.style.color;
image = (ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios);
}
}
if (!image && isFileOrResourcePath(imagePath)) {
image = ImageSource.fromFileOrResourceSync(imagePath);
}
} else {
Expand Down

0 comments on commit 22eb284

Please sign in to comment.