Skip to content

Commit c96deda

Browse files
committed
chore: refactoring
1 parent df8fdf9 commit c96deda

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/image.ios.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -258,36 +258,35 @@ export class Img extends ImageBase {
258258
const height = layout.getMeasureSpecSize(heightMeasureSpec);
259259
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
260260

261-
if (this.nativeViewProtected) {
262-
const image = this.nativeViewProtected.image;
263-
// const measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
264-
// const measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
261+
const image = this.nativeViewProtected.image;
265262

266-
const finiteWidth: boolean = widthMode === layout.EXACTLY;
267-
const finiteHeight: boolean = heightMode === layout.EXACTLY;
268-
this._imageSourceAffectsLayout = !finiteWidth || !finiteHeight;
269-
if (Trace.isEnabled()) {
270-
CLog(CLogTypes.info, 'onMeasure', this.src, widthMeasureSpec, heightMeasureSpec, width, height, this.aspectRatio, image && image.imageOrientation);
263+
// const measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
264+
// const measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
265+
266+
const finiteWidth: boolean = widthMode === layout.EXACTLY;
267+
const finiteHeight: boolean = heightMode === layout.EXACTLY;
268+
this._imageSourceAffectsLayout = !finiteWidth || !finiteHeight;
269+
if (Trace.isEnabled()) {
270+
CLog(CLogTypes.info, 'onMeasure', this.src, widthMeasureSpec, heightMeasureSpec, width, height, this.aspectRatio, image && image.imageOrientation);
271+
}
272+
if (image || this.aspectRatio > 0) {
273+
const nativeWidth = image ? layout.toDevicePixels(image.size.width) : 0;
274+
const nativeHeight = image ? layout.toDevicePixels(image.size.height) : 0;
275+
const imgRatio = nativeWidth / nativeHeight;
276+
const ratio = this.aspectRatio || imgRatio;
277+
// const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
278+
279+
if (!finiteWidth) {
280+
widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
281+
}
282+
if (!finiteHeight) {
283+
heightMeasureSpec = layout.makeMeasureSpec(width / ratio, layout.EXACTLY);
271284
}
272-
if (image || this.aspectRatio > 0) {
273-
const nativeWidth = image ? layout.toDevicePixels(image.size.width) : 0;
274-
const nativeHeight = image ? layout.toDevicePixels(image.size.height) : 0;
275-
const imgRatio = nativeWidth / nativeHeight;
276-
const ratio = this.aspectRatio || imgRatio;
277-
// const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
278-
279-
if (!finiteWidth) {
280-
widthMeasureSpec = layout.makeMeasureSpec(height * ratio, layout.EXACTLY);
281-
}
282-
if (!finiteHeight) {
283-
heightMeasureSpec = layout.makeMeasureSpec(width / ratio, layout.EXACTLY);
284-
}
285285

286-
if (Trace.isEnabled()) {
287-
CLog(CLogTypes.info, 'onMeasure scale', this.src, this.aspectRatio, finiteWidth, finiteHeight, width, height, nativeWidth, nativeHeight, widthMeasureSpec, heightMeasureSpec);
288-
}
286+
if (Trace.isEnabled()) {
287+
CLog(CLogTypes.info, 'onMeasure scale', this.src, this.aspectRatio, finiteWidth, finiteHeight, width, height, nativeWidth, nativeHeight, widthMeasureSpec, heightMeasureSpec);
289288
}
290-
}
289+
}
291290
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
292291

293292
// const widthAndState = Img.resolveSizeAndState(measureWidth, width, widthMode, 0);

0 commit comments

Comments
 (0)