mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(ios): frame backstack disposal handling (#10672)
This commit is contained in:

committed by
GitHub

parent
d3d4dfe322
commit
5f8fb2c36a
@ -217,6 +217,13 @@ export class FrameBase extends CustomLayoutView {
|
||||
removed.resolvedPage = null;
|
||||
}
|
||||
|
||||
protected _disposeBackstackEntry(entry: BackstackEntry): void {
|
||||
const page = entry.resolvedPage;
|
||||
if (page) {
|
||||
page._tearDownUI(true);
|
||||
}
|
||||
}
|
||||
|
||||
public navigate(param: any) {
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write(`NAVIGATE`, Trace.categories.Navigation);
|
||||
|
@ -318,11 +318,11 @@ export class Frame extends FrameBase {
|
||||
if (this._tearDownPending) {
|
||||
this._tearDownPending = false;
|
||||
if (!entry.recreated) {
|
||||
clearEntry(entry);
|
||||
this._disposeBackstackEntry(entry);
|
||||
}
|
||||
|
||||
if (current && !current.recreated) {
|
||||
clearEntry(current);
|
||||
this._disposeBackstackEntry(current);
|
||||
}
|
||||
|
||||
// If we have context activity was recreated. Create new fragment
|
||||
@ -493,6 +493,17 @@ export class Frame extends FrameBase {
|
||||
removed.viewSavedState = null;
|
||||
}
|
||||
|
||||
protected _disposeBackstackEntry(entry: BackstackEntry): void {
|
||||
if (entry.fragment) {
|
||||
_clearFragment(entry);
|
||||
}
|
||||
|
||||
entry.recreated = false;
|
||||
entry.fragment = null;
|
||||
|
||||
super._disposeBackstackEntry(entry);
|
||||
}
|
||||
|
||||
public createNativeView() {
|
||||
// Create native view with available _currentEntry occur in Don't Keep Activities
|
||||
// scenario when Activity is recreated on app suspend/resume. Push frame back in frame stack
|
||||
@ -527,12 +538,12 @@ export class Frame extends FrameBase {
|
||||
// Don't destroy current and executing entries or UI will look blank.
|
||||
// We will do it in setCurrent.
|
||||
if (entry !== executingEntry) {
|
||||
clearEntry(entry);
|
||||
this._disposeBackstackEntry(entry);
|
||||
}
|
||||
});
|
||||
|
||||
if (current && !executingEntry) {
|
||||
clearEntry(current);
|
||||
this._disposeBackstackEntry(current);
|
||||
}
|
||||
|
||||
this._android.rootViewGroup = null;
|
||||
@ -641,19 +652,6 @@ function restoreTransitionState(entry: BackstackEntry, snapshot: TransitionState
|
||||
expandedEntry.transitionName = snapshot.transitionName;
|
||||
}
|
||||
|
||||
function clearEntry(entry: BackstackEntry): void {
|
||||
if (entry.fragment) {
|
||||
_clearFragment(entry);
|
||||
}
|
||||
|
||||
entry.recreated = false;
|
||||
entry.fragment = null;
|
||||
const page = entry.resolvedPage;
|
||||
if (page && page._context) {
|
||||
entry.resolvedPage._tearDownUI(true);
|
||||
}
|
||||
}
|
||||
|
||||
let framesCounter = 0;
|
||||
const framesCache = new Array<WeakRef<AndroidFrame>>();
|
||||
|
||||
|
@ -42,6 +42,23 @@ export class Frame extends FrameBase {
|
||||
}
|
||||
|
||||
public disposeNativeView() {
|
||||
const current = this._currentEntry;
|
||||
const executingEntry = this._executingContext ? this._executingContext.entry : null;
|
||||
|
||||
if (executingEntry) {
|
||||
this._disposeBackstackEntry(executingEntry);
|
||||
}
|
||||
|
||||
this.backStack.forEach((entry) => {
|
||||
if (entry !== executingEntry) {
|
||||
this._disposeBackstackEntry(entry);
|
||||
}
|
||||
});
|
||||
|
||||
if (current) {
|
||||
this._disposeBackstackEntry(current);
|
||||
}
|
||||
|
||||
this._removeFromFrameStack();
|
||||
this.viewController = null;
|
||||
this._animatedDelegate = null;
|
||||
|
Reference in New Issue
Block a user