mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): ability to embed into platform host projects (#10465)
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user