fix(ios): navigatingTo event handling (#10120)

This commit is contained in:
farfromrefuge
2022-12-28 17:23:10 +00:00
committed by GitHub
parent 6948f7c032
commit a4f28b8317
4 changed files with 95 additions and 62 deletions

View File

@@ -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,
});
}
}

View File

@@ -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;