mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(ios): navigatingTo event handling (#10120)
This commit is contained in:
@@ -307,7 +307,16 @@ export class Frame extends FrameBase {
|
||||
}
|
||||
|
||||
public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) {
|
||||
super._onNavigatingTo(backstackEntry, isBack);
|
||||
// for now to not break iOS events chain (calling navigation events from controller delegates)
|
||||
// we dont call super(which would also trigger events) but only notify the frame of the navigation
|
||||
// though it means events are not triggered at the same time (lifecycle) on iOS / Android
|
||||
this.notify({
|
||||
eventName: Page.navigatingToEvent,
|
||||
object: this,
|
||||
isBack,
|
||||
entry: backstackEntry,
|
||||
fromEntry: this._currentEntry,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,14 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
|
||||
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
|
||||
const newEntry = this[ENTRY];
|
||||
|
||||
// Don't raise event if currentPage was showing modal page.
|
||||
if (!owner._presentedViewController && newEntry && (!frame || frame.currentPage !== owner)) {
|
||||
const isBack = isBackNavigationTo(owner, newEntry);
|
||||
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
|
||||
}
|
||||
|
||||
if (frame) {
|
||||
if (!owner.parent) {
|
||||
owner._frame = frame;
|
||||
|
||||
Reference in New Issue
Block a user