mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix dp vs dip conversions in iOS for errors of tests
This commit is contained in:
@@ -189,8 +189,8 @@ export class View extends ViewCommon {
|
||||
|
||||
let pointInWindow = this.nativeView.convertPointToView(this.nativeView.bounds.origin, null);
|
||||
return {
|
||||
x: layout.toDeviceIndependentPixels(pointInWindow.x),
|
||||
y: layout.toDeviceIndependentPixels(pointInWindow.y),
|
||||
x: pointInWindow.x,
|
||||
y: pointInWindow.y
|
||||
};
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ export class View extends ViewCommon {
|
||||
let pointInWindow = this.nativeView.convertPointToView(this.nativeView.bounds.origin, null);
|
||||
let pointOnScreen = this.nativeView.window.convertPointToWindow(pointInWindow, null);
|
||||
return {
|
||||
x: layout.toDeviceIndependentPixels(pointOnScreen.x),
|
||||
y: layout.toDeviceIndependentPixels(pointOnScreen.y),
|
||||
x: pointOnScreen.x,
|
||||
y: pointOnScreen.y
|
||||
};
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ export class View extends ViewCommon {
|
||||
let myPointInWindow = this.nativeView.convertPointToView(this.nativeView.bounds.origin, null);
|
||||
let otherPointInWindow = otherView.nativeView.convertPointToView(otherView.nativeView.bounds.origin, null);
|
||||
return {
|
||||
x: layout.toDeviceIndependentPixels(myPointInWindow.x - otherPointInWindow.x),
|
||||
y: layout.toDeviceIndependentPixels(myPointInWindow.y - otherPointInWindow.y),
|
||||
x: myPointInWindow.x - otherPointInWindow.x,
|
||||
y: myPointInWindow.y - otherPointInWindow.y
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Page } from "ui/page";
|
||||
import { FrameBase, View, application, layout, traceEnabled, traceWrite, traceCategories, isCategorySet } from "./frame-common";
|
||||
import { _createIOSAnimatedTransitioning } from "ui/transition";
|
||||
import * as uiUtils from "ui/utils";
|
||||
import * as utils from "utils/utils";
|
||||
|
||||
export * from "./frame-common";
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ export class GridLayout extends GridLayoutBase {
|
||||
|
||||
actualLength = offset - roundedOffset;
|
||||
roundedLength = Math.round(actualLength);
|
||||
columnGroup.rowOrColumn._actualLength = roundedLength;
|
||||
columnGroup.rowOrColumn._actualLength = layout.toDeviceIndependentPixels(roundedLength);
|
||||
roundedOffset += roundedLength;
|
||||
|
||||
this.columnOffsets.push(roundedOffset);
|
||||
@@ -191,7 +191,7 @@ export class GridLayout extends GridLayoutBase {
|
||||
|
||||
actualLength = offset - roundedOffset;
|
||||
roundedLength = Math.round(actualLength);
|
||||
rowGroup.rowOrColumn._actualLength = roundedLength;
|
||||
rowGroup.rowOrColumn._actualLength = layout.toDeviceIndependentPixels(roundedLength);
|
||||
roundedOffset += roundedLength;
|
||||
|
||||
this.rowOffsets.push(roundedOffset);
|
||||
@@ -417,7 +417,7 @@ class MeasureHelper {
|
||||
measureSpec.starColumnsCount += columnGroup.rowOrColumn.value;
|
||||
}
|
||||
else if (columnGroup.getIsAbsolute()) {
|
||||
measureSpec.pixelWidth += columnGroup.rowOrColumn.value;
|
||||
measureSpec.pixelWidth += layout.toDevicePixels(columnGroup.rowOrColumn.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ class MeasureHelper {
|
||||
measureSpec.starRowsCount += rowGroup.rowOrColumn.value;
|
||||
}
|
||||
else if (rowGroup.getIsAbsolute()) {
|
||||
measureSpec.pixelHeight += rowGroup.rowOrColumn.value;
|
||||
measureSpec.pixelHeight += layout.toDevicePixels(rowGroup.rowOrColumn.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class UITableViewDelegateImpl extends NSObject implements UITableViewDelegate {
|
||||
height = owner._prepareCell(cell, indexPath);
|
||||
}
|
||||
|
||||
return height;
|
||||
return layout.toDeviceIndependentPixels(height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate
|
||||
owner.notify(<ScrollEventData>{
|
||||
object: owner,
|
||||
eventName: ScrollViewBase.scrollEvent,
|
||||
scrollX: owner.horizontalOffset / layout.getDisplayDensity(),
|
||||
scrollY: owner.verticalOffset / layout.getDisplayDensity()
|
||||
scrollX: owner.horizontalOffset,
|
||||
scrollY: owner.verticalOffset
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export class ScrollView extends ScrollViewBase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, this.nativeView.contentSize.width - this.nativeView.bounds.size.width) / layout.getDisplayDensity();
|
||||
return Math.max(0, this.nativeView.contentSize.width - this.nativeView.bounds.size.width);
|
||||
}
|
||||
|
||||
get scrollableHeight(): number {
|
||||
@@ -68,7 +68,7 @@ export class ScrollView extends ScrollViewBase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, this.nativeView.contentSize.height - this.nativeView.bounds.size.height) / layout.getDisplayDensity();
|
||||
return Math.max(0, this.nativeView.contentSize.height - this.nativeView.bounds.size.height);
|
||||
}
|
||||
|
||||
get ios(): UIView {
|
||||
@@ -116,7 +116,10 @@ export class ScrollView extends ScrollViewBase {
|
||||
childSize = View.measureChild(this, child, layout.makeMeasureSpec(0, layout.UNSPECIFIED), heightMeasureSpec);
|
||||
}
|
||||
|
||||
this.nativeView.contentSize = CGSizeMake(childSize.measuredWidth, childSize.measuredHeight);
|
||||
let w = layout.toDeviceIndependentPixels(childSize.measuredWidth);
|
||||
let h = layout.toDeviceIndependentPixels(childSize.measuredHeight);
|
||||
this.nativeView.contentSize = CGSizeMake(w, h);
|
||||
|
||||
this._contentMeasuredWidth = Math.max(childSize.measuredWidth, this.effectiveMinWidth * density);
|
||||
this._contentMeasuredHeight = Math.max(childSize.measuredHeight, this.effectiveMinHeight * density);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user