@@ -7,7 +7,7 @@ import { DOCUMENT } from '@angular/common';
7
7
8
8
import { NativeScriptDebug } from './trace' ;
9
9
import { defaultPageFactoryProvider , setRootPage , PageFactory , PAGE_FACTORY , getRootPage } from './platform-providers' ;
10
- import { AppHostView } from './app-host-view' ;
10
+ import { AppHostView , AppHostLaunchAnimationView } from './app-host-view' ;
11
11
12
12
export const onBeforeLivesync = new EventEmitter < NgModuleRef < any > > ( ) ;
13
13
export const onAfterLivesync = new EventEmitter < {
@@ -161,7 +161,6 @@ export class NativeScriptPlatformRef extends PlatformRef {
161
161
@profile
162
162
private bootstrapNativeScriptApp ( ) {
163
163
let rootContent : View ;
164
- let launchView : AppLaunchView ;
165
164
166
165
if ( NativeScriptDebug . isLogEnabled ( ) ) {
167
166
NativeScriptDebug . bootstrapLog ( 'NativeScriptPlatform bootstrap started.' ) ;
@@ -172,12 +171,13 @@ export class NativeScriptPlatformRef extends PlatformRef {
172
171
}
173
172
174
173
let tempAppHostView : AppHostView ;
175
- let usingCustomLaunchView = false ;
174
+ let animatedHostView : AppHostLaunchAnimationView ;
176
175
if ( this . appOptions && this . appOptions . launchView ) {
177
- launchView = this . appOptions . launchView ;
178
- usingCustomLaunchView = true ;
179
- rootContent = launchView ;
180
- setRootPage ( < any > rootContent ) ;
176
+ animatedHostView = new AppHostLaunchAnimationView ( new Color ( this . appOptions && this . appOptions . backgroundColor ? this . appOptions . backgroundColor : '#fff' ) ) ;
177
+ this . appOptions . launchView . style . zIndex = 1000 ;
178
+ animatedHostView . addChild ( this . appOptions . launchView ) ;
179
+ rootContent = animatedHostView . ngAppRoot ;
180
+ setRootPage ( < any > animatedHostView ) ;
181
181
} else {
182
182
// Create a temp page for root of the renderer
183
183
tempAppHostView = new AppHostView ( new Color ( this . appOptions && this . appOptions . backgroundColor ? this . appOptions . backgroundColor : '#fff' ) ) ;
@@ -193,20 +193,11 @@ export class NativeScriptPlatformRef extends PlatformRef {
193
193
NativeScriptDebug . bootstrapLog ( `Angular bootstrap bootstrap done. uptime: ${ profilingUptime ( ) } ` ) ;
194
194
}
195
195
196
- if ( launchView && launchView . cleanup ) {
197
- // cleanup any custom launch views
198
- launchView . cleanup ( ) . then ( ( ) => {
199
- // swap launchView with actual booted view
200
- // todo: experiment in Angular 11 with a setup like this
201
- // Application.resetRootView({
202
- // create: () => {
203
- // // const { page, frame } = this.createFrameAndPage(false);
204
- // // frame._addView(launchView.getChildAt(0));
205
- // const rootView = launchView.getChildAt(0);
206
- // // launchView.parent._removeView(launchView);
207
- // return rootView;//launchView.getChildAt(0);//page;
208
- // },
209
- // });
196
+ if ( this . appOptions . launchView && this . appOptions . launchView . cleanup ) {
197
+ this . appOptions . launchView . cleanup ( ) . then ( ( ) => {
198
+ // cleanup any custom launch views
199
+ animatedHostView . removeChild ( this . appOptions . launchView ) ;
200
+ this . appOptions . launchView = null ;
210
201
} ) ;
211
202
} else {
212
203
rootContent = tempAppHostView . content ;
@@ -236,19 +227,15 @@ export class NativeScriptPlatformRef extends PlatformRef {
236
227
}
237
228
} ;
238
229
239
- if ( usingCustomLaunchView ) {
240
- // Since custom LaunchView could engage with animations, Launch Angular app on next tick
230
+ if ( this . appOptions && this . appOptions . launchView && this . appOptions . launchView . startAnimation ) {
231
+ // start animations on next tick (after initial boot)
241
232
setTimeout ( ( ) => {
242
- if ( this . appOptions . launchView . startAnimation ) {
243
- // ensure launch animation is executed after launchView added to view stack
244
- this . appOptions . launchView . startAnimation ( ) ;
245
- }
246
- bootstrap ( ) ;
233
+ // ensure launch animation is executed after launchView added to view stack
234
+ this . appOptions . launchView . startAnimation ( ) ;
247
235
} ) ;
248
- } else {
249
- bootstrap ( ) ;
250
236
}
251
- if ( ! bootstrapPromiseCompleted && ! usingCustomLaunchView ) {
237
+ bootstrap ( ) ;
238
+ if ( ! bootstrapPromiseCompleted ) {
252
239
const errorMessage = "Bootstrap promise didn't resolve" ;
253
240
if ( NativeScriptDebug . isLogEnabled ( ) ) {
254
241
NativeScriptDebug . bootstrapLogError ( errorMessage ) ;
0 commit comments