Skip to content

Commit d2e3cc6

Browse files
committed
fix: ios cleanup size measuring
1 parent c08cbed commit d2e3cc6

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/image.ios.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,37 +288,35 @@ export class Img extends ImageBase {
288288

289289
const image = this.nativeViewProtected.image;
290290

291-
292-
const nativeWidth = image ? layout.toDevicePixels(image.size.width) : 0;
293-
const nativeHeight = image ? layout.toDevicePixels(image.size.height) : 0;
294-
295-
let measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
296-
let measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
291+
// const measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
292+
// const measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
297293

298294
const finiteWidth: boolean = widthMode === layout.EXACTLY;
299295
const finiteHeight: boolean = heightMode === layout.EXACTLY;
300296
this._imageSourceAffectsLayout = !finiteWidth || !finiteHeight;
301-
const imgRatio = nativeWidth / nativeHeight;
302297
CLog(CLogTypes.info, 'onMeasure', this.src, widthMeasureSpec, heightMeasureSpec, width, height, this.aspectRatio, image && image.imageOrientation);
303298
if (image || this.aspectRatio > 0) {
299+
const nativeWidth = image ? layout.toDevicePixels(image.size.width) : 0;
300+
const nativeHeight = image ? layout.toDevicePixels(image.size.height) : 0;
301+
const imgRatio = nativeWidth / nativeHeight;
304302
const ratio = this.aspectRatio || imgRatio;
305303
// const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
306304

307305
if (!finiteWidth) {
308-
measureWidth = Math.round(height * ratio);
309-
} else {
310-
306+
widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
311307
}
312308
if (!finiteHeight) {
313-
measureHeight = Math.round(width / ratio);
309+
heightMeasureSpec = layout.makeMeasureSpec(width / ratio, layout.EXACTLY);
314310
}
315311

316-
CLog(CLogTypes.info, 'onMeasure scale', this.src, this.aspectRatio, finiteWidth, finiteHeight, width, height, nativeWidth, nativeHeight);
312+
CLog(CLogTypes.info, 'onMeasure scale', this.src, this.aspectRatio, finiteWidth, finiteHeight, width, height, nativeWidth, nativeHeight, widthMeasureSpec, heightMeasureSpec);
317313
}
318-
const widthAndState = Img.resolveSizeAndState(measureWidth, width, widthMode, 0);
319-
const heightAndState = Img.resolveSizeAndState(measureHeight, height, heightMode, 0);
314+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
315+
316+
// const widthAndState = Img.resolveSizeAndState(measureWidth, width, widthMode, 0);
317+
// const heightAndState = Img.resolveSizeAndState(measureHeight, height, heightMode, 0);
320318

321-
this.setMeasuredDimension(widthAndState, heightAndState);
319+
// this.setMeasuredDimension(widthAndState, heightAndState);
322320
}
323321

324322
// public disposeNativeView() {
@@ -349,7 +347,6 @@ export class Img extends ImageBase {
349347
}
350348

351349
private handleImageLoaded = (image: UIImage, error: NSError, cacheType: number) => {
352-
353350
// if (this.tintColor) {
354351
// image = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
355352
// }

0 commit comments

Comments
 (0)