mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Center View
This commit is contained in:
@ -7,6 +7,9 @@
|
||||
<Button tap="itemTap" text="action items icons" tag="action-items-icon" />
|
||||
<Button tap="itemTap" text="action items text" tag="action-items-text" />
|
||||
<Button tap="itemTap" text="data binding" tag="data-binding" />
|
||||
<Button tap="itemTap" text="center view" tag="center-view" />
|
||||
<Button tap="itemTap" text="center segmented" tag="center-view-segmented" />
|
||||
<Button tap="itemTap" text="center stack" tag="center-view-stack" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</Page>
|
8
apps/action-bar-demo/pages/center-view-segmented.ts
Normal file
8
apps/action-bar-demo/pages/center-view-segmented.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import observable = require("data/observable");
|
||||
import pages = require("ui/page");
|
||||
|
||||
export function pageLoaded(args) {
|
||||
var page = <pages.Page>args.object;
|
||||
var vm = new observable.Observable();
|
||||
page.bindingContext = vm;
|
||||
}
|
18
apps/action-bar-demo/pages/center-view-segmented.xml
Normal file
18
apps/action-bar-demo/pages/center-view-segmented.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<SegmentedBar selectedIndex="{{ index }}">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="Item 1" />
|
||||
<SegmentedBarItem title="Item 2" />
|
||||
<SegmentedBarItem title="Item 3" />
|
||||
</SegmentedBar.items>
|
||||
</SegmentedBar>
|
||||
</ActionBar.centerView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<Button text="{{ index }}" />
|
||||
</StackLayout>
|
||||
</Page>
|
8
apps/action-bar-demo/pages/center-view-stack.ts
Normal file
8
apps/action-bar-demo/pages/center-view-stack.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import observable = require("data/observable");
|
||||
import pages = require("ui/page");
|
||||
|
||||
export function pageLoaded(args) {
|
||||
var page = <pages.Page>args.object;
|
||||
var vm = new observable.Observable();
|
||||
page.bindingContext = vm;
|
||||
}
|
16
apps/action-bar-demo/pages/center-view-stack.xml
Normal file
16
apps/action-bar-demo/pages/center-view-stack.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<StackLayout orientation="horizontal" verticalAlignment="center" horizontalAlignment="center">
|
||||
<Button text="1st" />
|
||||
<Button text="2nd" />
|
||||
<Button text="3rd" />
|
||||
</StackLayout>
|
||||
</ActionBar.centerView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<Button text="do nothong" />
|
||||
</StackLayout>
|
||||
</Page>
|
12
apps/action-bar-demo/pages/center-view.ts
Normal file
12
apps/action-bar-demo/pages/center-view.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import observable = require("data/observable");
|
||||
import pages = require("ui/page");
|
||||
|
||||
export function pageLoaded(args) {
|
||||
var page = <pages.Page>args.object;
|
||||
var vm = new observable.Observable();
|
||||
vm.set("centerText", "center text");
|
||||
vm.set("centerTap", function () {
|
||||
console.log("Center view tapped!");
|
||||
});
|
||||
page.bindingContext = vm;
|
||||
}
|
12
apps/action-bar-demo/pages/center-view.xml
Normal file
12
apps/action-bar-demo/pages/center-view.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<Page loaded="pageLoaded">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Title">
|
||||
<ActionBar.centerView>
|
||||
<Button text="{{ centerText }}" tap="{{ centerTap }}" />
|
||||
</ActionBar.centerView>
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<Button text="do nothing" />
|
||||
</StackLayout>
|
||||
</Page>
|
@ -18,7 +18,6 @@ export function buttonTap(args: observable.EventData) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var j = 0;
|
||||
export function visibilityTap(args: observable.EventData) {
|
||||
var page = <pages.Page>view.getAncestor(<view.View>args.object, "Page")
|
||||
|
Reference in New Issue
Block a user