From d5409c1c679ab80416bdd1849bbb0fe3325d3614 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Thu, 19 Nov 2020 17:34:57 -0300 Subject: [PATCH] feat: allow app to start without a root view --- packages/core/application/application-interfaces.ts | 2 +- packages/core/application/index.d.ts | 3 ++- packages/core/application/index.ios.ts | 4 +++- packages/core/ui/frame/index.android.ts | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/application/application-interfaces.ts b/packages/core/application/application-interfaces.ts index 9427f68a4..13ea7fa5c 100644 --- a/packages/core/application/application-interfaces.ts +++ b/packages/core/application/application-interfaces.ts @@ -20,7 +20,7 @@ export interface ApplicationEventData extends EventData { } export interface LaunchEventData extends ApplicationEventData { - root?: View; + root?: View | null; savedInstanceState?: any /* android.os.Bundle */; } diff --git a/packages/core/application/index.d.ts b/packages/core/application/index.d.ts index d2cb041a4..07416d5f8 100644 --- a/packages/core/application/index.d.ts +++ b/packages/core/application/index.d.ts @@ -103,8 +103,9 @@ export interface LaunchEventData extends ApplicationEventData { /** * The root view for this Window on iOS or Activity for Android. * If not set a new Frame will be created as a root view in order to maintain backwards compatibility. + * If explicitly set to null, there will be no root view. */ - root?: View; + root?: View | null; savedInstanceState?: any /* android.os.Bundle */; } diff --git a/packages/core/application/index.ios.ts b/packages/core/application/index.ios.ts index e502b4758..f36cafb70 100644 --- a/packages/core/application/index.ios.ts +++ b/packages/core/application/index.ios.ts @@ -207,7 +207,9 @@ export class iOSApplication implements iOSApplicationDefinition { // this._window will be undefined when NS app is embedded in a native one if (this._window) { - this.setWindowContent(args.root); + if (args.root !== null) { + this.setWindowContent(args.root); + } } else { this._window = UIApplication.sharedApplication.delegate.window; } diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index 9203131ee..32a1a5090 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -1301,13 +1301,18 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { if (!rootView) { const mainEntry = application.getMainEntry(); const intent = activity.getIntent(); + let ensureNoRootView = false; if (fireLaunchEvent) { // entry point for Angular and Vue frameworks rootView = notifyLaunch(intent, savedInstanceState, null); + ensureNoRootView = rootView === null; } if (!rootView) { + if(ensureNoRootView) { + return; + } // entry point for NS Core if (!mainEntry) { // Also handles scenarios with Angular and Vue where the notifyLaunch didn't return a root view.