mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(core): Frame to Page property propagation (#10225)
This commit is contained in:
committed by
GitHub
parent
d8efb7a826
commit
4e62b00ddb
@@ -43,6 +43,14 @@ export class FrameBase extends CustomLayoutView {
|
||||
|
||||
public actionBarVisibility: 'auto' | 'never' | 'always';
|
||||
public _currentEntry: BackstackEntry;
|
||||
|
||||
/**
|
||||
* A reference of current page that is set earlier than current entry.
|
||||
* Using this property, methods like 'eachChildView' and '_childrenCount' gain access to page view
|
||||
* just in time for calls like '_addView' to perform view-tree iterations.
|
||||
*/
|
||||
public _resolvedPage: Page;
|
||||
|
||||
public _animationInProgress = false;
|
||||
public _executingContext: NavigationContext;
|
||||
public _isInFrameStack = false;
|
||||
@@ -238,6 +246,8 @@ export class FrameBase extends CustomLayoutView {
|
||||
// In case we navigated forward to a page that was in the backstack
|
||||
// with clearHistory: true
|
||||
if (!newPage.frame) {
|
||||
this._resolvedPage = newPage;
|
||||
|
||||
this._addView(newPage);
|
||||
newPage._frame = this;
|
||||
}
|
||||
@@ -456,7 +466,6 @@ export class FrameBase extends CustomLayoutView {
|
||||
if (this._currentEntry) {
|
||||
return this._currentEntry.resolvedPage;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -508,7 +517,7 @@ export class FrameBase extends CustomLayoutView {
|
||||
}
|
||||
|
||||
get _childrenCount(): number {
|
||||
if (this.currentPage) {
|
||||
if (this._resolvedPage) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -516,7 +525,7 @@ export class FrameBase extends CustomLayoutView {
|
||||
}
|
||||
|
||||
public eachChildView(callback: (child: View) => boolean) {
|
||||
const page = this.currentPage;
|
||||
const page = this._resolvedPage;
|
||||
if (page) {
|
||||
callback(page);
|
||||
}
|
||||
|
||||
@@ -913,6 +913,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
return null;
|
||||
}
|
||||
|
||||
frame._resolvedPage = page;
|
||||
|
||||
if (page.parent === frame) {
|
||||
// If we are navigating to a page that was destroyed
|
||||
// reinitialize its UI.
|
||||
@@ -920,6 +922,10 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
const context = (container && container.getContext()) || (inflater && inflater.getContext());
|
||||
page._setupUI(context);
|
||||
}
|
||||
|
||||
if (frame.isLoaded && !page.isLoaded) {
|
||||
page.callLoaded();
|
||||
}
|
||||
} else {
|
||||
if (!frame._styleScope) {
|
||||
// Make sure page will have styleScope even if parents don't.
|
||||
@@ -929,10 +935,6 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
frame._addView(page);
|
||||
}
|
||||
|
||||
if (frame.isLoaded && !page.isLoaded) {
|
||||
page.callLoaded();
|
||||
}
|
||||
|
||||
const savedState = entry.viewSavedState;
|
||||
if (savedState) {
|
||||
(<android.view.View>page.nativeViewProtected).restoreHierarchyState(savedState);
|
||||
|
||||
@@ -120,7 +120,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
return;
|
||||
}
|
||||
|
||||
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
|
||||
const frame: Frame = this.navigationController ? (<any>this.navigationController).owner : null;
|
||||
const newEntry = this[ENTRY];
|
||||
|
||||
// Don't raise event if currentPage was showing modal page.
|
||||
@@ -130,6 +130,8 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
|
||||
if (frame) {
|
||||
frame._resolvedPage = owner;
|
||||
|
||||
if (!owner.parent) {
|
||||
owner._frame = frame;
|
||||
if (!frame._styleScope) {
|
||||
|
||||
Reference in New Issue
Block a user