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

@ -1,7 +1,7 @@
<Page loaded="pageLoaded"> <Page loaded="pageLoaded">
<Page.actionBar> <Page.actionBar>
<ActionBar title="Title"> <ActionBar title="Title">
<ActionBar.centerView> <ActionBar.titleView>
<SegmentedBar selectedIndex="{{ index }}"> <SegmentedBar selectedIndex="{{ index }}">
<SegmentedBar.items> <SegmentedBar.items>
<SegmentedBarItem title="Item 1" /> <SegmentedBarItem title="Item 1" />
@ -9,7 +9,7 @@
<SegmentedBarItem title="Item 3" /> <SegmentedBarItem title="Item 3" />
</SegmentedBar.items> </SegmentedBar.items>
</SegmentedBar> </SegmentedBar>
</ActionBar.centerView> </ActionBar.titleView>
</ActionBar> </ActionBar>
</Page.actionBar> </Page.actionBar>
<StackLayout> <StackLayout>

View File

@ -1,13 +1,13 @@
<Page loaded="pageLoaded"> <Page loaded="pageLoaded">
<Page.actionBar> <Page.actionBar>
<ActionBar title="Title"> <ActionBar title="Title">
<ActionBar.centerView> <ActionBar.titleView>
<StackLayout orientation="horizontal" verticalAlignment="center" horizontalAlignment="center"> <StackLayout orientation="horizontal">
<Button text="1st" /> <Button text="1st" />
<Button text="2nd" /> <Button text="2nd" />
<Button text="3rd" /> <Button text="3rd" />
</StackLayout> </StackLayout>
</ActionBar.centerView> </ActionBar.titleView>
</ActionBar> </ActionBar>
</Page.actionBar> </Page.actionBar>
<StackLayout> <StackLayout>

View File

@ -1,9 +1,9 @@
<Page loaded="pageLoaded"> <Page loaded="pageLoaded">
<Page.actionBar> <Page.actionBar>
<ActionBar title="Title"> <ActionBar title="Title">
<ActionBar.centerView> <ActionBar.titleView>
<Button text="{{ centerText }}" tap="{{ centerTap }}" /> <Button text="{{ centerText }}" tap="{{ centerTap }}" />
</ActionBar.centerView> </ActionBar.titleView>
</ActionBar> </ActionBar>
</Page.actionBar> </Page.actionBar>
<StackLayout> <StackLayout>

View File

@ -70,35 +70,35 @@ export function test_navigationButton_inherit_bindingContext_inXML() {
TKUnit.assertEqual(navButton.text, "success", "actionItem.text"); TKUnit.assertEqual(navButton.text, "success", "actionItem.text");
}; };
export function test_centerView_inherit_bindingContext_inXML() { export function test_titleView_inherit_bindingContext_inXML() {
var p = <PageModule.Page>builder.parse( var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionBar.centerView>" + "<Page> <Page.actionBar> <ActionBar> <ActionBar.titleView>" +
"<Button text=\"{{ myProp }} \" />" + "<Button text=\"{{ myProp }} \" />" +
"</ActionBar.centerView> </ActionBar> </Page.actionBar> </Page>"); "</ActionBar.titleView> </ActionBar> </Page.actionBar> </Page>");
p.bindingContext = { myProp: "success" }; p.bindingContext = { myProp: "success" };
var centerBtn = <button.Button>p.actionBar.centerView; var centerBtn = <button.Button>p.actionBar.titleView;
TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly"); TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly");
TKUnit.assertEqual(centerBtn.text, "success", "actionItem.text"); TKUnit.assertEqual(centerBtn.text, "success", "actionItem.text");
}; };
export function test_centerView_inXML() { export function test_titleView_inXML() {
var p = <PageModule.Page>builder.parse( var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionBar.centerView>" + "<Page> <Page.actionBar> <ActionBar> <ActionBar.titleView>" +
"<Button/>" + "<Button/>" +
"</ActionBar.centerView> </ActionBar> </Page.actionBar> </Page>"); "</ActionBar.titleView> </ActionBar> </Page.actionBar> </Page>");
var centerBtn = <button.Button>p.actionBar.centerView; var centerBtn = <button.Button>p.actionBar.titleView;
TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly"); TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly");
}; };
export function test_centerView_inXML_short_definition() { export function test_titleView_inXML_short_definition() {
var p = <PageModule.Page>builder.parse( var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar>" + "<Page> <Page.actionBar> <ActionBar>" +
"<Button/>" + "<Button/>" +
"</ActionBar> </Page.actionBar> </Page>"); "</ActionBar> </Page.actionBar> </Page>");
var centerBtn = <button.Button>p.actionBar.centerView; var centerBtn = <button.Button>p.actionBar.titleView;
TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly"); TKUnit.assert(centerBtn instanceof button.Button, "cneterView not loaded correctly");
}; };

View File

@ -127,18 +127,18 @@ export var test_event_LoadedUnloaded_IsRaised = function () {
var layoutUnloaded = false, var layoutUnloaded = false,
buttonUnloaded = false; buttonUnloaded = false;
views[1].on(viewModule.View.unloadedEvent,(data) => { views[1].on(viewModule.View.unloadedEvent, (data) => {
layoutUnloaded = true; layoutUnloaded = true;
}); });
views[2].on(viewModule.View.unloadedEvent,(data) => { views[2].on(viewModule.View.unloadedEvent, (data) => {
buttonUnloaded = true; buttonUnloaded = true;
}); });
var newButton = new button.Button(), var newButton = new button.Button(),
buttonLoaded = false; buttonLoaded = false;
newButton.on(viewModule.View.loadedEvent,(data) => { newButton.on(viewModule.View.loadedEvent, (data) => {
buttonLoaded = true; buttonLoaded = true;
}); });

View File

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

View File

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

View File

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