mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Code snippets
This commit is contained in:
@@ -2,10 +2,79 @@
|
||||
import LabelModule = require("ui/label");
|
||||
import helper = require("../helper");
|
||||
import builder = require("ui/builder");
|
||||
import actionBar = require("ui/action-bar");
|
||||
import button = require("ui/button");
|
||||
import PageModule = require("ui/page");
|
||||
|
||||
// <snippet module="ui/action-bar" title="ActionBar">
|
||||
// # ActionBar
|
||||
// Using a ActionBar requires the action-bar module.
|
||||
// ``` JavaScript
|
||||
import actionBarModule = require("ui/action-bar");
|
||||
// ```
|
||||
//
|
||||
// ## Setting Title and Icon
|
||||
//```XML
|
||||
// <Page>
|
||||
// <Page.actionBar>
|
||||
// {%raw%}<ActionBar title="{{ title }}" android.icon="res://ic_test"/>{%endraw%}
|
||||
// </Page.actionBar>
|
||||
// ...
|
||||
// </Page>
|
||||
//```
|
||||
//The icon can only be set in Android platform. Following the design guides it is automatically hidden in Lollipop versions (API level >= 20). You explicitly control its visibility with the `android.iconVisibility' property.
|
||||
//
|
||||
//
|
||||
// ## Setting Custom Title View
|
||||
//```XML
|
||||
// <Page loaded="pageLoaded">
|
||||
// <Page.actionBar>
|
||||
// <ActionBar title="Title">
|
||||
// <ActionBar.titleView>
|
||||
// <StackLayout orientation="horizontal">
|
||||
// <Button text="1st" />
|
||||
// <Button text="2nd" />
|
||||
// <Button text="3rd" />
|
||||
// </StackLayout>
|
||||
// </ActionBar.titleView>
|
||||
// </ActionBar>
|
||||
// </Page.actionBar>
|
||||
// ...
|
||||
// </Page>
|
||||
//```
|
||||
//
|
||||
// ## Setting Action Items
|
||||
//```XML
|
||||
// <Page>
|
||||
// <Page.actionBar>
|
||||
// <ActionBar title="Title">
|
||||
// <ActionBar.actionItems>
|
||||
// <ActionItem text="left" ios.position="left"/>
|
||||
// <ActionItem text="right" ios.position="right"/>
|
||||
// <ActionItem text="pop" ios.position="right" android.position="popup"/>
|
||||
// </ActionBar.actionItems>
|
||||
// </ActionBar>
|
||||
// </Page.actionBar>
|
||||
// ...
|
||||
// </Page>
|
||||
//```
|
||||
//
|
||||
//The position option is platform specific. The available values are as follows:
|
||||
// * **Android** - `actionBar`, `actionBarIfRoom` and `popup`. The default is `actionBar`.
|
||||
// * **iOS** - `left` and `right`. The default is `left`.
|
||||
//
|
||||
// ## Setting Navigation Button
|
||||
//```XML
|
||||
// <Page>
|
||||
// <Page.actionBar>
|
||||
// <ActionBar title="Title">
|
||||
// <NavigationButton text="go back"/>
|
||||
// </ActionBar>
|
||||
// ...
|
||||
// </Page>
|
||||
//```
|
||||
//
|
||||
// </snippet>
|
||||
|
||||
export function test_actionItem_inherit_bindingContext() {
|
||||
var page: PageModule.Page;
|
||||
var label: LabelModule.Label;
|
||||
@@ -14,7 +83,7 @@ export function test_actionItem_inherit_bindingContext() {
|
||||
var pageFactory = function (): PageModule.Page {
|
||||
page = new PageModule.Page();
|
||||
page.bindingContext = context;
|
||||
var actionItem = new actionBar.ActionItem();
|
||||
var actionItem = new actionBarModule.ActionItem();
|
||||
|
||||
actionItem.bind({
|
||||
sourceProperty: "text",
|
||||
@@ -110,7 +179,7 @@ export function test_Setting_ActionItems_doesnt_thrown() {
|
||||
|
||||
var pageFactory = function (): PageModule.Page {
|
||||
page = new PageModule.Page();
|
||||
var actionItem = new actionBar.ActionItem();
|
||||
var actionItem = new actionBarModule.ActionItem();
|
||||
actionItem.text = "Item";
|
||||
page.actionBar.actionItems.addItem(actionItem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user