Skip to content

Commit d792cd9

Browse files
committed
fix(ios): res image fix
1 parent 726ebbc commit d792cd9

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/image.ios.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,25 @@ export function getImagePipeline(): ImagePipeline {
237237
function getUri(src: string | ImageAsset) {
238238
let uri: any = src;
239239
if (src instanceof ImageAsset) {
240-
uri = NSURL.sd_URLWithAsset(src.ios);
240+
return NSURL.sd_URLWithAsset(src.ios);
241241
}
242242
if (uri.indexOf(RESOURCE_PREFIX) === 0) {
243243
const resName = uri.substr(RESOURCE_PREFIX.length);
244244
if (screenScale === -1) {
245245
screenScale = Screen.mainScreen.scale;
246246
}
247-
supportedLocalFormats.some((v) => {
247+
const found = supportedLocalFormats.some((v) => {
248248
for (let i = screenScale; i >= 1; i--) {
249249
uri = NSBundle.mainBundle.URLForResourceWithExtension(i > 1 ? `${resName}@${i}x` : resName, v);
250-
if (!!uri) {
250+
if (uri) {
251251
return true;
252252
}
253253
}
254254
return false;
255255
});
256+
if (found) {
257+
return uri;
258+
}
256259
} else if (uri.indexOf('~/') === 0) {
257260
return NSURL.alloc().initFileURLWithPath(`${path.join(knownFolders.currentApp().path, uri.replace('~/', ''))}`);
258261
}
@@ -455,15 +458,21 @@ export class Img extends ImageBase {
455458
if (src instanceof ImageSource) {
456459
this._setNativeImage(src.ios);
457460
return;
458-
} else if (isFontIconURI(src as string)) {
459-
const fontIconCode = (src as string).split('//')[1];
460-
if (fontIconCode !== undefined) {
461-
// support sync mode only
462-
const font = this.style.fontInternal;
463-
const color = this.style.color;
464-
this._setNativeImage(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios);
461+
} else if (typeof src === 'string') {
462+
if (isFontIconURI(src)) {
463+
const fontIconCode = (src).split('//')[1];
464+
if (fontIconCode !== undefined) {
465+
// support sync mode only
466+
const font = this.style.fontInternal;
467+
const color = this.style.color;
468+
this._setNativeImage(ImageSource.fromFontIconCodeSync(fontIconCode, font, color).ios);
469+
}
470+
return;
471+
// } else if (src.startsWith(RESOURCE_PREFIX)) {
472+
// this._setNativeImage(ImageSource.fromResourceSync(src.));
473+
//
465474
}
466-
return;
475+
467476
}
468477

469478
const uri = getUri(src);

0 commit comments

Comments
 (0)