4
4
5
5
import { NativeScriptModule } from "nativescript-angular/nativescript.module" ;
6
6
import { platformNativeScriptDynamic } from "nativescript-angular/platform" ;
7
- import { NativeScriptRouterModule , NSModuleFactoryLoader } from "nativescript-angular/router" ;
7
+ import { NativeScriptRouterModule } from "nativescript-angular/router" ;
8
8
import { NativeScriptFormsModule } from "nativescript-angular/forms" ;
9
9
10
10
import { AppComponent } from "./app.component" ;
@@ -33,17 +33,38 @@ import { rendererTraceCategory, routerTraceCategory } from "nativescript-angular
33
33
34
34
import { BehaviorSubject } from "rxjs/BehaviorSubject" ;
35
35
36
- import trace = require( "trace" ) ;
37
- trace . setCategories ( rendererTraceCategory + "," + routerTraceCategory ) ;
36
+ import { GridLayout , ItemSpec } from "tns-core-modules/ui/layouts/grid-layout/grid-layout" ;
37
+
38
+ import { enable , addCategories , categories } from "trace" ;
39
+ import { Color } from "tns-core-modules/color/color" ;
40
+
41
+ addCategories ( rendererTraceCategory ) ;
42
+ // addCategories(routerTraceCategory);
43
+ addCategories ( categories . ViewHierarchy ) ;
44
+
38
45
// trace.setCategories(routerTraceCategory);
39
- // trace. enable();
46
+ enable ( ) ;
40
47
41
48
// nativeScriptBootstrap(GestureComponent);
42
49
// nativeScriptBootstrap(LayoutsComponent);
43
50
// nativeScriptBootstrap(IconFontComponent);
44
51
const platform = platformNativeScriptDynamic ( { bootInExistingPage : true } ) ;
45
- const root = new StackLayout ( ) ;
46
- const rootViewProvider = { provide : APP_ROOT_VIEW , useValue : root } ;
52
+ const root = new GridLayout ( ) ;
53
+
54
+ let rootViewsCount = 0 ;
55
+ let colors = [ "lightgreen" , "lightblue" , "lightpink" ] ;
56
+ function createRootProvider ( ) {
57
+ root . addRow ( new ItemSpec ( 1 , "star" ) ) ;
58
+
59
+ const appRootView = new StackLayout ( ) ;
60
+ GridLayout . setRow ( appRootView , rootViewsCount ) ;
61
+ root . addChild ( appRootView ) ;
62
+ appRootView . backgroundColor = new Color ( colors [ rootViewsCount % colors . length ] ) ;
63
+
64
+ rootViewsCount ++ ;
65
+ return { provide : APP_ROOT_VIEW , useValue : appRootView } ;
66
+ }
67
+
47
68
const singlePageHooksLog = new BehaviorSubject ( [ ] ) ;
48
69
const singlePageHooksLogProvider = { provide : HOOKS_LOG , useValue : singlePageHooksLog } ;
49
70
const multiPageHooksLog = new BehaviorSubject ( [ ] ) ;
@@ -52,108 +73,58 @@ const lazyLoadHooksLog = new BehaviorSubject([]);
52
73
export const lazyLoadHooksLogProvider = { provide : HOOKS_LOG , useValue : lazyLoadHooksLog } ;
53
74
54
75
@NgModule ( {
55
- bootstrap : [
56
- SinglePageMain
57
- ] ,
58
- declarations : [
59
- SinglePageMain ,
60
- FirstComponent ,
61
- SecondComponent ,
62
- ] ,
63
- entryComponents : [
64
- SinglePageMain ,
65
- FirstComponent ,
66
- SecondComponent ,
67
- ] ,
76
+ bootstrap : [ SinglePageMain ] ,
77
+ declarations : [ SinglePageMain , FirstComponent , SecondComponent ] ,
78
+ entryComponents : [ SinglePageMain , FirstComponent , SecondComponent ] ,
68
79
imports : [
69
80
NativeScriptModule ,
70
81
NativeScriptFormsModule ,
71
82
NativeScriptRouterModule ,
72
83
NativeScriptRouterModule . forRoot ( singlePageRoutes ) ,
73
84
] ,
74
- exports : [
75
- NativeScriptModule ,
76
- NativeScriptFormsModule ,
77
- NativeScriptRouterModule ,
78
- ] ,
79
- providers : [
80
- rootViewProvider ,
81
- singlePageHooksLogProvider ,
82
- ]
85
+ exports : [ NativeScriptModule , NativeScriptFormsModule , NativeScriptRouterModule ] ,
86
+ providers : [ createRootProvider ( ) , singlePageHooksLogProvider ] ,
83
87
} )
84
- class SinglePageModule { }
88
+ class SinglePageModule { }
85
89
86
90
@NgModule ( {
87
- bootstrap : [
88
- MultiPageMain
89
- ] ,
90
- declarations : [
91
- MultiPageMain ,
92
- FirstComponent ,
93
- SecondComponent ,
94
- ] ,
95
- entryComponents : [
96
- MultiPageMain ,
97
- FirstComponent ,
98
- SecondComponent ,
99
- ] ,
91
+ bootstrap : [ MultiPageMain ] ,
92
+ declarations : [ MultiPageMain , FirstComponent , SecondComponent ] ,
93
+ entryComponents : [ MultiPageMain , FirstComponent , SecondComponent ] ,
100
94
imports : [
101
95
NativeScriptModule ,
102
96
NativeScriptFormsModule ,
103
97
NativeScriptRouterModule ,
104
98
NativeScriptRouterModule . forRoot ( multiPageRoutes ) ,
105
99
] ,
106
- exports : [
107
- NativeScriptModule ,
108
- NativeScriptFormsModule ,
109
- NativeScriptRouterModule ,
110
- ] ,
111
- providers : [
112
- rootViewProvider ,
113
- multiPageHooksLogProvider ,
114
- ]
100
+ exports : [ NativeScriptModule , NativeScriptFormsModule , NativeScriptRouterModule ] ,
101
+ providers : [ createRootProvider ( ) , multiPageHooksLogProvider ] ,
115
102
} )
116
- class MultiPageModule { }
103
+ class MultiPageModule { }
117
104
118
105
@NgModule ( {
119
- bootstrap : [
120
- LazyLoadMain
121
- ] ,
122
- declarations : [
123
- LazyLoadMain ,
124
- FirstComponent ,
125
- ] ,
126
- entryComponents : [
127
- LazyLoadMain ,
128
- ] ,
106
+ bootstrap : [ LazyLoadMain ] ,
107
+ declarations : [ LazyLoadMain , FirstComponent ] ,
108
+ entryComponents : [ LazyLoadMain ] ,
129
109
imports : [
130
110
NativeScriptModule ,
131
111
NativeScriptFormsModule ,
132
112
NativeScriptRouterModule ,
133
113
NativeScriptRouterModule . forRoot ( lazyLoadRoutes ) ,
134
114
] ,
135
- exports : [
136
- NativeScriptModule ,
137
- NativeScriptFormsModule ,
138
- NativeScriptRouterModule ,
139
- ] ,
115
+ exports : [ NativeScriptModule , NativeScriptFormsModule , NativeScriptRouterModule ] ,
140
116
providers : [
141
- rootViewProvider ,
117
+ createRootProvider ( ) ,
142
118
lazyLoadHooksLogProvider ,
143
- { provide : NgModuleFactoryLoader , useClass : NSModuleFactoryLoader } ,
144
- ]
119
+ ] ,
145
120
} )
146
- class LazyLoadModule { }
121
+ class LazyLoadModule { }
147
122
148
- application . start ( {
123
+ application . run ( {
149
124
create : ( ) : Page => {
150
- const page = new Page ( ) ;
151
- page . content = root ;
152
-
153
- let onLoadedHandler = function ( args ) {
154
- page . off ( "loaded" , onLoadedHandler ) ;
125
+ let onLoadedHandler = function ( args ) {
126
+ root . off ( "loaded" , onLoadedHandler ) ;
155
127
// profiling.stop('application-start');
156
- console . log ( "Page loaded" ) ;
157
128
158
129
// profiling.start('ng-bootstrap');
159
130
console . log ( "BOOTSTRAPPING TEST APPS..." ) ;
@@ -163,8 +134,8 @@ application.start({
163
134
platform . bootstrapModule ( LazyLoadModule ) ;
164
135
} ;
165
136
166
- page . on ( "loaded" , onLoadedHandler ) ;
137
+ root . on ( "loaded" , onLoadedHandler ) ;
167
138
168
- return page ;
169
- }
139
+ return < any > root ;
140
+ } ,
170
141
} ) ;
0 commit comments