Skip to content

Commit

Permalink
fix(core): page frame reference not unset on native view disposal (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
CatchABus committed Oct 23, 2023
1 parent c78ea79 commit 22c21b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 0 additions & 2 deletions packages/core/ui/frame/frame-common.ts
Expand Up @@ -201,7 +201,6 @@ export class FrameBase extends CustomLayoutView {
public _removeEntry(removed: BackstackEntry): void {
const page = removed.resolvedPage;
const frame = page.frame;
page._frame = null;
if (frame) {
frame._removeView(page);
} else {
Expand Down Expand Up @@ -250,7 +249,6 @@ export class FrameBase extends CustomLayoutView {
this._resolvedPage = newPage;

this._addView(newPage);
newPage._frame = this;
}

this._currentEntry = entry;
Expand Down
4 changes: 0 additions & 4 deletions packages/core/ui/page/index.d.ts
Expand Up @@ -143,10 +143,6 @@ export declare class Page extends PageBase {
* @private
*/
hasActionBar: boolean;
/**
* @private
*/
_frame: Frame;

/**
* A method called before navigating to the page.
Expand Down
9 changes: 2 additions & 7 deletions packages/core/ui/page/index.ios.ts
Expand Up @@ -134,7 +134,6 @@ class UIViewControllerImpl extends UIViewController {
frame._resolvedPage = owner;

if (!owner.parent) {
owner._frame = frame;
if (!frame._styleScope) {
// Make sure page will have styleScope even if frame don't.
owner._updateStyleScope();
Expand Down Expand Up @@ -427,10 +426,6 @@ export class Page extends PageBase {
return this._ios;
}

get frame(): Frame {
return this._frame;
}

public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
//
}
Expand All @@ -440,7 +435,7 @@ export class Page extends PageBase {
}

public _shouldDelayLayout(): boolean {
return this._frame && this._frame._animationInProgress;
return this.frame && this.frame._animationInProgress;
}

public onLoaded(): void {
Expand Down Expand Up @@ -469,7 +464,7 @@ export class Page extends PageBase {

public _updateStatusBarStyle(value?: string) {
const frame = this.frame;
if (this.frame && value) {
if (frame && value) {
const navigationController: UINavigationController = frame.ios.controller;
const navigationBar = navigationController.navigationBar;

Expand Down
15 changes: 10 additions & 5 deletions packages/core/ui/page/page-common.ts
Expand Up @@ -27,8 +27,6 @@ export class PageBase extends ContentView {
private _navigationContext: any;
private _actionBar: ActionBar;

public _frame: Frame;

public actionBarHidden: boolean;
public enableSwipeBackNavigation: boolean;
public backgroundSpanUnderStatusBar: boolean;
Expand Down Expand Up @@ -81,6 +79,15 @@ export class PageBase extends ContentView {
return this;
}

public _parentChanged(oldParent: View): void {
const newParent = this.parent;
if (newParent && !isFrame(newParent)) {
throw new Error(`Page can only be nested inside Frame. New parent: ${newParent}`);
}

super._parentChanged(oldParent);
}

public _addChildFromBuilder(name: string, value: any) {
if (value instanceof ActionBar) {
this.actionBar = value;
Expand All @@ -94,9 +101,7 @@ export class PageBase extends ContentView {
}

get frame(): Frame {
const parent = this.parent;

return isFrame(parent) ? (parent as Frame) : undefined;
return <Frame>this.parent;
}

private createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {
Expand Down

0 comments on commit 22c21b7

Please sign in to comment.