-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathapp.ts
169 lines (155 loc) · 6.73 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//import "globals";
// import "./modules";
//global.registerModule("./main-page", function () { return require("./main-page"); });
//import * as profiling from "./profiling";
//profiling.start("application-start");
// "nativescript-angular/application" import should be first in order to load some required settings (like globals and reflect-metadata)
import {
NativeScriptModule,
platformNativeScriptDynamic,
NativeScriptRouterModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
routerTraceCategory,
rendererTraceCategory,
listViewTraceCategory,
PAGE_FACTORY,
PageFactory,
PageFactoryOptions,
onAfterLivesync,
onBeforeLivesync
} from "nativescript-angular";
import { NgModule } from "@angular/core";
import { Router } from "@angular/router";
import { Page } from "ui/page";
import { Color } from "color";
import { setCategories, enable } from "trace";
// setCategories(rendererTraceCategory);
// setCategories(routerTraceCategory);
// setCategories(listViewTraceCategory);
enable();
import { RendererTest } from "./examples/renderer-test";
import { TabViewTest } from "./examples/tab-view/tab-view-test";
import { Benchmark } from "./performance/benchmark";
import { ListTest } from "./examples/list/list-test";
import { ListTemplateSelectorTest } from "./examples/list/template-selector";
import { ListTestAsync, ListTestFilterAsync } from "./examples/list/list-test-async";
import { ImageTest } from "./examples/image/image-test";
import { HttpTest } from "./examples/http/http-test";
import { ActionBarTest } from "./examples/action-bar/action-bar-test";
import { ModalTest } from "./examples/modal/modal-test";
import { PlatfromDirectivesTest } from "./examples/platform-directives/platform-directives-test";
import { LivesyncApp } from "./examples/livesync-test/livesync-test-app";
// new router
import { RouterOutletAppComponent } from "./examples/router/router-outlet-test";
import { PageRouterOutletAppComponent } from "./examples/router/page-router-outlet-test";
import { PageRouterOutletNestedAppComponent } from "./examples/router/page-router-outlet-nested-test";
import { ClearHistoryAppComponent } from "./examples/router/clear-history-test";
import { LoginAppComponent } from "./examples/router/login-test";
// animations
import { AnimationEnterLeaveTest } from "./examples/animation/animation-enter-leave-test";
import { AnimationKeyframesTest } from "./examples/animation/animation-keyframes-test";
import { AnimationNgClassTest } from "./examples/animation/animation-ngclass-test";
import { AnimationStatesTest } from "./examples/animation/animation-states-test";
@NgModule({
declarations: [
],
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptRouterModule,
],
exports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptRouterModule,
],
providers: []
})
class ExampleModule { }
function makeExampleModule(componentType) {
let imports: any[] = [ExampleModule];
if (componentType.routes) {
imports.push(NativeScriptRouterModule.forRoot(componentType.routes))
}
let exports: any[] = [];
if (componentType.exports) {
exports = componentType.exports;
}
let entries = [];
if (componentType.entries) {
entries = componentType.entries;
}
entries.push(componentType);
let providers = [];
if (componentType.providers) {
providers = componentType.providers;
}
@NgModule({
bootstrap: [componentType],
imports: imports,
entryComponents: entries,
declarations: [
...entries,
...exports,
],
providers: providers,
exports: exports,
})
class ExampleModuleForComponent { }
return ExampleModuleForComponent;
}
const customPageFactoryProvider = {
provide: PAGE_FACTORY,
useValue: (opts: PageFactoryOptions) => {
const page = new Page();
page.backgroundColor = opts.isModal ? new Color("lightblue") : new Color("lightgreen");
return page;
}
};
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic(undefined, [customPageFactoryProvider]).bootstrapModule(makeExampleModule(RendererTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(TabViewTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(Benchmark));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ListTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ListTemplateSelectorTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ListTestAsync));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ImageTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ModalTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(HttpTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(PlatfromDirectivesTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ActionBarTest));
// router
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(RouterOutletAppComponent));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(PageRouterOutletAppComponent));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(PageRouterOutletNestedAppComponent));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ClearHistoryAppComponent));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LoginAppComponent));
// animations
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
// platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
//Livesync test
//var cachedUrl: string;
//onBeforeLivesync.subscribe((moduleRef) => {
// console.log("------- onBeforeLivesync");
// if (moduleRef) {
// const router = <Router>moduleRef.injector.get(Router);
// cachedUrl = router.url;
// console.log("------- Caching URL: " + cachedUrl);
// }
//});
//
//onAfterLivesync.subscribe((moduleRef) => {
// console.log("------- onAfterLivesync cachedUrl:");
// const router = <Router>moduleRef.injector.get(Router);
// router.events.subscribe(e => console.log(e.toString()));
// if (router && cachedUrl) {
// setTimeout(() => { router.navigateByUrl(cachedUrl); }, 0);
// }
//});
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LivesyncApp));
console.log("APP RESTART");