|
1 | 1 | import { Component } from "@angular/core"; |
2 | | - |
3 | | -import { FirstComponentActionBar } from "../action-bar/action-bar-first.component"; |
4 | | -import { SecondComponentActionBar } from "../action-bar/action-bar-second.component"; |
5 | | - |
6 | | -import { AppComponent } from "../template/app.component"; |
7 | | - |
8 | | -import { FirstComponent } from "../components/first.component"; |
9 | | -import { SecondComponent } from "../components/second.component"; |
10 | | -import { NavigationTestRouter, NavigationSubRoutes } from "../router/router-outlet"; |
11 | | - |
12 | | -import { BindingComponent } from "../binding/binding-page"; |
13 | | - |
14 | | -import { ListViewComponent } from "../listView/commonTemplate/list-view-page"; |
15 | | -import { ListViewControlComponent } from "../listView/customTemplate/list-view-item-template"; |
16 | | -import { ListViewAsyncPipeComponent } from "../listView/asyncPipeTemplate/async-pipe-template"; |
17 | | -import { ListViewMainPageComponent } from "../listView/listViewMainPage/list-view-main-page"; |
18 | | - |
19 | | -import { ModalTest, ModalTestWithPushStrategy } from "../modal/modal-dialog.component"; |
20 | | - |
21 | | -import { NavigationOptionsComponent } from "../navigation-options/navigation-options.component"; |
22 | | -import { NavigationInfoComponent } from "../navigation-options/navigation-info.component"; |
23 | | - |
| 2 | +import { routes } from "../app.routes"; |
| 3 | +import * as platform from "platform"; |
24 | 4 |
|
25 | 5 | @Component({ |
26 | 6 | selector: "main", |
27 | 7 | template: ` |
28 | | - <StackLayout> |
29 | | - <Label text="Main Component" class="title"></Label> |
30 | | -
|
31 | | - <StackLayout orientation="horizontal" horizontalAlignment="center"> |
32 | | - <Button text="Template" [nsRouterLink]="['/template']"></Button> |
33 | | - <Button text="Router" [nsRouterLink]="['/router']"></Button> |
34 | | - </StackLayout> |
35 | | -
|
36 | | - <StackLayout orientation="horizontal" horizontalAlignment="center"> |
37 | | - <Button text="First" [nsRouterLink]="['/first']"></Button> |
38 | | - <Button text="Second" [nsRouterLink]="['/second']"></Button> |
39 | | - </StackLayout> |
40 | | -
|
41 | | - <StackLayout orientation="horizontal" horizontalAlignment="center"> |
42 | | - <Button text="ActionBar1" [nsRouterLink]="['/first-action-bar']"></Button> |
43 | | - <Button text="ActionBar2" [nsRouterLink]="['/second-action-bar']"></Button> |
44 | | - </StackLayout> |
45 | | -
|
46 | | - <Button text="Binding" [nsRouterLink]="['/binding']"></Button> |
47 | | -
|
48 | | - <Button text="ListViewExamples" [nsRouterLink]="['/listView']"></Button> |
49 | | - |
50 | | - <StackLayout orientation="horizontal" horizontalAlignment="center"> |
51 | | - <Button text="modal" [nsRouterLink]="['/modal']"></Button> |
52 | | - <Button text="modal(onPush)" [nsRouterLink]="['/modal-on-push']"></Button> |
53 | | - </StackLayout> |
54 | | -
|
55 | | - <Button text="nav-options" [nsRouterLink]="['/nav-options']"></Button> |
56 | | - </StackLayout> |
| 8 | + <WrapLayout id='mainView' [orientation]="orientation"> |
| 9 | + <Button *ngFor="let route of routers" [text]="route.data.title" [nsRouterLink]="route.path" [color]="route.data.isNavigatable == true ? 'red':'blue'" height="40"></Button> |
| 10 | + </WrapLayout> |
57 | 11 | `, |
58 | 12 | }) |
59 | | -export class MainComponent { } |
| 13 | +export class MainComponent { |
| 14 | + private _routers = []; |
| 15 | + private _routes = require("../app.routes").routes |
| 16 | + private _orientation: string = "vertical"; |
| 17 | + |
| 18 | + constructor() { |
| 19 | + let routs = this._routes.filter((item) => { |
| 20 | + let isNavigatable = item.data.isNavigatable != undefined && item.data.isNavigatable == true && item.path != ''; |
| 21 | + console.log("Page route:" + item.path + "; page name: " + item.data.title + "; isNavigatable: " + isNavigatable); |
| 22 | + return isNavigatable; |
| 23 | + }); |
| 24 | + |
| 25 | + this._routers = routs; |
| 26 | + if (platform.isAndroid) { |
| 27 | + this._orientation = "horizontal"; |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + get routers() { |
| 32 | + return this._routers; |
| 33 | + } |
| 34 | + |
| 35 | + get orientation() { |
| 36 | + return this._orientation; |
| 37 | + } |
| 38 | +} |
60 | 39 |
|
61 | 40 | @Component({ |
62 | 41 | selector: 'navigation-main', |
63 | 42 | template: `<page-router-outlet></page-router-outlet>` |
64 | 43 | }) |
65 | 44 | export class NavigationMainPageRouter { } |
66 | | - |
67 | | - |
68 | | -export const routes = [ |
69 | | - { path: '', component: MainComponent }, |
70 | | - { path: 'template', component: AppComponent }, |
71 | | - { path: 'router', component: NavigationTestRouter, children: NavigationSubRoutes }, |
72 | | - { path: 'first', component: FirstComponent }, |
73 | | - { path: 'second', component: SecondComponent }, |
74 | | - |
75 | | - { path: 'first-action-bar', component: FirstComponentActionBar }, |
76 | | - { path: 'second-action-bar', component: SecondComponentActionBar }, |
77 | | - { path: 'binding', component: BindingComponent }, |
78 | | - |
79 | | - { path: 'listView', component: ListViewMainPageComponent }, |
80 | | - { path: 'listView/commonTemplate', component: ListViewComponent }, |
81 | | - { path: 'listView/customTemplate', component: ListViewControlComponent }, |
82 | | - { path: 'listView/asyncPipeTemplate', component: ListViewAsyncPipeComponent }, |
83 | | - |
84 | | - { path: 'modal', component: ModalTest }, |
85 | | - { path: 'modal-on-push', component: ModalTestWithPushStrategy }, |
86 | | - |
87 | | - { path: 'nav-options', component: NavigationOptionsComponent }, |
88 | | - { path: 'nav-info', component: NavigationInfoComponent } |
89 | | -]; |
90 | | - |
91 | | -export const routableComponents = [ |
92 | | - AppComponent, MainComponent, NavigationTestRouter, |
93 | | - FirstComponent, SecondComponent, |
94 | | - FirstComponentActionBar, SecondComponentActionBar, |
95 | | - BindingComponent, |
96 | | - ListViewMainPageComponent, ListViewComponent, |
97 | | - ListViewControlComponent, ListViewAsyncPipeComponent, |
98 | | - ModalTest, ModalTestWithPushStrategy, |
99 | | - NavigationOptionsComponent, NavigationInfoComponent, |
100 | | -] |
0 commit comments