From 8d8cea103fe301d8b8f8570af6e31be2f4a1654d Mon Sep 17 00:00:00 2001 From: hshristov Date: Mon, 3 Aug 2015 12:02:38 +0300 Subject: [PATCH] Fix wrap-layout implementation for iOS Fix layout-helper so that unit-tests can work again --- apps/tests/layouts/layout-helper.ios.ts | 7 +++++++ ui/layouts/wrap-layout/wrap-layout.ios.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/tests/layouts/layout-helper.ios.ts b/apps/tests/layouts/layout-helper.ios.ts index f315b6361..748cc89e5 100644 --- a/apps/tests/layouts/layout-helper.ios.ts +++ b/apps/tests/layouts/layout-helper.ios.ts @@ -88,6 +88,13 @@ export class MyButton extends button.Button { get layoutTop(): number { return this._layoutTop; } + + _getCurrentMeasureSpecs(): { widthMeasureSpec: number; heightMeasureSpec: number } { + return { + widthMeasureSpec: (this)._oldWidthMeasureSpec, + heightMeasureSpec: (this)._oldHeightMeasureSpec + }; + } } export function assertMeasure(btn: MyButton, width: number, height: number, name?: string) { diff --git a/ui/layouts/wrap-layout/wrap-layout.ios.ts b/ui/layouts/wrap-layout/wrap-layout.ios.ts index de01466fd..a5019e405 100644 --- a/ui/layouts/wrap-layout/wrap-layout.ios.ts +++ b/ui/layouts/wrap-layout/wrap-layout.ios.ts @@ -146,7 +146,7 @@ export class WrapLayout extends common.WrapLayout { childWidth = length; - childHeight = isNaN(this.itemHeight) ? childHeight : this.itemHeight * density; + childHeight = this.itemHeight > 0 ? this.itemHeight * density : childHeight; if (childTop + childHeight > childrenLength) { // Move to top. childTop = this.paddingTop * density; @@ -162,7 +162,7 @@ export class WrapLayout extends common.WrapLayout { } } else { - childWidth = isNaN(this.itemWidth) ? childWidth : this.itemWidth * density; + childWidth = this.itemWidth > 0 ? this.itemWidth * density : childWidth; childHeight = length; if (childLeft + childWidth > childrenLength) { // Move to left.