Layout round instead of ceiling (#3833)

* Layout round instead of cailing
Add helper method to layout module to convert to/from dips to px and measure the native view
whiteSpace affects layout added for iOS
Fix bug in switch onMeasure implementation
Fix bug in cssValueToDevicePixels iOS implementation
ActionBar for iOS is measured with AT_MOST modifier

* Fix switch measure routine
This commit is contained in:
Hristo Hristov
2017-03-20 16:11:16 +02:00
committed by GitHub
parent f165382bb7
commit fe54ac6ead
18 changed files with 162 additions and 330 deletions

View File

@ -26,6 +26,7 @@ class SwitchChangeHandlerImpl extends NSObject {
};
}
const zeroSize = { width: 0, height: 0 };
export class Switch extends SwitchBase {
private _ios: UISwitch;
private _handler: NSObject;
@ -52,12 +53,12 @@ export class Switch extends SwitchBase {
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
// It can't be anything different from 51x31
let nativeSize = this._nativeView.sizeThatFits(CGSizeMake(0, 0));
let nativeSize = this._nativeView.sizeThatFits(zeroSize);
this.width = nativeSize.width;
this.height = nativeSize.height;
let widthAndState = layout.makeMeasureSpec(layout.toDevicePixels(nativeSize.width), layout.EXACTLY);
let heightAndState = layout.makeMeasureSpec(layout.toDevicePixels(nativeSize.height), layout.EXACTLY);
const widthAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.width), layout.toDevicePixels(51), layout.EXACTLY, 0);
const heightAndState = Switch.resolveSizeAndState(layout.toDevicePixels(nativeSize.height), layout.toDevicePixels(31), layout.EXACTLY, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}