fix(core): guard unstable page/frame init contexts under async conditions (#9428)

This commit is contained in:
Nathan Walker
2021-05-30 12:02:38 -07:00
committed by GitHub
parent 04381fa3e7
commit d3bc4d5b82
3 changed files with 13 additions and 7 deletions

View File

@ -353,6 +353,9 @@ export class ActionBar extends ActionBarBase {
} }
private setColor(navBar: UINavigationBar, color?: Color) { private setColor(navBar: UINavigationBar, color?: Color) {
if (!navBar) {
return;
}
if (color) { if (color) {
navBar.titleTextAttributes = <any>{ navBar.titleTextAttributes = <any>{
[NSForegroundColorAttributeName]: color.ios, [NSForegroundColorAttributeName]: color.ios,
@ -443,13 +446,12 @@ export class ActionBar extends ActionBarBase {
} }
private get navBar(): UINavigationBar { private get navBar(): UINavigationBar {
const page = this.page;
// Page should be attached to frame to update the action bar. // Page should be attached to frame to update the action bar.
if (!page || !page.frame) { if (this.page?.frame?.ios?.controller) {
return (<UINavigationController>this.page.frame.ios.controller).navigationBar;
} else {
return undefined; return undefined;
} }
return (<UINavigationController>page.frame.ios.controller).navigationBar;
} }
[colorProperty.getDefault](): UIColor { [colorProperty.getDefault](): UIColor {

View File

@ -224,7 +224,7 @@ export class Frame extends FrameBase {
this._ios._disableNavBarAnimation = disableNavBarAnimationCache; this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
} }
if (this._ios.controller.navigationBar) { if (this._ios.controller?.navigationBar) {
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty(); this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
} }
@ -666,7 +666,9 @@ class iOSFrame implements iOSFrameDefinition {
} }
public set showNavigationBar(value: boolean) { public set showNavigationBar(value: boolean) {
this._showNavigationBar = value; this._showNavigationBar = value;
this._controller.setNavigationBarHiddenAnimated(!value, !this._disableNavBarAnimation); if (this._controller) {
this._controller.setNavigationBarHiddenAnimated(!value, !this._disableNavBarAnimation);
}
} }
public get navBarVisibility(): 'auto' | 'never' | 'always' { public get navBarVisibility(): 'auto' | 'never' | 'always' {

View File

@ -177,7 +177,9 @@ class UIViewControllerImpl extends UIViewController {
} }
// If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate. // If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate.
frame.ios.controller.delegate = this[DELEGATE]; if (frame.ios?.controller) {
frame.ios.controller.delegate = this[DELEGATE];
}
frame._processNavigationQueue(owner); frame._processNavigationQueue(owner);