feat(core): ability to embed into platform host projects (#10465)

This commit is contained in:
Vladimir Mutafov
2024-07-02 02:47:33 +03:00
committed by GitHub
parent 9fd361c2e6
commit 779d79285d
19 changed files with 885 additions and 672 deletions

View File

@@ -1,5 +1,6 @@
import { profile } from '../profiling';
import { View } from '../ui';
import { View } from '../ui/core/view';
import { isEmbedded } from '../ui/embedding';
import { AndroidActivityCallbacks, NavigationEntry } from '../ui/frame/frame-common';
import type { AndroidApplication as IAndroidApplication } from './application';
import { ApplicationCommon } from './application-common';
@@ -10,6 +11,12 @@ declare namespace com {
class NativeScriptApplication extends android.app.Application {
static getInstance(): NativeScriptApplication;
}
namespace embedding {
class ApplicationHolder {
static getInstance(): android.app.Application;
}
}
}
}
@@ -358,6 +365,10 @@ export class AndroidApplication extends ApplicationCommon implements IAndroidApp
nativeApp = com.tns.NativeScriptApplication.getInstance();
}
if (!nativeApp && isEmbedded()) {
nativeApp = com.tns.embedding.ApplicationHolder.getInstance();
}
// the getInstance might return null if com.tns.NativeScriptApplication exists but is not the starting app type
if (!nativeApp) {
// TODO: Should we handle the case when a custom application type is provided and the user has not explicitly initialized the application module?

View File

@@ -1,5 +1,6 @@
import { profile } from '../profiling';
import { View } from '../ui';
import { View } from '../ui/core/view';
import { isEmbedded } from '../ui/embedding';
import { IOSHelper } from '../ui/core/view/view-helper';
import { NavigationEntry } from '../ui/frame/frame-interfaces';
import * as Utils from '../utils';
@@ -367,7 +368,7 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication
});
if (this._window) {
if (root !== null && !NativeScriptEmbedder.sharedInstance().delegate) {
if (root !== null && !isEmbedded()) {
this.setWindowContent(root);
}
} else {