This commit is contained in:
Peter Staev
2016-02-15 12:18:32 +02:00
parent 07af447cb1
commit ea1ebd2c94
6 changed files with 84 additions and 0 deletions

View File

@@ -222,6 +222,9 @@
<SubType>Designer</SubType>
</Content>
<Content Include="apps\tests\pages\tab-view.xml" />
<Content Include="apps\ui-tests-app\action-bar\action-view.xml">
<SubType>Designer</SubType>
</Content>
<Content Include="apps\ui-tests-app\action-bar\system-icons.xml">
<SubType>Designer</SubType>
</Content>
@@ -255,6 +258,9 @@
<SubType>Designer</SubType>
</Content>
<TypeScriptCompile Include="apps\ui-tests-app\animations\background.ts" />
<TypeScriptCompile Include="apps\ui-tests-app\action-bar\action-view.ts">
<DependentUpon>action-view.xml</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="apps\ui-tests-app\pages\touch-event.ts" />
<Content Include="apps\ui-tests-app\pages\touch-event.xml">
<SubType>Designer</SubType>

View File

@@ -118,6 +118,27 @@ import actionBarModule = require("ui/action-bar");
//The value should be a string such as 'ic_menu_search' if you want to display the built-in Android Menu Search icon for example.
//For a full list of Android drawable names, please visit http://androiddrawables.com
//
// ## Displaying Custom View in Action Items
//```XML
// <Page>
// <Page.actionBar>
// <ActionBar>
// <ActionBar.actionItems>
// <ActionItem>
// <ActionItem.actionView>
// <StackLayout orientation="horizontal">
// <Label text="Green" color="green"/>
// <Label text="Red" color="red"/>
// </StackLayout>
// </ActionItem.actionView>
// </ActionItem>
// </ActionBar.actionItems>
// </ActionBar>
// </Page.actionBar>
// ...
// </Page>
//```
//
// ## Setting Navigation Button
//```XML
// <Page>
@@ -197,6 +218,37 @@ export function test_actionItem_page_property_inXML() {
TKUnit.assertEqual(actionItem.page, p, "actionItem.page");
};
export function test_actionItem_actionView_inXML() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionItem> <ActionItem.actionView>" +
"<Label/>" +
"</ActionItem.actionView> </ActionItem> </ActionBar> </Page.actionBar> </Page>");
var label = <LabelModule.Label>p.actionBar.actionItems.getItemAt(0).actionView;
TKUnit.assert(label instanceof LabelModule.Label, "ActionItem.actionView not loaded correctly");
};
export function test_actionItem_actionView_inherit_bindingContext_inXML() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionItem> <ActionItem.actionView>" +
"<Label text=\"{{ myProp }} \" />" +
"</ActionItem.actionView> </ActionItem> </ActionBar> </Page.actionBar> </Page>");
p.bindingContext = { myProp: "success" };
var label = <LabelModule.Label>p.actionBar.actionItems.getItemAt(0).actionView;
TKUnit.assert(label instanceof LabelModule.Label, "ActionItem.actionView not loaded correctly");
TKUnit.assertEqual(label.text, "success", "ActionItem.actionView");
};
export function test_ActionBar_is_not_empty_when_actionItem_actionView_is_set() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar> <ActionItem> <ActionItem.actionView>" +
"<Label text=\"test\" />" +
"</ActionItem.actionView> </ActionItem> </ActionBar> </Page.actionBar> </Page>");
TKUnit.assertFalse(p.actionBar._isEmpty(), "ActionItem.actionView is set but ActionBar reports empty");
};
export function test_navigationButton_inherit_bindingContext_inXML() {
var p = <PageModule.Page>builder.parse(
"<Page> <Page.actionBar> <ActionBar>" +

View File

@@ -0,0 +1,5 @@
import frame = require("ui/frame");
export function navigate(args) {
frame.topmost().navigate("action-bar/clean");
}

View File

@@ -0,0 +1,19 @@
<Page>
<Page.actionBar>
<ActionBar>
<ActionBar.actionItems>
<ActionItem>
<ActionItem.actionView>
<StackLayout orientation="horizontal">
<Label text="Green" color="green"/>
<Label text="Red" color="red"/>
</StackLayout>
</ActionItem.actionView>
</ActionItem>
</ActionBar.actionItems>
</ActionBar>
</Page.actionBar>
<StackLayout>
<Button text="go to cleared page" tap="navigate"/>
</StackLayout>
</Page>

View File

@@ -36,6 +36,7 @@ examples.set("actColor", "action-bar/color");
examples.set("actBG", "action-bar/background");
examples.set("actStyle", "action-bar/all");
examples.set("actIcons", "action-bar/system-icons");
examples.set("actView", "action-bar/action-view");
examples.set("basics", "bindings/basics");
examples.set("xmlbasics", "bindings/xmlbasics");

View File

@@ -343,6 +343,7 @@
"apps/ui-tests-app/action-bar/clean.ts",
"apps/ui-tests-app/action-bar/color.ts",
"apps/ui-tests-app/action-bar/system-icons.ts",
"apps/ui-tests-app/action-bar/action-view.ts",
"apps/ui-tests-app/animations/background.ts",
"apps/ui-tests-app/app.ts",
"apps/ui-tests-app/bindings/basics.ts",