mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: Add methods to get the root view and set a different root view at run time (#5386)
* feat: add option to set a different root view at run time * feat: expose application getRootView method * refactor: Introduce ViewEntry interface * fix: Respect root view rturned from launch event in Android * refactor: getRootView() code + caching root view per activity. * refactor: add app-root.xml in apps * refactor: http test made async
This commit is contained in:
committed by
Alexander Vakrilov
parent
0c8275fa06
commit
b113b0021a
@@ -100,6 +100,10 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
get rootView() : View {
|
||||
return this._rootView;
|
||||
}
|
||||
|
||||
public addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): NotificationObserver {
|
||||
const observer = NotificationObserver.initWithCallback(onReceiveCallback);
|
||||
utils.ios.getter(NSNotificationCenter, NSNotificationCenter.defaultCenter).addObserverSelectorNameObject(observer, "onReceive", notificationName, null);
|
||||
@@ -263,6 +267,10 @@ export function getMainEntry() {
|
||||
return mainEntry;
|
||||
}
|
||||
|
||||
export function getRootView() {
|
||||
return iosApp.rootView;
|
||||
}
|
||||
|
||||
// NOTE: for backwards compatibility. Remove for 4.0.0.
|
||||
let createRootFrame = true;
|
||||
let started: boolean = false;
|
||||
@@ -296,6 +304,12 @@ export function run(entry?: string | NavigationEntry) {
|
||||
start(entry);
|
||||
}
|
||||
|
||||
export function _resetRootView(entry?: NavigationEntry | string) {
|
||||
createRootFrame = false;
|
||||
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
|
||||
iosApp.setWindowContent();
|
||||
}
|
||||
|
||||
export function getNativeApplication(): UIApplication {
|
||||
return iosApp.nativeApp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user