From e79fd51ce496ce107ab674ee21e032f917108541 Mon Sep 17 00:00:00 2001 From: Matt Donovan Date: Sat, 6 Jun 2015 14:11:00 -0500 Subject: [PATCH 1/5] adding removeChildren() for layout and fixing comment typos --- ui/layouts/layout-base.d.ts | 5 +++++ ui/layouts/layout-base.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ui/layouts/layout-base.d.ts b/ui/layouts/layout-base.d.ts index f36d88968..111147ab7 100644 --- a/ui/layouts/layout-base.d.ts +++ b/ui/layouts/layout-base.d.ts @@ -45,6 +45,11 @@ */ removeChild(view: view.View); + /** + * Removes all views in this layout. + */ + removeChildren(); + /** * Gets or sets padding style property. */ diff --git a/ui/layouts/layout-base.ts b/ui/layouts/layout-base.ts index 47c0587be..c7ba48a62 100644 --- a/ui/layouts/layout-base.ts +++ b/ui/layouts/layout-base.ts @@ -56,6 +56,12 @@ export class LayoutBase extends view.CustomLayoutView implements definition.Layo this._subViews.splice(index, 1); } + public removeChildren() { + while (this.getChildrenCount() != 0) { + this.removeChild(this._subViews[this.getChildrenCount() - 1]); + } + } + public _eachChildView(callback: (child: view.View) => boolean) { var i; var length = this._subViews.length; From 7d948265f359f2ded367cd9cef49587f46722256 Mon Sep 17 00:00:00 2001 From: Matt Donovan Date: Sat, 6 Jun 2015 15:53:22 -0500 Subject: [PATCH 2/5] Adding removeColumns() and removeRows() to GridLayout --- ui/layouts/grid-layout/grid-layout-common.ts | 16 ++++++++++++++++ ui/layouts/grid-layout/grid-layout.d.ts | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/ui/layouts/grid-layout/grid-layout-common.ts b/ui/layouts/grid-layout/grid-layout-common.ts index 1c4c8a984..71fee88bd 100644 --- a/ui/layouts/grid-layout/grid-layout-common.ts +++ b/ui/layouts/grid-layout/grid-layout-common.ts @@ -202,6 +202,22 @@ export class GridLayout extends layouts.LayoutBase implements definition.GridLay this.onColumnRemoved(itemSpec, index); } + public removeColumns() { + for (var i = 0; i < this._cols.length; i++) { + this._cols[i].index = -1; + } + this._cols.length = 0; + this.invalidate(); + } + + public removeRows() { + for (var i = 0; i < this._rows.length; i++) { + this._rows[i].index = -1; + } + this._rows.length = 0; + this.invalidate(); + } + protected onRowChanged(element: view.View, oldValue: number, newValue: number) { // } diff --git a/ui/layouts/grid-layout/grid-layout.d.ts b/ui/layouts/grid-layout/grid-layout.d.ts index af688603f..fe9eb5d80 100644 --- a/ui/layouts/grid-layout/grid-layout.d.ts +++ b/ui/layouts/grid-layout/grid-layout.d.ts @@ -131,11 +131,21 @@ */ public removeColumn(itemSpec: ItemSpec): void; + /** + * Removes all columns specification from a GridLayout. + */ + removeColumns(): void; + /** * Removes a row specification from a GridLayout. */ public removeRow(itemSpec: ItemSpec): void; + /** + * Removes all rows specification from a GridLayout. + */ + removeRows(): void; + /** * Gets array of column specifications defined on this instance of GridLayout. */ From 69e651bb43577991e328c99cce2dedb1188cafed Mon Sep 17 00:00:00 2001 From: Matt Donovan Date: Mon, 8 Jun 2015 00:03:57 -0500 Subject: [PATCH 3/5] Adding void return statements --- ui/layouts/grid-layout/grid-layout.d.ts | 8 ++++---- ui/layouts/grid-layout/grid-layout.ios.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/layouts/grid-layout/grid-layout.d.ts b/ui/layouts/grid-layout/grid-layout.d.ts index fe9eb5d80..325a47c81 100644 --- a/ui/layouts/grid-layout/grid-layout.d.ts +++ b/ui/layouts/grid-layout/grid-layout.d.ts @@ -119,12 +119,12 @@ /** * Adds a column specification to a GridLayout. */ - public addColumn(itemSpec: ItemSpec); + public addColumn(itemSpec: ItemSpec): void; /** * Adds a row specification to a GridLayout. */ - public addRow(itemSpec: ItemSpec); + public addRow(itemSpec: ItemSpec): void; /** * Removes a column specification from a GridLayout. @@ -134,7 +134,7 @@ /** * Removes all columns specification from a GridLayout. */ - removeColumns(): void; + public removeColumns(): void; /** * Removes a row specification from a GridLayout. @@ -144,7 +144,7 @@ /** * Removes all rows specification from a GridLayout. */ - removeRows(): void; + public removeRows(): void; /** * Gets array of column specifications defined on this instance of GridLayout. diff --git a/ui/layouts/grid-layout/grid-layout.ios.ts b/ui/layouts/grid-layout/grid-layout.ios.ts index 1b20a3a3c..d03a6f120 100644 --- a/ui/layouts/grid-layout/grid-layout.ios.ts +++ b/ui/layouts/grid-layout/grid-layout.ios.ts @@ -12,7 +12,7 @@ export class GridLayout extends common.GridLayout { protected onRowAdded(itemSpec: common.ItemSpec) { this.invalidate(); - } + } protected onColumnAdded(itemSpec: common.ItemSpec) { this.invalidate(); From dad1510ce9ea1fc4cb55b8b2642d4f9bb2745347 Mon Sep 17 00:00:00 2001 From: Matt Donovan Date: Mon, 8 Jun 2015 00:11:04 -0500 Subject: [PATCH 4/5] Adding voiid return statements --- ui/layouts/layout-base.d.ts | 8 ++++---- ui/layouts/layout-base.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/layouts/layout-base.d.ts b/ui/layouts/layout-base.d.ts index 111147ab7..388bc5390 100644 --- a/ui/layouts/layout-base.d.ts +++ b/ui/layouts/layout-base.d.ts @@ -30,25 +30,25 @@ * Adds the view to children array. * @param view The view to be added to the end of the children array. */ - addChild(view: view.View); + addChild(view: view.View): void; /** * Inserts the view to children array at the specified index. * @param view The view to be added to the end of the children array. * @param atIndex The insertion index. */ - insertChild(child: view.View, atIndex: number); + insertChild(child: view.View, atIndex: number): void; /** * Removes the specified view from the children array. * @param view The view to remove from the children array. */ - removeChild(view: view.View); + removeChild(view: view.View): void; /** * Removes all views in this layout. */ - removeChildren(); + removeChildren(): void; /** * Gets or sets padding style property. diff --git a/ui/layouts/layout-base.ts b/ui/layouts/layout-base.ts index c7ba48a62..b5b6e77c1 100644 --- a/ui/layouts/layout-base.ts +++ b/ui/layouts/layout-base.ts @@ -37,18 +37,18 @@ export class LayoutBase extends view.CustomLayoutView implements definition.Layo return view.getViewById(this, id); } - public addChild(child: view.View) { + public addChild(child: view.View): void { // TODO: Do we need this method since we have the core logic in the View implementation? this._addView(child); this._subViews.push(child); } - public insertChild(child: view.View, atIndex: number) { + public insertChild(child: view.View, atIndex: number): void { this._addView(child, atIndex); this._subViews.splice(atIndex, 0, child); } - public removeChild(child: view.View) { + public removeChild(child: view.View): void { this._removeView(child); // TODO: consider caching the index on the child. @@ -56,13 +56,13 @@ export class LayoutBase extends view.CustomLayoutView implements definition.Layo this._subViews.splice(index, 1); } - public removeChildren() { + public removeChildren(): void { while (this.getChildrenCount() != 0) { this.removeChild(this._subViews[this.getChildrenCount() - 1]); } } - public _eachChildView(callback: (child: view.View) => boolean) { + public _eachChildView(callback: (child: view.View) => boolean): void { var i; var length = this._subViews.length; var retVal: boolean; From cfda63d42b74ebab9a1b4ffba91b0e98eb91e636 Mon Sep 17 00:00:00 2001 From: Matt Donovan Date: Mon, 8 Jun 2015 17:16:12 -0500 Subject: [PATCH 5/5] changing != to !== --- ui/layouts/layout-base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/layouts/layout-base.ts b/ui/layouts/layout-base.ts index b5b6e77c1..f72613418 100644 --- a/ui/layouts/layout-base.ts +++ b/ui/layouts/layout-base.ts @@ -57,7 +57,7 @@ export class LayoutBase extends view.CustomLayoutView implements definition.Layo } public removeChildren(): void { - while (this.getChildrenCount() != 0) { + while (this.getChildrenCount() !== 0) { this.removeChild(this._subViews[this.getChildrenCount() - 1]); } }