|
1 |
| -import {Component} from '@angular/core'; |
2 |
| -//TODO: port to latest router |
3 |
| -//import {RouteConfig} from '@angular/router-deprecated'; |
4 |
| -//import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router-deprecated/ns-router-deprecated"; |
5 |
| -const NS_ROUTER_DIRECTIVES = []; |
6 |
| - |
7 |
| -import { Page} from "ui/page"; |
8 |
| -import {NS_DIRECTIVES} from "nativescript-angular/directives"; |
9 |
| - |
10 |
| -@Component({ |
11 |
| - selector: "first", |
12 |
| - directives: [NS_ROUTER_DIRECTIVES, NS_DIRECTIVES], |
13 |
| - template: ` |
14 |
| - <ActionBar title="Custom Title"> |
15 |
| - <ActionItem *ngIf="show" text="action" (tap)="onTap()"></ActionItem> |
16 |
| - <ActionItem ios.systemIcon="9" android.systemIcon="ic_menu_share_holo_light" (tap)="onShare()"></ActionItem> |
17 |
| - </ActionBar> |
18 |
| -
|
19 |
| - <StackLayout verticalAlignment="center"> |
20 |
| - <Button [text]="show ? 'hide' : 'show'" (tap)="show = !show"></Button> |
21 |
| - <Button text="Start" [nsRouterLink]="['/Second']"></Button> |
22 |
| - </StackLayout> |
23 |
| - `, |
24 |
| -}) |
25 |
| -class FirstComponent { |
26 |
| - public show: boolean = true; |
27 |
| - onTap() { |
28 |
| - console.log("FirstComponent.Tapped!"); |
29 |
| - } |
30 |
| - onShare() { |
31 |
| - console.log("Share button tapped!"); |
32 |
| - } |
33 |
| -} |
34 |
| - |
35 |
| - |
36 |
| -@Component({ |
37 |
| - selector: "nested-component", |
38 |
| - directives: [NS_ROUTER_DIRECTIVES, NS_DIRECTIVES], |
39 |
| - template: ` |
40 |
| -
|
41 |
| - <ActionBarExtension> |
42 |
| - <ActionItem *ngIf="show" (tap)="onTap()"> |
43 |
| - <Button text="CUSTOM"></Button> |
44 |
| - </ActionItem> |
45 |
| - </ActionBarExtension> |
46 |
| -
|
47 |
| - <StackLayout verticalAlignment="center"> |
48 |
| - <Button [text]="show ? 'hide' : 'show'" (tap)="show = !show"></Button> |
49 |
| - </StackLayout> |
50 |
| - `, |
51 |
| -}) |
52 |
| -class NestedComponent { |
53 |
| - public show: boolean = true; |
54 |
| - |
55 |
| - onTap() { |
56 |
| - console.log("NestedComponent.Tapped!"); |
57 |
| - } |
58 |
| -} |
59 |
| - |
60 |
| -@Component({ |
61 |
| - selector: "second", |
62 |
| - directives: [NS_ROUTER_DIRECTIVES, NS_DIRECTIVES, NestedComponent], |
63 |
| - template: ` |
64 |
| - <ActionBar title="Second Page Title"> |
65 |
| - <NavigationButton text="First" android.systemIcon="ic_menu_back"></NavigationButton> |
66 |
| - <ActionItem text="TapMe" (tap)="onTap()"></ActionItem> |
67 |
| - </ActionBar> |
68 |
| -
|
69 |
| - <StackLayout verticalAlignment="center"> |
70 |
| - <Label text="Second Page is Here" class="title"></Label> |
71 |
| - <nested-component></nested-component> |
72 |
| - </StackLayout> |
73 |
| - `, |
74 |
| -}) |
75 |
| -class SecondComponent { |
76 |
| - onTap() { |
77 |
| - console.log("SecondComponent.Tapped!"); |
78 |
| - } |
79 |
| -} |
80 |
| - |
81 |
| -@Component({ |
82 |
| - selector: 'action-bar-test', |
83 |
| - directives: [NS_ROUTER_DIRECTIVES], |
84 |
| - template: ` |
85 |
| - <GridLayout> |
86 |
| - <page-router-outlet></page-router-outlet> |
87 |
| - </GridLayout> |
88 |
| - ` |
89 |
| -}) |
90 |
| -//TODO: port to latest router |
91 |
| -//@RouteConfig([ |
92 |
| - //{ path: '/', component: FirstComponent, name: 'First' }, |
93 |
| - //{ path: '/second', component: SecondComponent, name: 'Second' }, |
94 |
| -//]) |
95 |
| -export class ActionBarTest { |
96 |
| -} |
97 |
| - |
98 |
| - |
| 1 | +import { Component } from '@angular/core'; |
| 2 | +import { Page} from "ui/page"; |
| 3 | + |
| 4 | +@Component({ |
| 5 | + selector: "first", |
| 6 | + template: ` |
| 7 | + <ActionBar title="Custom Title"> |
| 8 | + <ActionItem *ngIf="show" text="action" (tap)="onTap()"></ActionItem> |
| 9 | + <ActionItem ios.systemIcon="9" android.systemIcon="ic_menu_share_holo_light" (tap)="onShare()"></ActionItem> |
| 10 | + </ActionBar> |
| 11 | +
|
| 12 | + <StackLayout verticalAlignment="center"> |
| 13 | + <Button [text]="show ? 'hide' : 'show'" (tap)="show = !show"></Button> |
| 14 | + <Button text="Start" [nsRouterLink]="['/second']"></Button> |
| 15 | + </StackLayout> |
| 16 | + `, |
| 17 | +}) |
| 18 | +class FirstComponent { |
| 19 | + public show: boolean = true; |
| 20 | + onTap() { |
| 21 | + console.log("FirstComponent.Tapped!"); |
| 22 | + } |
| 23 | + onShare() { |
| 24 | + console.log("Share button tapped!"); |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +@Component({ |
| 30 | + selector: "nested-component", |
| 31 | + template: ` |
| 32 | +
|
| 33 | + <ActionBarExtension> |
| 34 | + <ActionItem *ngIf="show" (tap)="onTap()"> |
| 35 | + <Button text="CUSTOM"></Button> |
| 36 | + </ActionItem> |
| 37 | + </ActionBarExtension> |
| 38 | +
|
| 39 | + <StackLayout verticalAlignment="center"> |
| 40 | + <Button [text]="show ? 'hide' : 'show'" (tap)="show = !show"></Button> |
| 41 | + </StackLayout> |
| 42 | + `, |
| 43 | +}) |
| 44 | +class NestedComponent { |
| 45 | + public show: boolean = true; |
| 46 | + |
| 47 | + onTap() { |
| 48 | + console.log("NestedComponent.Tapped!"); |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +@Component({ |
| 53 | + selector: "second", |
| 54 | + template: ` |
| 55 | + <ActionBar title="Second Page Title"> |
| 56 | + <NavigationButton text="First" android.systemIcon="ic_menu_back"></NavigationButton> |
| 57 | + <ActionItem text="TapMe" (tap)="onTap()"></ActionItem> |
| 58 | + </ActionBar> |
| 59 | +
|
| 60 | + <StackLayout verticalAlignment="center"> |
| 61 | + <Label text="Second Page is Here" class="title"></Label> |
| 62 | + <nested-component></nested-component> |
| 63 | + </StackLayout> |
| 64 | + `, |
| 65 | +}) |
| 66 | +class SecondComponent { |
| 67 | + onTap() { |
| 68 | + console.log("SecondComponent.Tapped!"); |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +@Component({ |
| 73 | + selector: 'action-bar-test', |
| 74 | + template: ` |
| 75 | + <GridLayout> |
| 76 | + <page-router-outlet></page-router-outlet> |
| 77 | + </GridLayout> |
| 78 | + ` |
| 79 | +}) |
| 80 | +export class ActionBarTest { |
| 81 | + static routes = [ |
| 82 | + { path: '', component: FirstComponent }, |
| 83 | + { path: 'second', component: SecondComponent }, |
| 84 | + ] |
| 85 | + |
| 86 | + static entries = [ |
| 87 | + FirstComponent, |
| 88 | + SecondComponent, |
| 89 | + ] |
| 90 | +} |
| 91 | + |
| 92 | + |
0 commit comments