mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
CenterView renamed to TitleView
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<ActionBar.titleView>
|
||||
<SegmentedBar selectedIndex="{{ index }}">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="Item 1" />
|
||||
@ -9,7 +9,7 @@
|
||||
<SegmentedBarItem title="Item 3" />
|
||||
</SegmentedBar.items>
|
||||
</SegmentedBar>
|
||||
</ActionBar.centerView>
|
||||
</ActionBar.titleView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<StackLayout orientation="horizontal" verticalAlignment="center" horizontalAlignment="center">
|
||||
<ActionBar.titleView>
|
||||
<StackLayout orientation="horizontal">
|
||||
<Button text="1st" />
|
||||
<Button text="2nd" />
|
||||
<Button text="3rd" />
|
||||
</StackLayout>
|
||||
</ActionBar.centerView>
|
||||
</ActionBar.titleView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<ActionBar.titleView>
|
||||
<Button text="{{ centerText }}" tap="{{ centerTap }}" />
|
||||
</ActionBar.centerView>
|
||||
</ActionBar.titleView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
|
@ -50,7 +50,7 @@ export function test_actionBar_inherit_bindingContext_inXML() {
|
||||
export function test_actionItem_inherit_bindingContext_inXML() {
|
||||
var p = <PageModule.Page>builder.parse(
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.actionItems>" +
|
||||
"<ActionItem text=\"{{ myProp }} \" />" +
|
||||
"<ActionItem text=\"{{ myProp }} \" />" +
|
||||
"</ActionBar.actionItems> </ActionBar> </Page.actionBar> </Page>");
|
||||
p.bindingContext = { myProp: "success" };
|
||||
|
||||
@ -70,35 +70,35 @@ export function test_navigationButton_inherit_bindingContext_inXML() {
|
||||
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(
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.centerView>" +
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.titleView>" +
|
||||
"<Button text=\"{{ myProp }} \" />" +
|
||||
"</ActionBar.centerView> </ActionBar> </Page.actionBar> </Page>");
|
||||
"</ActionBar.titleView> </ActionBar> </Page.actionBar> </Page>");
|
||||
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.assertEqual(centerBtn.text, "success", "actionItem.text");
|
||||
};
|
||||
|
||||
export function test_centerView_inXML() {
|
||||
export function test_titleView_inXML() {
|
||||
var p = <PageModule.Page>builder.parse(
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.centerView>" +
|
||||
"<Page> <Page.actionBar> <ActionBar> <ActionBar.titleView>" +
|
||||
"<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");
|
||||
};
|
||||
|
||||
export function test_centerView_inXML_short_definition() {
|
||||
export function test_titleView_inXML_short_definition() {
|
||||
var p = <PageModule.Page>builder.parse(
|
||||
"<Page> <Page.actionBar> <ActionBar>" +
|
||||
"<Button/>" +
|
||||
"</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");
|
||||
};
|
||||
|
||||
|
@ -127,18 +127,18 @@ export var test_event_LoadedUnloaded_IsRaised = function () {
|
||||
var layoutUnloaded = false,
|
||||
buttonUnloaded = false;
|
||||
|
||||
views[1].on(viewModule.View.unloadedEvent,(data) => {
|
||||
views[1].on(viewModule.View.unloadedEvent, (data) => {
|
||||
layoutUnloaded = true;
|
||||
});
|
||||
|
||||
views[2].on(viewModule.View.unloadedEvent,(data) => {
|
||||
views[2].on(viewModule.View.unloadedEvent, (data) => {
|
||||
buttonUnloaded = true;
|
||||
});
|
||||
|
||||
var newButton = new button.Button(),
|
||||
buttonLoaded = false;
|
||||
|
||||
newButton.on(viewModule.View.loadedEvent,(data) => {
|
||||
newButton.on(viewModule.View.loadedEvent, (data) => {
|
||||
buttonLoaded = true;
|
||||
});
|
||||
|
||||
@ -598,7 +598,7 @@ function _createLabelWithBorder(): viewModule.View {
|
||||
|
||||
export var testIsVisible = function () {
|
||||
var lbl = new label.Label();
|
||||
|
||||
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
|
||||
TKUnit.assert(lbl.visibility === enums.Visibility.visible, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.visible);
|
||||
TKUnit.assert(lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: true;");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
2
ui/action-bar/action-bar.d.ts
vendored
2
ui/action-bar/action-bar.d.ts
vendored
@ -12,7 +12,7 @@
|
||||
|
||||
navigationButton: NavigationButton;
|
||||
actionItems: ActionItems;
|
||||
centerView: view.View;
|
||||
titleView: view.View;
|
||||
|
||||
page: pages.Page;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user