Skip to content

Commit 1bd52ef

Browse files
committed
Fixed Issue NativeScript#518: Allow ActionItems to be directly specified between the ActionBar opening and closing tags.
1 parent 9418ab8 commit 1bd52ef

9 files changed

+72
-4
lines changed

CrossPlatformModules.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<TypeScriptCompile Include="apps\action-bar-demo\pages\action-items-text.ts">
6868
<DependentUpon>action-items-text.xml</DependentUpon>
6969
</TypeScriptCompile>
70+
<TypeScriptCompile Include="apps\action-bar-demo\pages\all-between-tags.ts">
71+
<DependentUpon>all-between-tags.xml</DependentUpon>
72+
</TypeScriptCompile>
7073
<TypeScriptCompile Include="apps\action-bar-demo\pages\center-view-stack.ts">
7174
<DependentUpon>center-view-stack.xml</DependentUpon>
7275
</TypeScriptCompile>
@@ -118,12 +121,14 @@
118121
<Content Include="apps\action-bar-demo\pages\center-view-segmented.xml" />
119122
<Content Include="apps\action-bar-demo\pages\center-view.xml" />
120123
<Content Include="apps\action-bar-demo\pages\data-binding.xml" />
124+
<Content Include="apps\action-bar-demo\pages\all-between-tags.xml" />
121125
<Content Include="apps\animations\opacity.css" />
122126
<Content Include="apps\animations\opacity.xml">
123127
<SubType>Designer</SubType>
124128
</Content>
125129
<Content Include="apps\animations\bkg.png" />
126130
<Content Include="apps\animations\test-icon.png" />
131+
<Content Include="apps\tests\ui\action-bar\ActionBar_BetweenTags.xml" />
127132
<Content Include="apps\tests\ui\action-bar\ActionBar_NumberAsText.xml" />
128133
<Content Include="apps\tests\ui\page\modal-page.xml">
129134
<SubType>Designer</SubType>
@@ -988,7 +993,9 @@
988993
<Content Include="apps\cuteness.unoptimized\res\reddit-logo.png" />
989994
<Content Include="apps\cuteness.unoptimized\res\telerik-logo.png" />
990995
<Content Include="apps\action-bar-demo\app.css" />
991-
<Content Include="apps\action-bar-demo\main-page.xml" />
996+
<Content Include="apps\action-bar-demo\main-page.xml">
997+
<SubType>Designer</SubType>
998+
</Content>
992999
<Content Include="apps\action-bar-demo\pages\action-items-text.xml">
9931000
<SubType>Designer</SubType>
9941001
</Content>

apps/action-bar-demo/main-page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<Button tap="itemTap" text="center view" tag="center-view" />
2020
<Button tap="itemTap" text="center segmented" tag="center-view-segmented" />
2121
<Button tap="itemTap" text="center stack" tag="center-view-stack" />
22+
<Button tap="itemTap" text="all between tags" tag="all-between-tags" />
2223
</StackLayout>
2324
</ScrollView>
2425
</Page>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import observable = require("data/observable");
2+
3+
export function onTapped(args: observable.EventData) {
4+
console.log(`Tapped ${(<any>args.object).text}`);
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Page>
2+
<Page.actionBar>
3+
<ActionBar>
4+
<ActionItem text="i1" tap="onTapped"/>
5+
<Label text="tv" tap="onTapped"/>
6+
<ActionItem text="i2" tap="onTapped"/>
7+
<NavigationButton text="nb" android.systemIcon="ic_menu_back" tap="onTapped"/>
8+
<ActionItem text="i3" tap="onTapped"/>
9+
</ActionBar>
10+
</Page.actionBar>
11+
12+
<StackLayout>
13+
<Label text="page content"/>
14+
</StackLayout>
15+
</Page>

apps/action-bar-demo/pages/navigation-button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ export function visibilityTap(args: observable.EventData) {
4444
}
4545

4646
export function navTap(args: observable.EventData) {
47-
console.log("navigation button tapped");
47+
console.log("(Android only) Navigation button tapped");
4848
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Page>
2+
<Page.actionBar>
3+
<ActionBar>
4+
<ActionItem text="i1" tap="onTapped"/>
5+
<Label text="tv" tap="onTapped"/>
6+
<ActionItem text="i2" tap="onTapped"/>
7+
<NavigationButton text="nb" tap="onTapped"/>
8+
<ActionItem text="i3" tap="onTapped"/>
9+
</ActionBar>
10+
</Page.actionBar>
11+
12+
<StackLayout>
13+
<Label text="page content"/>
14+
</StackLayout>
15+
</Page>

apps/tests/ui/action-bar/action-bar-tests-common.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,28 @@ export function test_Setting_ActionItemsWithNumberAsText_doesnt_thrown() {
324324
}
325325
}
326326

327+
export function test_CanDefineEverythingAsContentBetweenTheTwoTags() {
328+
var moduleName = __dirname.substr(fs.knownFolders.currentApp().path.length);
329+
helper.navigateToModuleAndRunTest(moduleName + "/ActionBar_BetweenTags", undefined, (page: PageModule.Page) => {
330+
331+
TKUnit.assertNotNull(page.actionBar.navigationButton);
332+
TKUnit.assertEqual(page.actionBar.navigationButton.text, "nb");
333+
334+
TKUnit.assertNull(page.actionBar.title);
335+
TKUnit.assertNotNull(page.actionBar.titleView);
336+
TKUnit.assertTrue(page.actionBar.titleView instanceof LabelModule.Label);
337+
TKUnit.assertEqual((<LabelModule.Label>page.actionBar.titleView).text, "tv");
338+
339+
TKUnit.assertNotNull(page.actionBar.actionItems);
340+
var items = page.actionBar.actionItems.getItems();
341+
TKUnit.assertEqual(items.length, 3);
342+
343+
TKUnit.assertEqual(items[0].text, "i1");
344+
TKUnit.assertEqual(items[1].text, "i2");
345+
TKUnit.assertEqual(items[2].text, "i3");
346+
});
347+
}
348+
327349
export function createPageAndNavigate() {
328350
var page: PageModule.Page;
329351
var pageFactory = function (): PageModule.Page {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"apps/action-bar-demo/pages/action-bar-hidden.ts",
4040
"apps/action-bar-demo/pages/action-items-icon.ts",
4141
"apps/action-bar-demo/pages/action-items-text.ts",
42+
"apps/action-bar-demo/pages/all-between-tags.ts",
4243
"apps/action-bar-demo/pages/center-view-segmented.ts",
4344
"apps/action-bar-demo/pages/center-view-stack.ts",
4445
"apps/action-bar-demo/pages/center-view.ts",

ui/action-bar/action-bar-common.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ export class ActionBar extends view.View implements dts.ActionBar {
129129
if (value instanceof dts.NavigationButton) {
130130
this.navigationButton = value;
131131
}
132-
133-
if (value instanceof view.View) {
132+
else if (value instanceof dts.ActionItem) {
133+
this.actionItems.addItem(value);
134+
}
135+
else if (value instanceof view.View) {
134136
this.titleView = value;
135137
}
136138
}

0 commit comments

Comments
 (0)