CenterView renamed to TitleView

This commit is contained in:
vakrilov
2015-07-14 13:26:17 +03:00
parent ff2e8e6625
commit 2cdf1e222b
9 changed files with 53 additions and 53 deletions

View File

@@ -32,7 +32,7 @@ export class ActionBar extends view.View implements dts.ActionBar {
private _actionItems: ActionItems;
private _navigationButton: NavigationButton;
private _page: pages.Page;
private _centerView: view.View;
private _titleView: view.View;
get title(): string {
return this._getValue(ActionBar.titleProperty);
@@ -81,23 +81,23 @@ export class ActionBar extends view.View implements dts.ActionBar {
throw new Error("actionItems property is read-only");
}
get centerView(): view.View {
return this._centerView;
get titleView(): view.View {
return this._titleView;
}
set centerView(value: view.View) {
if (this._centerView !== value) {
if (this._centerView) {
this._removeView(this._centerView);
this._centerView.style._resetValue(style.horizontalAlignmentProperty, observable.ValueSource.Inherited);
this._centerView.style._resetValue(style.verticalAlignmentProperty, observable.ValueSource.Inherited);
set titleView(value: view.View) {
if (this._titleView !== value) {
if (this._titleView) {
this._removeView(this._titleView);
this._titleView.style._resetValue(style.horizontalAlignmentProperty, observable.ValueSource.Inherited);
this._titleView.style._resetValue(style.verticalAlignmentProperty, observable.ValueSource.Inherited);
}
this._centerView = value;
this._titleView = value;
if (this._centerView) {
this._centerView.style._setValue(style.horizontalAlignmentProperty, enums.HorizontalAlignment.center, observable.ValueSource.Inherited);
this._centerView.style._setValue(style.verticalAlignmentProperty, enums.VerticalAlignment.center, observable.ValueSource.Inherited);
this._addView(this._centerView);
if (this._titleView) {
this._titleView.style._setValue(style.horizontalAlignmentProperty, enums.HorizontalAlignment.center, observable.ValueSource.Inherited);
this._titleView.style._setValue(style.verticalAlignmentProperty, enums.VerticalAlignment.center, observable.ValueSource.Inherited);
this._addView(this._titleView);
}
this.updateActionBar();
@@ -118,7 +118,7 @@ export class ActionBar extends view.View implements dts.ActionBar {
}
get _childrenCount(): number {
return this.centerView ? 1 : 0;
return this.titleView ? 1 : 0;
}
constructor() {
@@ -160,7 +160,7 @@ export class ActionBar extends view.View implements dts.ActionBar {
}
if (value instanceof view.View) {
this.centerView = value;
this.titleView = value;
}
}
@@ -174,8 +174,8 @@ export class ActionBar extends view.View implements dts.ActionBar {
}
public _eachChildView(callback: (child: view.View) => boolean) {
if (this.centerView) {
callback(this.centerView);
if (this.titleView) {
callback(this.titleView);
}
}

View File

@@ -51,7 +51,7 @@ export class ActionBar extends common.ActionBar {
this._addActionItems(menu);
// Set title
this._updateTitleAndCenterView(actionBar);
this._updateTitleAndTitleView(actionBar);
// Set home icon
this._updateIcon(actionBar);
@@ -101,9 +101,9 @@ export class ActionBar extends common.ActionBar {
actionBar.setDisplayShowHomeEnabled(visibility);
}
public _updateTitleAndCenterView(actionBar: android.app.ActionBar) {
if (this.centerView) {
actionBar.setCustomView(this.centerView.android);
public _updateTitleAndTitleView(actionBar: android.app.ActionBar) {
if (this.titleView) {
actionBar.setCustomView(this.titleView.android);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
@@ -112,7 +112,7 @@ export class ActionBar extends common.ActionBar {
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
// No center view - show the title
// No title view - show the title
var title = this.title;
if (types.isDefined(title)) {
actionBar.setTitle(title);
@@ -143,7 +143,7 @@ export class ActionBar extends common.ActionBar {
public _onTitlePropertyChanged() {
if (frame.topmost().currentPage === this.page) {
this._updateTitleAndCenterView(frame.topmost().android.actionBar);
this._updateTitleAndTitleView(frame.topmost().android.actionBar);
}
}

View File

@@ -12,7 +12,7 @@
navigationButton: NavigationButton;
actionItems: ActionItems;
centerView: view.View;
titleView: view.View;
page: pages.Page;

View File

@@ -25,9 +25,9 @@ export class ActionBar extends common.ActionBar {
// Set Title
navigationItem.title = this.title;
if (this.centerView && this.centerView.ios) {
console.log("setting center view: " + this.centerView.ios);
navigationItem.titleView = this.centerView.ios;
if (this.titleView && this.titleView.ios) {
console.log("setting center view: " + this.titleView.ios);
navigationItem.titleView = this.titleView.ios;
}
// Find previous ViewController in the navigation stack
@@ -125,10 +125,10 @@ export class ActionBar extends common.ActionBar {
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
if (this.centerView) {
if (this.titleView) {
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
view.View.measureChild(this, this.centerView,
view.View.measureChild(this, this.titleView,
utils.layout.makeMeasureSpec(width, utils.layout.AT_MOST),
utils.layout.makeMeasureSpec(this.navigationBarHeight, utils.layout.AT_MOST));
}
@@ -138,7 +138,7 @@ export class ActionBar extends common.ActionBar {
}
public onLayout(left: number, top: number, right: number, bottom: number) {
view.View.layoutChild(this, this.centerView, 0, 0, right - left, this.navigationBarHeight);
view.View.layoutChild(this, this.titleView, 0, 0, right - left, this.navigationBarHeight);
super.onLayout(left, top, right, bottom);
}