Fix: bugs caught with tests

This commit is contained in:
vakrilov
2016-01-21 17:13:58 +02:00
committed by vakrilov
parent 96c638e1cc
commit 216cfb11de
2 changed files with 9 additions and 7 deletions

View File

@ -271,7 +271,7 @@ export class View extends viewCommon.View {
if (superview && this._nativeView) {
var types = require("utils/types");
if (types.isNullOrUndefined(atIndex) || atIndex >= this._nativeView.subviews.count) {
if (types.isNullOrUndefined(atIndex) || atIndex >= superview.subviews.count) {
superview.addSubview(this._nativeView);
} else {
superview.insertSubviewAtIndex(this._nativeView, atIndex);

View File

@ -100,7 +100,13 @@ export class DockLayout extends common.DockLayout {
let childWidth = child.getMeasuredWidth() + (lp.leftMargin + lp.rightMargin) * density;
let childHeight = child.getMeasuredHeight() + (lp.topMargin + lp.bottomMargin) * density;
if (last && this.stretchLastChild) {
// Last child with stretch - give it all the space and return;
View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight);
return;
}
let dock = DockLayout.getDock(child);
switch (dock) {
case Dock.top:
@ -135,11 +141,7 @@ export class DockLayout extends common.DockLayout {
break;
}
if (!last) {
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
} else {
View.layoutChild(this, child, x, y, x + remainingWidth, y + remainingHeight);
}
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
});
DockLayout.restoreOriginalParams(this);