@@ -16,8 +16,8 @@ export * from "./application-common";
1616
1717// TODO: Remove this and get it from global to decouple builder for angular
1818import { createViewFromEntry } from "../ui/builder" ;
19- import { ios as iosView , ViewBase } from "../ui/core/view" ;
20- import { Frame , View , NavigationEntry } from "../ui/frame" ;
19+ import { ios as iosView , View } from "../ui/core/view" ;
20+ import { Frame , NavigationEntry } from "../ui/frame" ;
2121import { ios } from "../ui/utils" ;
2222import * as utils from "../utils/utils" ;
2323import { profile } from "../profiling" ;
@@ -51,7 +51,7 @@ class IOSApplication implements IOSApplicationDefinition {
5151 private _currentOrientation = utils . ios . getter ( UIDevice , UIDevice . currentDevice ) . orientation ;
5252 private _window : UIWindow ;
5353 private _observers : Array < NotificationObserver > ;
54- private _rootView : ViewBase ;
54+ private _rootView : View ;
5555
5656 constructor ( ) {
5757 this . _observers = new Array < NotificationObserver > ( ) ;
@@ -114,18 +114,7 @@ class IOSApplication implements IOSApplicationDefinition {
114114 notify ( args ) ;
115115 notify ( < LoadAppCSSEventData > { eventName : "loadAppCss" , object : < any > this , cssFile : getCssFileName ( ) } ) ;
116116
117- const rootView = createRootView ( args . root ) ;
118- this . _rootView = rootView ;
119- const controller = getViewController ( rootView ) ;
120- this . _window . rootViewController = controller ;
121- if ( createRootFrame ) {
122- // Don't setup as styleScopeHost
123- rootView . _setupUI ( { } ) ;
124- } else {
125- // setup view as styleScopeHost
126- rootView . _setupAsRootView ( { } ) ;
127- }
128- this . _window . makeKeyAndVisible ( ) ;
117+ this . setWindowContent ( args . root ) ;
129118 }
130119
131120 @profile
@@ -193,12 +182,44 @@ class IOSApplication implements IOSApplicationDefinition {
193182 } ) ;
194183 }
195184 }
185+
186+ public _onLivesync ( ) : void {
187+ // If view can't handle livesync set window controller.
188+ if ( ! this . _rootView . _onLivesync ( ) ) {
189+ this . setWindowContent ( ) ;
190+ }
191+ }
192+
193+ public setWindowContent ( view ?: View ) : void {
194+ const rootView = createRootView ( view ) ;
195+ this . _rootView = rootView ;
196+ const controller = getViewController ( rootView ) ;
197+
198+ if ( createRootFrame ) {
199+ // Don't setup as styleScopeHost
200+ rootView . _setupUI ( { } ) ;
201+ } else {
202+ // setup view as styleScopeHost
203+ rootView . _setupAsRootView ( { } ) ;
204+ }
205+
206+ const haveController = this . _window . rootViewController !== null ;
207+ this . _window . rootViewController = controller ;
208+ if ( ! haveController ) {
209+ this . _window . makeKeyAndVisible ( ) ;
210+ }
211+ }
196212}
197213
198214const iosApp = new IOSApplication ( ) ;
199215exports . ios = iosApp ;
200216setApplication ( iosApp ) ;
201217
218+ // attach on global, so it can be overwritten in NativeScript Angular
219+ ( < any > global ) . __onLiveSyncCore = function ( ) {
220+ iosApp . _onLivesync ( ) ;
221+ }
222+
202223let mainEntry : NavigationEntry ;
203224function createRootView ( v ?: View ) {
204225 let rootView = v ;
0 commit comments